Skip to content

Commit 948d441

Browse files
Merge pull request #58 from jtniehof/test_updates
Unit test updates to run on my machine
2 parents 36f7b77 + 1557be3 commit 948d441

5 files changed

Lines changed: 18 additions & 12 deletions

File tree

scripts/convert_product_definition_to_yaml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def convert_csv_to_yaml(file_path):
3737
else:
3838
required_variables = required_for_data
3939

40-
if row[header_to_index["RECORD_VARYING"]].lower() == "nrv":
40+
if (("RECORD_VARYING" in required_variables or "RECORD_VARYING" in header_to_index)
41+
and row[header_to_index["RECORD_VARYING"]].lower() == "nrv"):
4142
required_variables = [variable for variable in required_variables if
4243
variable != "DEPEND_0"]
4344

tests/hit/l3/pha/science/test_range_fit_lookup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_loads_csv_into_array(self):
7676
charges, delta_e_loss = lookup_table.evaluate_e_prime(range, e_prime)
7777

7878
np.testing.assert_equal(charges, expected_charges)
79-
np.testing.assert_equal([double_power_law(e_prime, *charge1_parameters),
80-
double_power_law(e_prime, *charge2_parameters)], delta_e_loss)
79+
np.testing.assert_allclose([double_power_law(e_prime, *charge1_parameters),
80+
double_power_law(e_prime, *charge2_parameters)], delta_e_loss)
8181

8282
def test_load_from_real_example_files(self):
8383
range_fit_lookup = RangeFitLookup.from_files(

tests/maps/test_spectral_fit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def test_finds_best_fit_with_nan_in_flux(self):
174174

175175
scalar_coefficients, result, result_error = fit_arrays_to_power_law(flux, uncertainty, energies)
176176
np.testing.assert_array_equal(result, np.array(true_gamma).reshape(1, 1, *spacial_dimension_shape))
177-
np.testing.assert_array_equal(scalar_coefficients,
178-
np.array(true_A).reshape(1, 1, *spacial_dimension_shape))
177+
np.testing.assert_allclose(scalar_coefficients,
178+
np.array(true_A).reshape(1, 1, *spacial_dimension_shape))
179179

180180
def test_spectral_fit_map_negative_gammas(self):
181181
epoch = np.array([datetime.now()])
@@ -244,8 +244,8 @@ def test_finds_best_fit_with_nan_in_uncertainty(self):
244244

245245
scalar_coefficients, result, result_error = fit_arrays_to_power_law(flux, uncertainty, energies)
246246
np.testing.assert_array_equal(result, np.array(true_gamma).reshape(1, 1, *spacial_dimension_shape))
247-
np.testing.assert_array_equal(scalar_coefficients,
248-
np.array(true_A).reshape(1, 1, *spacial_dimension_shape))
247+
np.testing.assert_allclose(scalar_coefficients,
248+
np.array(true_A).reshape(1, 1, *spacial_dimension_shape))
249249

250250
def test_finds_best_fit_with_zero_in_flux_and_uncertainty(self):
251251
energies = np.geomspace(1, 10, 23)

tests/scripts/test_convert_product_definition_to_yaml.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def test_parse_required_for_data_with_multiple_depend(self):
2525
"FILLVAL": ["-1.00E+31", "", ""],
2626
"LABL_PTR_1": ["energy_label", "", ""],
2727
"LABL_PTR_2": ["pitch_angle_label", "", ""],
28-
"VARIABLE_PURPOSE": ["primary var, summary", "", ""]
28+
"VARIABLE_PURPOSE": ["primary var, summary", "", ""],
29+
"RECORD_VARYING": ["rv", "nrv", "nrv"]
2930
}
3031

3132
rows = [
@@ -58,6 +59,7 @@ def test_parse_required_for_data_with_multiple_depend(self):
5859
LABL_PTR_1: energy_label
5960
LABL_PTR_2: pitch_angle_label
6061
VARIABLE_PURPOSE: primary var, summary
62+
RECORD_VARYING: rv
6163
energy_label:
6264
NAME: energy_label
6365
DATA_TYPE: str
@@ -160,7 +162,8 @@ def test_parse_required_for_support_data_non_rv(self):
160162

161163
def test_parse_required_for_data_epoch(self):
162164
required_for_data = ["NAME", "DATA_TYPE", "CATDESC", "VAR_TYPE", "DEPEND_0", "DISPLAY_TYPE",
163-
"FIELDNAM", "FORMAT", "LABLAXIS", "UNITS", "VALIDMIN", "VALIDMAX", "FILLVAL"]
165+
"FIELDNAM", "FORMAT", "LABLAXIS", "UNITS", "VALIDMIN", "VALIDMAX", "FILLVAL",
166+
"RECORD_VARYING"]
164167

165168
test_csv_values = [
166169
"epoch",
@@ -175,7 +178,8 @@ def test_parse_required_for_data_epoch(self):
175178
"",
176179
"",
177180
"",
178-
"-1.00E+31"
181+
"-1.00E+31",
182+
"rv"
179183
]
180184
filePath = "csv_test_file.csv"
181185
with open(filePath, "w", newline='') as csvfile:
@@ -193,7 +197,8 @@ def test_parse_required_for_data_epoch(self):
193197
UNITS: ' '
194198
VALIDMIN: ' '
195199
VALIDMAX: ' '
196-
FILLVAL: -1.00E+31"""
200+
FILLVAL: -1.00E+31
201+
RECORD_VARYING: rv"""
197202
actual_yaml = convert_csv_to_yaml(filePath)
198203
self.assertEqual(expected_yaml, actual_yaml)
199204

tests/swapi/l3a/science/test_calculate_proton_solar_wind_temperature_and_density.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def test_throws_error_when_chi_squared_over_ten(self):
292292
coincident_count_rates, energy, 1)
293293

294294
self.assertAlmostEqual(77665.54856, proton_solar_wind_temp_and_density.temperature.nominal_value,
295-
4)
295+
3)
296296
self.assertAlmostEqual(3676.14173, proton_solar_wind_temp_and_density.temperature.std_dev, 3)
297297
self.assertAlmostEqual(0.03594, proton_solar_wind_temp_and_density.density.nominal_value,
298298
5)

0 commit comments

Comments
 (0)