-
Notifications
You must be signed in to change notification settings - Fork 10
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
Ease of use improvements #38
Conversation
Also made that method work with parameter names instead of only parameter identifiers
The check should be performed on all traces that are added, and it should always be done
…modification This allows for constructions like `new Trace(SampleCoding.FLOAT, [0] * sample_count, TraceParameterMap().add('input', bytes.fromhex('0102030405060708')))`
Issues were: incorrect comparison between ndarrays and lists, no support for multi-dimensional arrays, and no detection of empty ndarrays.
1157e50
to
6da200f
Compare
More explicitly set types of ndarray input values
6da200f
to
76da810
Compare
trsfile/parametermap.py
Outdated
|
||
def insert(self, name: str, type: ParameterType, size: int, offset: int): | ||
"""Insert a trace parameter definition into this map in a specified location. If the given offset would put the | ||
new TraceParameter in the middle of a parameter already present in the map, the offset is increased to put add |
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.
Either put
or add
is redundant here
trsfile/parametermap.py
Outdated
def insert_std(self, name: str, size: int, offset: int): | ||
"""Insert a trace parameter definition of a StandardTraceParameter into this map in a specified location. If | ||
the given offset would put the new TraceParameter in the middle of a parameter already present in the map, the | ||
offset is increased to put add the new parameter after that existing one instead. Any parameters already present |
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.
Either put
or add
is redundant here
trsfile/parametermap.py
Outdated
type = StandardTraceParameters.from_identifier(name).parameter_type | ||
self.insert(name, type, size, offset) | ||
except ValueError: | ||
raise ValueError(f"No StandardTraceParameter found with name '{name}'. Either specify a type in this " |
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.
Specifying a type is not possible in this method, right? Maybe you could reference the non-standard one instead?
trsfile/parametermap.py
Outdated
type = StandardTraceParameters.from_identifier(name).parameter_type | ||
self.append(name, type, size) | ||
except ValueError: | ||
raise ValueError(f"No StandardTraceParameter found with name '{name}'. Either specify a type in this " |
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 comment applies here; shouldn't you reference append
in this error message instead?
trsfile/parametermap.py
Outdated
|
||
:param name: The name of the TraceParameter for which to add a definition. This name must match that of a | ||
StandardTraceParameter | ||
:param size: The size of the TraceParameter, in number of values of its type |
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 number of values of its type
is a confusing way to describe this parameter. It suggests to me that the type can have a number of values. How about simply number of elements
instead?
Make sure to update this for the other occurrences, too
trsfile/parametermap.py
Outdated
"""Test whether this RawTraceData could be interpreted by given definitions | ||
|
||
:param definitions: The trace parameter definition map of the trs file to which the trace with this trace | ||
raw trace data will be added |
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.
This sentence is not what you think it is :P
trsfile/traceparameter.py
Outdated
return isinstance(other, type(self)) and self.value == other.value | ||
if not isinstance(other, type(self)): | ||
return False | ||
if (type(self.value) == list or type(self.value) == ndarray) and \ |
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.
These lines are a bit confusing. Can you think of a way to make them more readable?
Ease-of-use improvements based on user feedback.
PR also contains several fixes for bug encountered while implementing these improvements.