Skip to content

Commit

Permalink
Fix test scripts to use random
Browse files Browse the repository at this point in the history
  • Loading branch information
tbhaxor committed May 9, 2024
1 parent de9bc00 commit 2dcad96
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tests/test_astro_palsma_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ def test_dimension():
# Import AstroPlasma Ionization module
from astro_plasma import Ionization
import numpy as np
import random

f_ion = Ionization.interpolate_ion_frac

hydrogen_num_density = np.power(10.0, np.random.uniform(low=-5.0, high=-2.0)) # Hydrogen number density in cm^-3
temperature = np.power(10.0, np.random.uniform(low=3.8, high=6.5)) # Temperature of the plasma in kelvin
metallicity = np.random.uniform(low=0.2, high=0.9) # Metallicity of plasma with respect to solar
redshift = np.random.uniform(low=0.1, high=1.2) # Cosmological redshift
hydrogen_num_density = np.power(10.0, random.uniform(-5.0, -2.0)) # Hydrogen number density in cm^-3
temperature = np.power(10.0, random.uniform(3.8, 6.5)) # Temperature of the plasma in kelvin
metallicity = random.uniform(0.2, 0.9) # Metallicity of plasma with respect to solar
redshift = random.uniform(0.1, 1.2) # Cosmological redshift
mode = "PIE"

element = np.random.randint(low=1, high=32)
ion = np.random.randint(low=1, high=element + 1)
element = random.randint(1, 31)
ion = random.randint(1, element + 1)

frac = f_ion(
nH=hydrogen_num_density,
Expand All @@ -77,10 +78,10 @@ def test_dimension():
) # This value is in log10
assert np.array(frac).ndim == 0

hydrogen_num_density = np.power(10.0, np.random.uniform(low=-5.0, high=-2.0)) # Hydrogen number density in cm^-3
hydrogen_num_density = np.power(10.0, random.uniform(-5.0, -2.0)) # Hydrogen number density in cm^-3
temperature = np.power(10.0, np.linspace(3.8, 6.5, 5)) # Temperature of the plasma in kelvin
metallicity = np.random.uniform(low=0.2, high=0.9) # Metallicity of plasma with respect to solar
redshift = np.random.uniform(low=0.1, high=1.2) # Cosmological redshift
metallicity = random.uniform(0.2, 0.9) # Metallicity of plasma with respect to solar
redshift = random.uniform(0.1, 1.2) # Cosmological redshift

frac = f_ion(
nH=hydrogen_num_density,
Expand All @@ -96,8 +97,8 @@ def test_dimension():
hydrogen_num_density = np.logspace(-5.0, -2.0, 2) # Hydrogen number density in cm^-3
temperature = np.logspace(3.8, 6.5, 5) # Temperature of the plasma in kelvin
hydrogen_num_density, temperature = np.meshgrid(hydrogen_num_density, temperature)
metallicity = np.random.uniform(low=0.2, high=0.9) # Metallicity of plasma with respect to solar
redshift = np.random.uniform(low=0.1, high=1.2) # Cosmological redshift
metallicity = random.uniform(0.2, 0.9) # Metallicity of plasma with respect to solar
redshift = random.uniform(0.1, 1.2) # Cosmological redshift

frac = f_ion(
nH=hydrogen_num_density,
Expand Down

0 comments on commit 2dcad96

Please sign in to comment.