Skip to content

Ease of use improvements#38

Merged
TomHogervorst merged 8 commits into
masterfrom
ease-of-use-improvements
Nov 17, 2022
Merged

Ease of use improvements#38
TomHogervorst merged 8 commits into
masterfrom
ease-of-use-improvements

Conversation

@TomHogervorst

Copy link
Copy Markdown
Contributor

Ease-of-use improvements based on user feedback.
PR also contains several fixes for bug encountered while implementing these improvements.

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.
@TomHogervorst TomHogervorst force-pushed the ease-of-use-improvements branch 3 times, most recently from 1157e50 to 6da200f Compare November 8, 2022 13:46
More explicitly set types of ndarray input values
Comment thread 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

Copy link
Copy Markdown

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

Comment thread 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

Copy link
Copy Markdown

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

Comment thread 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 "

Copy link
Copy Markdown

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?

Comment thread 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 "

Copy link
Copy Markdown

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?

Comment thread 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

Copy link
Copy Markdown

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

Comment thread 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

Copy link
Copy Markdown

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

Comment thread 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 \

Copy link
Copy Markdown

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?

@TomHogervorst TomHogervorst merged commit 4f6fa8d into master Nov 17, 2022
@TomHogervorst TomHogervorst deleted the ease-of-use-improvements branch November 17, 2022 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants