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

Hall kernel #1526

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Hall kernel #1526

wants to merge 3 commits into from

Conversation

jbarr444
Copy link

@jbarr444 jbarr444 commented Mar 8, 2025

Added a collision kernel which interpolates the table from Hall 1980.

@slayoo
Copy link
Member

slayoo commented Mar 9, 2025

@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).

@slayoo
Copy link
Member

slayoo commented Mar 12, 2025

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

@jbarr444
Copy link
Author

I’m getting

************* 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?

@slayoo
Copy link
Member

slayoo commented Mar 17, 2025

@jbarr444, big thanks for this PR! Please stay tuned for an update here

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.

None yet

2 participants