Skip to content

Commit

Permalink
Replace numba.vectorize with numpy.vectorize
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 21, 2023
1 parent c73d6cb commit 26c00d2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions qha/grid_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]


@vectorize([float64(float64, float64)], nopython=True)
@np.vectorize
def calculate_eulerian_strain(v0, vs):
"""
Calculate the Eulerian strain (:math:`f`s) of a given volume vector *vs* with respect to a reference volume *v0*,
Expand All @@ -43,7 +43,7 @@ def calculate_eulerian_strain(v0, vs):
return 1 / 2 * ((v0 / vs) ** (2 / 3) - 1)


@vectorize([float64(float64, float64)], nopython=True)
@np.vectorize
def from_eulerian_strain(v0, fs):
"""
Calculate the corresponding volumes :math:`V`s from a vector of given Eulerian strains (*fs*)
Expand Down
6 changes: 3 additions & 3 deletions qha/statmech.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}[qha.settings.energy_unit]


@vectorize([float64(float64, float64)], nopython=True, target="parallel", cache=True)
@np.vectorize
def ho_free_energy(temperature, frequency):
"""
Calculate Helmholtz free energy of a single harmonic oscillator at a specific temperature.
Expand All @@ -60,7 +60,7 @@ def ho_free_energy(temperature, frequency):
return 1 / 2 * hw + kt * np.log(1 - np.exp(-hw / kt))


@vectorize([float64(float64, float64)], nopython=True, target="parallel", cache=True)
@np.vectorize
def subsystem_partition_function(temperature, frequency):
"""
Calculate the subsystem partition function of a single harmonic oscillator at a specific temperature.
Expand All @@ -78,7 +78,7 @@ def subsystem_partition_function(temperature, frequency):
return np.exp(x / 2) / (1 - np.exp(x))


@vectorize([float64(float64, float64)], nopython=True, target="parallel", cache=True)
@np.vectorize
def log_subsystem_partition_function(temperature, frequency):
"""
Calculate the natural logarithm of the subsystem partition function of a single harmonic oscillator
Expand Down
4 changes: 2 additions & 2 deletions qha/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def lagrange4(xs: Vector, ys: Vector) -> Callable[[float], float]:
x0, x1, x2, x3 = xs
y0, y1, y2, y3 = ys

@vectorize(["float64(float64)"], target="parallel")
@np.vectorize
def f(x: float) -> float:
"""
A helper function that only does the evaluation.
Expand Down Expand Up @@ -92,7 +92,7 @@ def lagrange3(xs: Vector, ys: Vector) -> Callable[[float], float]:
x0, x1, x2 = xs
y0, y1, y2 = ys

@vectorize(["float64(float64)"], target="parallel")
@np.vectorize
def f(x: float) -> float:
"""
A helper function that only does the evaluation.
Expand Down
Loading

0 comments on commit 26c00d2

Please sign in to comment.