Skip to content
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

Add infrastructure and initial set of tests for ADQ component #215

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

philsmt
Copy link
Collaborator

@philsmt philsmt commented Aug 2, 2024

Adds the infrastructure (mock device and sources) to test ADQ digitizers and a basic set of tests for initialization and some auxiliary methods of the ADQ component.

I rather split this up, as the next methods will require significantly more complex tests.

@philsmt philsmt requested a review from takluyver August 2, 2024 14:57
@philsmt
Copy link
Collaborator Author

philsmt commented Aug 2, 2024

Also contains a couple of fixes that came up when writing the tests...

@philsmt philsmt added the skip-changelog Tell the CI that a changelog entry isn't necessary label Aug 2, 2024
Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.87%. Comparing base (77c311a) to head (87a9fb3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #215      +/-   ##
==========================================
+ Coverage   71.09%   75.87%   +4.77%     
==========================================
  Files          23       23              
  Lines        2726     2727       +1     
==========================================
+ Hits         1938     2069     +131     
+ Misses        788      658     -130     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 71 to 82
for i, ch_label in enumerate(self.channel_labels):
# Add a channel-dependent baseline shift and gaussian to
# each channel.
root_grp[f'channel_{ch_label}/raw/samples'][:] += -10 * (i+1) \
+ gaussian(x, 0, i*80, i*1000, 50).astype(np.int16)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to do this optionally for a selected single channel? We don't generally fill mock files with random data, and I imagine this is going to make the tests slower & more memory intensive, especially on systems using tmpfs (i.e. temporary files are created in RAM).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it shouldn't be a problem to limit actual data to a few select channels. But unlike with EXtra-data, I'd consider real data in the files essential to test what the components do - in particular if they contain transformations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

87a9fb3 limits data generation to channels selected in the fixture, and I reduced the trace length to 50000 (which should be enough for any realistic data-based tests). That should keep the memory cost negligible while the fixture is only generated once per session.

@@ -124,7 +124,7 @@ def __init__(self, data, channel, digitizer=None, pulses=None,
raise ValueError('channel expected to be 2 or 3 characters, '
'e.g. 1A or 1_A')

self._channel_number = ord(self._channel_letter) - ord('A')
self._channel_number = ord(self._channel_letter) - ord('A') + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we confident no-one is already using channel numbers as they are now, counting from zero?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the numbers and letters are enumated at initialization time by the AdqDigitizer device and cannot be configured. They're not even (always) in the physical order in the crate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, perhaps I'm misunderstanding. At the moment, if I create adq = AdqDigitizer(run, '1C'), then adq.number will give me 2 (A=0, B=1, C=2), yes? With this change, it becomes 3. Are you confident that no-one has started using those numbers as they are?

(We can still change it even if someone might be using it - I just want to think about if we need to announce the change somehow)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I understand now. So the earlier behaviour was a bug, adq.number was always meant to represent the board number in the sense it was used in CONTROL parameters (yes, someone funny used letters for fast data and numbers for slow data). As a matter of fact, .channel_parameters would've given you the wrong values as of now.

I highly doubt this parameter was used already directly, but if you feel strongly about it I can add it as a bugfix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks. Let's mention it in the changelog, though since we install master every day it doesn't make much difference.

@takluyver
Copy link
Member

Other than the question about announcing the numbering change, this LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Tell the CI that a changelog entry isn't necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants