From 2dcad966122e834192badbd205b6be127dfb2d87 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Fri, 10 May 2024 03:30:29 +0530 Subject: [PATCH] Fix test scripts to use `random` --- tests/test_astro_palsma_basic.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test_astro_palsma_basic.py b/tests/test_astro_palsma_basic.py index b612ee0..6fb9c0f 100644 --- a/tests/test_astro_palsma_basic.py +++ b/tests/test_astro_palsma_basic.py @@ -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, @@ -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, @@ -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,