-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Draft of formula data record #302
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #302 +/- ##
===========================================
- Coverage 100.00% 97.50% -2.50%
===========================================
Files 49 50 +1
Lines 2890 2966 +76
Branches 356 358 +2
===========================================
+ Hits 2890 2892 +2
- Misses 0 74 +74
|
decode_function: Callable, | ||
min_value: Optional[float] = None, | ||
max_value: Optional[float] = None, | ||
is_reoccurring: bool = False, |
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.
not needed - it will always be False
min_value: Optional[float] = None, | ||
max_value: Optional[float] = None, | ||
is_reoccurring: bool = False, | ||
min_occurrences: int = 1, |
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.
not needed - always 1
max_value: Optional[float] = None, | ||
is_reoccurring: bool = False, | ||
min_occurrences: int = 1, | ||
max_occurrences: Optional[int] = None, |
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.
not needed - always 1
def contains(self) -> Tuple["AbstractDataRecord", ...]: | ||
return () | ||
|
||
def decode(self, raw_value: int) -> float: |
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.
please adjust the code to handle following scenario:
raw_value | physical_value
0 | 0 km/h (decoding/encoding using encode/decode function)
1 | 0.1 km/h (decoding/encoding using encode/decode function)
...
2999 | 299.9 km/h (decoding/encoding using encode/decode function)
3000 | 3000 (no decoding/encoding - as per RawDataRecord
; potentially to be handled by TableDataRecord
encoding/decoding and adding labels as physical values like Fault
, Init
)
3001 | 3001 (no decoding/encoding - as per RawDataRecord
; potentially to be handled by TableDataRecord
encoding/decoding and adding labels as physical values like Fault
, Init
)
...
In other words we need:
- range where (endocidng/decoding) formulas are applied
- option to mix it with other
DataRecords
outside the formula range
raw_value = super().decode(raw_value) | ||
return self._decode_function(raw_value) | ||
|
||
def encode(self, physical_value: float) -> int: |
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.
same remark as per decode
|
||
def decode(self, raw_value: int) -> DecodedDataRecord: | ||
decoded_data_record: DecodedDataRecord = super().decode(raw_value) | ||
physical_value = (decoded_data_record.raw_value / self._factor) + self._offset |
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.
I think it would be easier to just create encode_formula
and decode_formula
in init
using factor
and offset
. Then you can inherit everything after CustomFormulaDataRecord
cause all the rest would be the same.
Something like that (simplified):
class LinearFormulaDataRecord(CustomFormulaDataRecord):
def __init__(..., factor, offset, ...):
super(..., encode_fomula=lambda x: (x-offset)/factor, decode_formula=lambda x: x*factor + offset, ...
Description
Proposition for FormulaDataRecord