Skip to content

Commit

Permalink
Merge pull request #97 from singularitti/numba
Browse files Browse the repository at this point in the history
Remove `numba` in code
  • Loading branch information
singularitti authored Oct 21, 2023
2 parents ba9d292 + 3240118 commit 6f96cbb
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 56 deletions.
1 change: 0 additions & 1 deletion qha/grid_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import Optional, Tuple

import numpy as np
from numba import vectorize, float64

from qha.fitting import polynomial_least_square_fitting, apply_finite_strain_fitting
from qha.type_aliases import Vector, Matrix
Expand Down
2 changes: 0 additions & 2 deletions qha/single_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import numpy as np
from lazy_property import LazyProperty
from numba import jit, float64, boolean

from qha.statmech import ho_free_energy
from qha.type_aliases import Scalar, Vector, Matrix, Array3D
Expand All @@ -17,7 +16,6 @@
__all__ = ["free_energy", "HOFreeEnergySampler"]


@jit(float64[:](float64, float64[:], float64[:], float64[:, :, :], boolean), cache=True)
def free_energy(
temperature: Scalar,
q_weights: Vector,
Expand Down
1 change: 0 additions & 1 deletion qha/statmech.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import numpy as np
from numba import float64, vectorize
from scipy.constants import physical_constants as pc

import qha.settings
Expand Down
3 changes: 0 additions & 3 deletions qha/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Callable, Optional

import numpy as np
from numba import float64, guvectorize, int64, jit, vectorize

from qha.fitting import polynomial_least_square_fitting
from qha.grid_interpolation import calculate_eulerian_strain
Expand Down Expand Up @@ -109,7 +108,6 @@ def f(x: float) -> float:
return f


@jit(nopython=True, nogil=True, cache=True)
def find_nearest(array: Vector, value: Scalar) -> int:
"""
Given an *array* , and given a *value* , returns an index ``j`` such that *value* is between ``array[j]``
Expand Down Expand Up @@ -152,7 +150,6 @@ def find_nearest(array: Vector, value: Scalar) -> int:
return j_low


@guvectorize([(float64[:], float64[:], int64[:])], "(m),(n)->(n)")
def vectorized_find_nearest(array: Vector, values: Vector, result: Vector):
"""
A vectorized version of function ``find_nearest``.
Expand Down
11 changes: 6 additions & 5 deletions qha/type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
.. moduleauthor:: Qi Zhang <[email protected]>
"""

from numba import float64
from numpy import float64
from numpy.typing import NDArray

# ===================== What can be exported? =====================
__all__ = ["Scalar", "Vector", "Matrix", "Array3D", "Array4D"]

Scalar = float64 # 0-dimensional float
Vector = float64[:] # 1-dimensional floats
Matrix = float64[:, :] # 2-dimensional floats
Array3D = float64[:, :, :] # 3-dimensional floats
Array4D = float64[:, :, :, :] # 4-dimensional floats
Vector = NDArray[float64] # 1-dimensional floats
Matrix = NDArray[float64] # 2-dimensional floats
Array3D = NDArray[float64] # 3-dimensional floats
Array4D = NDArray[float64] # 4-dimensional floats
Loading

0 comments on commit 6f96cbb

Please sign in to comment.