-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bound stream computed field with physical limits #82
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 12058948228Details
💛 - Coveralls |
seems fine to me, i guess my question is when does this occur? seems like if the device is giving us impossible values that's a problem with the device not the i/o software, and setting this to 0 could mask that problem. i trust ya but can i have it explained to me why it's preferable to have 0 in the recorded values rather than the value itself, which can be clamped in analysis? |
battery_max_voltage: float = Field( | ||
10.0, | ||
description="Maximum voltage of the battery." | ||
"Scaled battery voltage will be 0 if it is greater than this value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use -1 to make it unambiguous from the value actually being zero (which should never happen, but thinking about downstream data analysis)
Also I think we are getting to the point where we want to have a separate like T = TypeVar("T", bound = Union[int, float])
class ScaledValue(BaseModel, Generic[T]):
factor: T = 1
maximum: Optional[T] = None
minimum: Optional[T] = None
def scale(self, value: T) -> T:
return np.clip(value * factor, self.minimum, self.maximum) So then for example class StreamConfig(BaseModel):
battery_voltage: ScaledValue[float] = ScaledValue(factor = 10, maximum = 20)
vin_voltage: ScaledValue[float] = ScaledValue(factor=1000, maximum = 20) where idk we could compute that battery_voltage:
factor: 100
maximum: 10
# ... cfg = StreamConfig()
cfg.battery_voltage.scale(100) |
📚 Documentation preview 📚: https://miniscope-io--82.org.readthedocs.build/en/82/