-
Notifications
You must be signed in to change notification settings - Fork 3
Reverse Indices for Digital Waveform Signals #222
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
Reverse Indices for Digital Waveform Signals #222
Conversation
Test Results 56 files ± 0 56 suites ±0 25m 31s ⏱️ +16s Results for commit 7adf82c. ± Comparison against base commit 9713651. This pull request removes 4 and adds 24 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…78052-reverse-signal-index
…eturns_new_line_name and _DigitalWaveformExtendedProperties
…78052-reverse-signal-index
bkeryan
left a comment
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.
Approved with suggestion (add test case for pickle of _on_key_changed)
…ictionaries can be shared by waveforms
* add _raw_index * line_index and line_names * more tests * fix new test * data_index and documentation * fix doc types * documentation improvements * documentation improvements * documentation improvements * clean up NI_LineNames in tests * remove DigitalWaveformFailure.data_index * test___signal_with_line_names___change_line_names_property___signal_returns_new_line_name and _DigitalWaveformExtendedProperties * signal_column_index * line lengths * italics for 'See "Signal index vs. signal column index"' notes * add bitorder to from_port, and default to the industry standard 'big' * rename to column_index * bitorder != sys.byteorder * add on_key_changed to ExtendedPropertyDictionary * change tests to big-endian * make on_key_changed private * cleanup * from typing_extensions import TypeAlias, to fix python 3.9 * fix pickling and copying issues with callbacks * change on_key_changed to a list of weak methods, so ExtendedPropertyDictionaries can be shared by waveforms --------- Co-authored-by: Mike Prosser <[email protected]>
…als (#222) (#233) * Reverse Indices for Digital Waveform Signals (#222) * add _raw_index * line_index and line_names * more tests * fix new test * data_index and documentation * fix doc types * documentation improvements * documentation improvements * documentation improvements * clean up NI_LineNames in tests * remove DigitalWaveformFailure.data_index * test___signal_with_line_names___change_line_names_property___signal_returns_new_line_name and _DigitalWaveformExtendedProperties * signal_column_index * line lengths * italics for 'See "Signal index vs. signal column index"' notes * add bitorder to from_port, and default to the industry standard 'big' * rename to column_index * bitorder != sys.byteorder * add on_key_changed to ExtendedPropertyDictionary * change tests to big-endian * make on_key_changed private * cleanup * from typing_extensions import TypeAlias, to fix python 3.9 * fix pickling and copying issues with callbacks * change on_key_changed to a list of weak methods, so ExtendedPropertyDictionaries can be shared by waveforms --------- Co-authored-by: Mike Prosser <[email protected]> * Fix unpickling issues with Waveform and Signal (#237) * add versioned unpickling tests for waveform and signal, and fix issues causing the new tests to fail * skip unpickle tests in oldest_deps test run --------- Co-authored-by: Mike Prosser <[email protected]> --------- Co-authored-by: Mike Prosser <[email protected]>
What does this Pull Request accomplish?
In NI Digital Waveforms, the signals are typically ordered with the least significant bit last, and that least significant line is line0. That means, for example, if you read digital data from a 32 bit port, the line numbers (aka signal numbers) count down from 31 to 0. Here's what that looks like in LabVIEW. (Note, this is simulated hardware where the samples count up from zero)
In our .NET Digital Waveforms, we match this 'reversed' signal ordering using logic like this (from line 152 in DigitalData.cs)
We should do the same thing in our Python Digital Waveforms.
To accomplish this, I've added a
signal.column_indexproperty alongside thesignal.signal_indexproperty. Thesignal_indexrepresents the line number, and counts down, while thecolumn_indexrepresents the position in the underlyingsignals.dataarray, and counts up. These two indices are reversed with respect to each other:I have updated
_signal.py,_signal_collection.py, and_waveform.pyto set and use the correct index when accessing things likesignal.dataandsignal.name. (Note that the strings in NI_LineNames match the ordering of column_index, and are reversed with respect to signal_index)I have also updated documentation to explain the difference between the two indices.
Here's a summary of all of the changes:
signal.column_indexsignal.data,signal.name, andsignal.__reduce__()to usecolumn_indexsignal_collection.__getitem__()to set and usecolumn_indexDigitalWaveformFaiulre.column_indexDigitalWaveformclasswaveform._signal_namestowaveform._line_nameswaveform._get_signal_name()andset_signal_name()toget_line_name()andset_line_name()waveform.test()to include thecolumn_indexin theDigitalWaveformFalurereportWhy should this Pull Request be merged?
AB#3178052
What testing has been done?
Added/Updated auto tests:
Signal name caching issue
While updating tests in nidaqmx-python, I noticed that the
signal.namevalue (which is cached) wasn't being cleared/updated whenwaveform.extended_properties["NI_LineNames"]is updated.I added a test
test___signal_with_line_names___change_line_names_property___signal_returns_new_line_nameto demonstrate the issue here in nitypes-python.I fixed the issue by adding a
_DigitalWaveformExtendedPropertiesclass, which just clearsself._waveform._line_nameswhen["NI_LineNames"]is changed.