Provide some tests#25
Conversation
Codecov Report
@@ Coverage Diff @@
## main #25 +/- ##
===========================================
+ Coverage 44.03% 84.05% +40.01%
===========================================
Files 16 16
Lines 604 602 -2
===========================================
+ Hits 266 506 +240
+ Misses 338 96 -242
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Yes, I agree that benchmarks is what we really need. However I would start doing unit tests to understand better how the code works before starting to write benchmarks. |
Benchmark will be useful at some point, and I want to keep the split. Nevertheless, what we really need are unit tests: they are useful not only as a consistency check (like benchmarks), but also to lead development and refactoring (à la TDD, we have already seen them in action). As usual, LHAPDF will make a bit more cumbersome to install dependencies, but maybe I can try to properly repackage it, and update on PyPI (and we might avoid a further container this way). |
|
@alecandido @felixhekhorn I have some doubts about the function https://github.com/N3PDF/pineko/blob/20e6c5765afc43eafd05468101d54dc997631755/src/pineko/check.py#L6 |
As cited in the docstring, the function is taken from here: It is just a trick to retrieve the indices to compare to the elements, and e.g. in case I'm pretty confident it is going to work for a sorted array, but it might even work for an unsorted one... The only way to understand it is analyzing a few cases, i.e. testing it:
|
Yes, that is the point. I have tested it with a not realistic input and it failed. Now I am going to understand why, however, even if it is working with realistic inputs, maybe we don't want to keep a function that fails in some cases. |
Definitely we don't. So the correct behavior is keeping the tests, update the function :) |
|
In general, unit tests should test things in isolation. So, please, do your best in order to limit the amount of non-source files you are using in test. In particular: do your best to remove completely the The best pattern would be to make fixtures, that are generating required files at runtime, in temporary folders (if really needed). |
Yes, I would have liked to do everything at runtime. However I need at least one eko to test and it takes forever to compute it at runtime, even for small datasets |
felixhekhorn
left a comment
There was a problem hiding this comment.
since we're going for pytest, let's use it! i.e.
- move
utilsinconftestand makelhapdf_patha fixture (as we do ineko) - make
test_files+test_pdfa fixture - I also suggest a fixture
def grid_path(id)and similar - a minor style comment: let's move file names from suffix to prefix as we do for tests and as in eko
then let's merge!
This I'm not sure is really useful: they are a bunch of functions only used a few times each. However, I'm not strongly opinionated, do whatever you prefer, but don't spend too much time, it is already good enough. |
Co-authored-by: Alessandro Candido <candido.ale@gmail.com>
Actually I was thinking about the same thing. I believe that the lhapdf_path fixture is useful and the test_pdf and test_files ones are useful as well but a grid_path fixture I don't think it would be. So for me we can merge, do you agree? |
Almost, find and replace: |
Yes, I know :) |
|
Actually now docker is failing for some reason... |
Network/server issue, I believe. Let's retry with the new commit, otherwise again in a while. |
|
N3PDF/external is currently private: either we make it public, or we should move the containers somewhere else. Given that there is little to nothing in external (just the install scripts, and the Do you agree? @felixhekhorn @andreab1997 @giacomomagni |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
===========================================
+ Coverage 44.03% 84.05% +40.01%
===========================================
Files 16 16
Lines 604 602 -2
===========================================
+ Hits 266 506 +240
+ Misses 338 96 -242
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Now that the workflow is running correctly, can we merge this? @alecandido @felixhekhorn |
We want to provide some unit test for pineko