Skip to content

Commit

Permalink
Remove pytest warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
KasukabeDefenceForce committed Oct 4, 2024
1 parent a15c0c4 commit 71e7f0a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 3 additions & 1 deletion tardis/energy_input/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def doppler_factor_3d(direction_vector, position_vector, time):
Doppler factor
"""
velocity_vector = position_vector / time
return 1 - (np.dot(direction_vector, velocity_vector) / C_CGS)
direction_vector_contiguous = np.ascontiguousarray(direction_vector)
velocity_vector_contiguous = np.ascontiguousarray(velocity_vector)
return 1 - (np.dot(direction_vector_contiguous, velocity_vector_contiguous) / C_CGS)


@njit(**njit_dict_no_parallel)
Expand Down
15 changes: 4 additions & 11 deletions tardis/io/model/parse_radiation_field_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,8 @@ def calculate_geometric_dilution_factor(geometry):
np.array
The dilution factors for the inout geometry
"""
return 0.5 * (
1
- np.sqrt(
1
- (
geometry.r_inner[geometry.v_inner_boundary_index] ** 2
/ geometry.r_middle**2
)
.to(1)
.value
)
value = (
1 - (geometry.r_inner[geometry.v_inner_boundary_index] ** 2 / geometry.r_middle**2).to(1).value
)
value = np.clip(value, 0, None)
return 0.5 * (1 - np.sqrt(value))
1 change: 1 addition & 0 deletions tardis/io/tests/test_atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_atom_data_levels(levels):


def test_atom_data_lines(lines):
lines = lines.sort_index()
assert_quantity_allclose(
lines.loc[(2, 0, 0, 6), "wavelength_cm"].values[0] * u.Unit("cm"),
584.335 * u.Unit("Angstrom"),
Expand Down
2 changes: 1 addition & 1 deletion tardis/model/matter/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(

def assemble_isotope_masses(self):
isotope_mass_df = pd.Series(
index=self.isotopic_mass_fraction.index, data=-1
index=self.isotopic_mass_fraction.index, data=-1,dtype="float64"
)
for isotope_tuple in self.isotopic_mass_fraction.index:
isotope_symbol = int("{:03d}{:03d}0000".format(*isotope_tuple))
Expand Down
6 changes: 5 additions & 1 deletion tardis/plasma/properties/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,11 @@ def exp1_times_exp(x):
array_like
Output array.
"""
f = exp1(x) * np.exp(x)
x = np.asarray(x)
f = np.empty_like(x)
small_x = x <= 500
f[small_x] = exp1(x[small_x]) * np.exp(x[small_x])

# Use Laurent series for large values to avoid infinite exponential
mask = x > 500
f[mask] = (x**-1 - x**-2 + 2 * x**-3 - 6 * x**-4)[mask]
Expand Down
6 changes: 3 additions & 3 deletions tardis/plasma/properties/nlte_rate_equation_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def calculate_first_guess(
"""
first_guess = pd.Series(0.0, index=rate_matrix_index)
for atomic_number in atomic_numbers:
first_guess.loc[(atomic_number, 1)].iloc[0] = number_density.loc[
first_guess.at[(atomic_number, 1)] = number_density.loc[
atomic_number
]
# TODO: After the first iteration, the new guess can be the old solution.
Expand Down Expand Up @@ -937,7 +937,7 @@ def ion_matrix(ion_coefficients, atomic_number, ion_number):
offdiag = np.zeros(atomic_number)
index = ion_coefficients.index
for i in index:
offdiag[i] = ion_coefficients.loc[i]
offdiag[i] = float(ion_coefficients.loc[i].iloc[0])
diag = np.hstack([-offdiag, np.zeros(1)])
return (np.diag(diag) + np.diag(offdiag, k=-1))[ion_number, :]

Expand All @@ -961,7 +961,7 @@ def recomb_matrix(recomb_coefficients, atomic_number, ion_number):
offdiag = np.zeros(atomic_number)
index = recomb_coefficients.index
for i in index:
offdiag[i] = recomb_coefficients.loc[i]
offdiag[i] = float(recomb_coefficients.loc[i].values[0])
diag = np.hstack([np.zeros(1), -offdiag])
return (np.diag(diag) + np.diag(offdiag, k=1))[ion_number, :]

Expand Down

0 comments on commit 71e7f0a

Please sign in to comment.