File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,19 @@ class Smoothness:
6262 """
6363
6464 def __init__ (self , rate_hz = 50.0 , use_filter = True ):
65- self .rate_hz = rate_hz
65+ # Validate rate_hz
66+ if not isinstance (rate_hz , (int , float )):
67+ raise TypeError (f"rate_hz must be a number, got { type (rate_hz ).__name__ } " )
68+ if rate_hz <= 0 :
69+ raise ValueError (f"rate_hz must be positive, got { rate_hz } " )
70+ if rate_hz > 100000 : # 100 kHz is a reasonable upper limit
71+ raise ValueError (f"rate_hz too high ({ rate_hz } Hz), maximum is 100,000 Hz" )
72+
73+ # Validate use_filter
74+ if not isinstance (use_filter , bool ):
75+ raise TypeError (f"use_filter must be boolean, got { type (use_filter ).__name__ } " )
76+
77+ self .rate_hz = float (rate_hz ) # Ensure it's a float
6678 self .use_filter = use_filter
6779
6880 def _filter_signal (self , signal ):
You can’t perform that action at this time.
0 commit comments