You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jbarr444, the key prerequisite for any PR is a unit test.
Here, we have the table from the paper that can serve as a source for expected values.
We use the pytest framework for unit testing, here's an example tutorial: https://betterstack.com/community/guides/testing/pytest-guide/
In short, we need a function (named test_... to be discoverable by pytest) that includes an arrange-act-assert logic, in which a minimal setup (the "arrange" part) to use the new code would be executed (the "act" part), and the results obtained by the newly introduced unit would be checked against dome reference values (the "assert" part).
Thank you @jbarr444
To make the test run on CI, we need to first address the code-quality issues raised by pylint:
************* Module PySDM.dynamics.collisions.collision_kernels.hall
PySDM/dynamics/collisions/collision_kernels/hall.py:1:0: C0114: Missing module docstring (missing-module-docstring)
PySDM/dynamics/collisions/collision_kernels/hall.py:388:17: E1133: Non-iterable value nb.prange(len(idx) - 1) is used in an iterating context (not-an-iterable)
PySDM/dynamics/collisions/collision_kernels/hall.py:4:0: C0411: third party import "import numba as nb" should be placed before "from PySDM.dynamics.collisions.collision_kernels.geometric import Geometric" (wrong-import-order)
************* Module tests.unit_tests.dynamics.collisions.test_table
tests/unit_tests/dynamics/collisions/test_table.py:1:0: C0114: Missing module docstring (missing-module-docstring)
tests/unit_tests/dynamics/collisions/test_table.py:1:0: E0401: Unable to import 'hall' (import-error)
Note that Numba is imported in the new hall.py file, but effectively it is not used there - without the numba.jit decorator, the call to prange is equivalent to plain range. See https://numba.readthedocs.io/en/stable/user/parallel.html
************* Module PySDM.dynamics.collisions.collision_kernels.hall
PySDM/dynamics/collisions/collision_kernels/hall.py:338:17: E1133: Non-iterable value nb.prange(len(idx) - 1) is used in an iterating context (not-an-iterable)
************* Module tests.unit_tests.dynamics.collisions.test_table
tests/unit_tests/dynamics/collisions/test_table.py:12:14: W1114: Positional arguments appear to be out of order (arguments-out-of-order)
Not sure about the first one. I am still not very familiar with numba, evidently. The second one is because I put them in the wrong order on purpose to show that it still passes. What should I do about that?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a collision kernel which interpolates the table from Hall 1980.