jfkcooper / HOGBEN

Experimental design in neutron reflectometry using the Fisher information.
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Add unit tests for `fisher` function in `utils` #55

Closed sstendahl closed 1 year ago

sstendahl commented 1 year ago

Fixes issue #53

In this current PR the following unit tests are performed for the fisher function:

Also, the triple assignments in fisher function have been removed, and the associated docstring now indicates the list type for qs and counts (a list of list),

I refactored the general structure of the unit test quite a bit since this morning, moving the get_fisher_information outside of the testing Class, as to allow to test for different cases. Given it's a cheap calculation, it is probably still worth it to just calculate g in each test.

There's probably a few more tests that could be added as well, such as the importance scaling and the gradient calculations. But I figured those may be added in a separate PR:

sstendahl commented 1 year ago

With regard to the latest PR, there's some bigger changes:

sstendahl commented 1 year ago

The refl1d model fixture would need to be refactored a bit once the simulate class is refactored (as far as I can tell, that's the only part in test_fisher.py that actually depends on simulate), but I thought it would make most sense to do that once that refactor is actually in.

I could move the logic that it borrows from simulate to a helper function in test_fisher.py otherwise, but that would basically mean copying that current function to here, which would not be pretty and add several extra dependencies from the simulate class.