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

Remove Numba as a dependency #2841

Merged
merged 8 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Continue removing Numba
  • Loading branch information
namurphy committed Aug 28, 2024
commit 7fe2a10656e0e015d9438bbddd64cd6042b7fda5
6 changes: 3 additions & 3 deletions docs/changelog/0.8.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Deprecations and Removals
<https://github.com/plasmapy/plasmapy/pull/1465>`__)
- The ``[all]`` option when using |pip| to install `plasmapy` is now
deprecated and may be removed in a future release. Packages that
were previously optional (|h5py|, |lmfit|, |mpmath|, and |Numba|)
were previously optional (|h5py|, |lmfit|, |mpmath|, and Numba)
are now installed by default when running ``pip install
plasmapy``. To install all packages required for code development of
PlasmaPy, instead run ``pip install plasmapy[developer]``. (`#1482
Expand Down Expand Up @@ -137,7 +137,7 @@ Features
<https://github.com/plasmapy/plasmapy/pull/1145>`__)
- Introduced the concept of :term:`lite-functions`, by creating the
lite-function ``plasmapy.formulary.parameters.thermal_speed_lite``,
which is a simplified and |Numba| jitted version of
which is a simplified and Numba jitted version of
``plasmapy.formulary.parameters.thermal_speed``. These functions
are intended for computational use and as such have no validation of
input or output values.
Expand Down Expand Up @@ -603,7 +603,7 @@ Trivial/Internal Changes
``1.19.0``, `pandas` to ``1.0.0``, `pytest` to ``5.4.0``, `scipy` to
``1.5.0``, and |xarray| to ``0.15.0``. (`#1482
<https://github.com/plasmapy/plasmapy/pull/1482>`__)
- Moved |h5py|, |lmfit|, |mpmath|, and |Numba| out of the
- Moved |h5py|, |lmfit|, |mpmath|, and Numba out of the
``extras`` requirements category and into the ``install``
requirements category. These packages are now installed when
running ``pip install plasmapy``. (`#1482
Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
(python_role, "lmfit"),
(python_role, "mpmath"),
(python_role, "nbsphinx"),
(python_role, "numba"),
(python_role, "xarray"),
# plasmapy_sphinx
(python_role, "automod.*"),
Expand Down Expand Up @@ -253,7 +252,6 @@
"astropy": ("https://docs.astropy.org/en/stable/", None),
"lmfit": ("https://lmfit.github.io/lmfit-py/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"numba": ("https://numba.readthedocs.io/en/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"pytest": ("https://docs.pytest.org/en/stable/", None),
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/coding_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ Dependencies and requirements
become compatible with the latest versions of its dependencies than
to set a maximum requirement.

* It sometimes takes a few months for packages like |Numba| to become
* It sometimes takes a few months for packages like Numba to become
compatible with the newest minor version of |Python|.

* The ``tests`` and ``docs`` dependency sets are required for running
Expand Down
7 changes: 3 additions & 4 deletions docs/performance_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ functions for situations when performance matters. For example,
lite-function for `~plasmapy.formulary.frequencies.plasma_frequency`.

Lite-functions accept and return NumPy arrays (assumed to be in SI
units) instead of |Quantity| objects. Lite-functions make use of
just-in-time (JIT) compilation via |Numba| to achieve high performance.
Because lite-functions do not include any validation of inputs, they
should only be used for performance-critical applications.
units) instead of |Quantity| objects. Lite-functions have improved
performance because they do not perform any checks on the inputs, and
thus should be used cautiously.

If you need a lite-function version of a `plasmapy.formulary` function
that has not already been implemented, please `raise an issue`_.
Expand Down
2 changes: 0 additions & 2 deletions src/plasmapy/formulary/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import astropy.units as u
import numpy as np
from astropy.constants.si import e, eps0
from numba import njit

from plasmapy import particles
from plasmapy.particles.decorators import particle_input
Expand Down Expand Up @@ -156,7 +155,6 @@ def gyrofrequency(


@preserve_signature
@njit
def plasma_frequency_lite(
n: float,
mass: float,
Expand Down
2 changes: 0 additions & 2 deletions src/plasmapy/formulary/speeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import astropy.units as u
import numpy as np
from astropy.constants.si import k_B, mu0
from numba import njit

from plasmapy.formulary import lengths
from plasmapy.particles import electron
Expand Down Expand Up @@ -475,7 +474,6 @@ def thermal_speed_coefficients(method: str, ndim: int) -> float:


@preserve_signature
@njit
def thermal_speed_lite(T: float, mass: float, coeff: float) -> float:
r"""
The :term:`lite-function` for
Expand Down
5 changes: 0 additions & 5 deletions tests/formulary/test_plasma_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import numpy as np
import pytest
from astropy.constants.si import m_p
from numba.extending import is_jitted

from plasmapy.formulary.frequencies import plasma_frequency, plasma_frequency_lite, wp_
from plasmapy.particles._factory import _physical_particle_factory
Expand Down Expand Up @@ -149,10 +148,6 @@ def test_can_handle_numpy_arrays(self) -> None:
class TestPlasmaFrequencyLite:
"""Test class for `plasma_frequency_lite`."""

def test_is_jitted(self) -> None:
"""Ensure `plasmapy_frequency_lite` was jitted by `numba`."""
assert is_jitted(plasma_frequency_lite)

@pytest.mark.parametrize(
"inputs",
[
Expand Down
5 changes: 0 additions & 5 deletions tests/formulary/test_thermal_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import numpy as np
import pytest
from astropy.constants.si import k_B
from numba.extending import is_jitted

from plasmapy.formulary.speeds import (
kappa_thermal_speed,
Expand Down Expand Up @@ -293,10 +292,6 @@ def test_can_handle_numpy_arrays(self) -> None:
class TestThermalSpeedLite:
"""Test class for `thermal_speed_lite`."""

def test_is_jitted(self) -> None:
"""Ensure `thermal_speed_lite` was jitted by `numba`."""
assert is_jitted(thermal_speed_lite)

@pytest.mark.parametrize(
"inputs",
[
Expand Down
8 changes: 5 additions & 3 deletions tests/utils/decorators/test_lite_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import pytest
from numba import jit, njit

from plasmapy.utils.decorators.lite_func import bind_lite_func

Expand Down Expand Up @@ -47,12 +46,15 @@ def test_raises(lite_func, attrs, _error) -> None:
bind_lite_func(lite_func, attrs=attrs)(foo)


# If we add back Numba as a dependency, we will need to add back two
# lines in this parametrization that tested lite functions with Numba
# decorators. See git history.


@pytest.mark.parametrize(
("lite_func", "attrs"),
[
(foo_lite, None),
(jit(foo_lite, nopython=True), None),
(njit(foo_lite), None),
(foo_lite, {"bar": bar}),
],
)
Expand Down