Skip to content

Conversation

@andLaing
Copy link
Collaborator

EArray for the sensors can now be saved
in h5file.root as is done in the C++
detsim.

Tidied and added type hints, docstrings
and a test for the writer.

@andLaing andLaing requested a review from gonzaponte December 12, 2019 11:20
@andLaing andLaing force-pushed the read-new-detsim branch 2 times, most recently from 0005a01 to f4581e7 Compare January 16, 2020 12:18
Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

I can't believe we didn't have rwf_io_test.py!

Comment on lines +13 to +15
compression : str = 'ZLIB4',
n_sensors : int ,
waveform_length : int ) -> Callable:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will not work, arguments with default values (optional) cannot be followed by arguments without default values (mandatory)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Curiously, that's not something that I changed but now that you mention it it shouldn't work. Must just be that we've always set everything explicitly or something. I'll change it to default to the NEW numbers

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right, it was already like that. I've only noticed it because you changed something else 😆
If you want, leave it as is and we open a new PR fixing it everywhere. I don't think it should take any particular number.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll leave it for now

rwf_writer_(sens)

with tb.open_file(ofile) as h5test:
if group_name is 'root':
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not correct to compare strings with is. is checks whether two objects have the same ID, i.e. if they refer to the same memory space. Curiously this works, interactively, but it is not guaranteed to work in general.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Curiously this works, interactively

Yes, it depends on whether the string is interned or not ... and that depends on complex implementation-defined details (which are probably not guaranteed not to evolve with time). So, to a first order approximation:

  1. Do not use is to compare strings ...

  2. ... unless

    • you have benchmarked to prove that your code is too slow
    • you have profiled to prove that some string comparison is taking a significant portion of your CPU cycles

    If you ever find yourself in that situation (rather unlikely) then interning relevant strings and using is might speed it up.

TL;DR: do not use is to compare strigns.

Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

Nice extension to the rwf writer. Now it allows writing to the root group. It also adds a good test that covers both the new and the original cases, which were somehow untested.
Good job!

EArray for the sensors can now be saved
in h5file.root as is done in the C++
detsim.

Tidied and added type hints, docstrings
and a test for the writer.
Changed the try except structure to instead
check if the group already exists.

Changed 'root' for None in root group definition.

Some minor cosmetics.
test_rwf_writer changedto remove potentially
unstable 'is' comparison of strings.

Outputs now compared with np.all(arr1 == arr2)
carmenromo added a commit that referenced this pull request Feb 1, 2020
#685

[author: andLaing]

EArray for the sensors can now be saved in h5file.root as is done in
the C++ detsim.

Tidied and added type hints, docstrings and a test for the writer.

[reviewer: gonzaponte]

Nice extension to the rwf writer. Now it allows writing to the root
group. It also adds a good test that covers both the new and the
original cases, which were somehow untested.
Good job!
@carmenromo carmenromo merged commit a06e743 into next-exp:master Feb 1, 2020
@andLaing andLaing deleted the read-new-detsim branch April 10, 2020 15:03
andLaing pushed a commit to andLaing/IC that referenced this pull request May 13, 2020
next-exp#685

[author: andLaing]

EArray for the sensors can now be saved in h5file.root as is done in
the C++ detsim.

Tidied and added type hints, docstrings and a test for the writer.

[reviewer: gonzaponte]

Nice extension to the rwf writer. Now it allows writing to the root
group. It also adds a good test that covers both the new and the
original cases, which were somehow untested.
Good job!
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.

4 participants