From 8dfeb05a802cab761b9cd731b539ad683162f87b Mon Sep 17 00:00:00 2001 From: M Laraib Ali Date: Tue, 8 Apr 2025 00:34:17 +0500 Subject: [PATCH 1/5] move testing files to `test/test_data` --- lasso/dimred/test_dimred_run.py | 26 +++++++-------- lasso/dyna/test_d3plot.py | 30 +++++++++--------- lasso/dyna/test_d3plot_header.py | 8 ++--- lasso/io/test_binary_buffer.py | 12 +++---- lasso/io/test_files.py | 8 ++--- .../DimredRunTest/verificationFile.hdf5 | Bin test/{ => test_data}/d3plot_beamip/d3plot | Bin test/{ => test_data}/d3plot_beamip/d3plot01 | Bin .../d3plot_node_temperature/d3plot | Bin .../d3plot_node_temperature/d3plot01 | Bin test/{ => test_data}/d3plot_solid_int/d3plot | Bin .../{ => test_data}/d3plot_solid_int/d3plot01 | Bin .../{ => test_data}/d3plot_solid_int/d3plot02 | Bin .../{ => test_data}/d3plot_solid_int/d3plot03 | Bin .../{ => test_data}/d3plot_solid_int/d3plot04 | Bin .../{ => test_data}/d3plot_solid_int/d3plot05 | Bin .../{ => test_data}/d3plot_solid_int/d3plot06 | Bin .../{ => test_data}/d3plot_solid_int/d3plot07 | Bin .../{ => test_data}/d3plot_solid_int/d3plot08 | Bin .../{ => test_data}/d3plot_solid_int/d3plot09 | Bin .../{ => test_data}/d3plot_solid_int/d3plot10 | Bin .../{ => test_data}/d3plot_solid_int/d3plot11 | Bin .../{ => test_data}/d3plot_solid_int/d3plot12 | Bin .../{ => test_data}/d3plot_solid_int/d3plot13 | Bin .../{ => test_data}/d3plot_solid_int/d3plot14 | Bin .../{ => test_data}/d3plot_solid_int/d3plot15 | Bin .../{ => test_data}/d3plot_solid_int/d3plot16 | Bin .../{ => test_data}/d3plot_solid_int/d3plot17 | Bin .../{ => test_data}/d3plot_solid_int/d3plot18 | Bin .../{ => test_data}/d3plot_solid_int/d3plot19 | Bin .../{ => test_data}/d3plot_solid_int/d3plot20 | Bin .../{ => test_data}/d3plot_solid_int/d3plot21 | Bin .../{ => test_data}/d3plot_solid_int/d3plot22 | Bin test/{ => test_data}/femzip/d3plot | Bin test/{ => test_data}/femzip/d3plot.fz | Bin test/{ => test_data}/femzip/d3plot01 | Bin test/{ => test_data}/io_test/file1.txt | 0 .../io_test/subfolder/file2.txt | 0 .../io_test/subfolder/file3.yay | 0 test/{ => test_data}/order_d3plot/d3plot | Bin test/{ => test_data}/order_d3plot/d3plot01 | Bin test/{ => test_data}/order_d3plot/d3plot02 | Bin test/{ => test_data}/order_d3plot/d3plot10 | Bin test/{ => test_data}/order_d3plot/d3plot100 | Bin test/{ => test_data}/order_d3plot/d3plot11 | Bin test/{ => test_data}/order_d3plot/d3plot12 | Bin test/{ => test_data}/order_d3plot/d3plot22 | Bin test/{ => test_data}/simple_d3plot/d3plot | Bin test/{ => test_data}/simple_d3plot/d3plot01 | Bin 49 files changed, 42 insertions(+), 42 deletions(-) rename test/{ => test_data}/DimredRunTest/verificationFile.hdf5 (100%) rename test/{ => test_data}/d3plot_beamip/d3plot (100%) rename test/{ => test_data}/d3plot_beamip/d3plot01 (100%) rename test/{ => test_data}/d3plot_node_temperature/d3plot (100%) rename test/{ => test_data}/d3plot_node_temperature/d3plot01 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot01 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot02 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot03 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot04 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot05 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot06 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot07 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot08 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot09 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot10 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot11 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot12 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot13 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot14 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot15 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot16 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot17 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot18 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot19 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot20 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot21 (100%) rename test/{ => test_data}/d3plot_solid_int/d3plot22 (100%) rename test/{ => test_data}/femzip/d3plot (100%) rename test/{ => test_data}/femzip/d3plot.fz (100%) rename test/{ => test_data}/femzip/d3plot01 (100%) rename test/{ => test_data}/io_test/file1.txt (100%) rename test/{ => test_data}/io_test/subfolder/file2.txt (100%) rename test/{ => test_data}/io_test/subfolder/file3.yay (100%) rename test/{ => test_data}/order_d3plot/d3plot (100%) rename test/{ => test_data}/order_d3plot/d3plot01 (100%) rename test/{ => test_data}/order_d3plot/d3plot02 (100%) rename test/{ => test_data}/order_d3plot/d3plot10 (100%) rename test/{ => test_data}/order_d3plot/d3plot100 (100%) rename test/{ => test_data}/order_d3plot/d3plot11 (100%) rename test/{ => test_data}/order_d3plot/d3plot12 (100%) rename test/{ => test_data}/order_d3plot/d3plot22 (100%) rename test/{ => test_data}/simple_d3plot/d3plot (100%) rename test/{ => test_data}/simple_d3plot/d3plot01 (100%) diff --git a/lasso/dimred/test_dimred_run.py b/lasso/dimred/test_dimred_run.py index adba6fb..c604d80 100644 --- a/lasso/dimred/test_dimred_run.py +++ b/lasso/dimred/test_dimred_run.py @@ -12,7 +12,7 @@ class TestDimredRun(TestCase): def test_run(self): """Verifies correct function of DimredRun.py""" - verification_hdf5_file = h5py.File("test/DimredRunTest/verificationFile.hdf5", "r") + verification_hdf5_file = h5py.File("test/test_data/DimredRunTest/verificationFile.hdf5", "r") with tempfile.TemporaryDirectory() as tmpdir: @@ -33,7 +33,7 @@ def test_run(self): start_stage=DIMRED_STAGES[0], end_stage="CLUSTERING", console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, cluster_args=["kmeans"], ) @@ -138,7 +138,7 @@ def test_run(self): simulation_runs=os.path.join(tmpdir, "SVDTestPlot*/plot"), start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[0], - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", console=None, ) @@ -161,7 +161,7 @@ def test_for_errors(self): start_stage="INVALID_START", end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) @@ -174,7 +174,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage="INVALID_END", console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) @@ -187,7 +187,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[-1], end_stage=DIMRED_STAGES[0], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) @@ -199,7 +199,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) @@ -211,7 +211,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, cluster_args=["noMeans"], ) @@ -224,7 +224,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, cluster_args=["kmeans"], outlier_args=["DoesNotExist"], @@ -239,7 +239,7 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) # check for empty simulation runs @@ -250,13 +250,13 @@ def test_for_errors(self): start_stage=DIMRED_STAGES[0], end_stage=DIMRED_STAGES[-1], console=None, - project_dir="test/DimredRunTest", + project_dir="test/test_data/DimredRunTest", n_processes=5, ) def tearDown(self): # cleanup of created files - test_files = os.listdir("test/DimredRunTest") + test_files = os.listdir("test/test_data/DimredRunTest") test_files.pop(test_files.index("verificationFile.hdf5")) for entry in test_files: - os.remove(os.path.join("test/DimredRunTest", entry)) + os.remove(os.path.join("test/test_data/DimredRunTest", entry)) diff --git a/lasso/dyna/test_d3plot.py b/lasso/dyna/test_d3plot.py index 73de673..4ba00f9 100644 --- a/lasso/dyna/test_d3plot.py +++ b/lasso/dyna/test_d3plot.py @@ -17,7 +17,7 @@ def test_init(self): # settings self.maxDiff = None - filepath = "test/simple_d3plot/d3plot" + filepath = "test/test_data/simple_d3plot/d3plot" geometry_array_shapes = { "node_coordinates": (4915, 3), @@ -152,7 +152,7 @@ def test_header(self): "neipb": 0, } - d3plot = D3plot("test/simple_d3plot/d3plot") + d3plot = D3plot("test/test_data/simple_d3plot/d3plot") header = d3plot.header for name, value in test_header_data.items(): @@ -162,7 +162,7 @@ def test_beam_integration_points(self): self.maxDiff = None - filepath = "test/d3plot_beamip/d3plot" + filepath = "test/test_data/d3plot_beamip/d3plot" maxmin_test_values = { # "element_beam_shear_stress": (-0.007316963, 0.), "element_beam_shear_stress": (0.0, 0.0056635854), @@ -188,7 +188,7 @@ def test_beam_integration_points(self): def test_correct_sort_of_more_than_100_state_files(self): - filepath = "test/order_d3plot/d3plot" + filepath = "test/test_data/order_d3plot/d3plot" d3plot = D3plot(filepath) @@ -199,8 +199,8 @@ def test_femzip_basic(self): self.maxDiff = None - filepath1 = "test/femzip/d3plot.fz" - filepath2 = "test/femzip/d3plot" + filepath1 = "test/test_data/femzip/d3plot.fz" + filepath2 = "test/test_data/femzip/d3plot" d3plot_kwargs_list = [{}, {"buffered_reading": True}, {"state_filter": [0]}] @@ -220,8 +220,8 @@ def test_femzip_extended(self): self.maxDiff = None - filepath1 = "test/femzip/d3plot.fz" - filepath2 = "test/femzip/d3plot" + filepath1 = "test/test_data/femzip/d3plot.fz" + filepath2 = "test/test_data/femzip/d3plot" d3plot_kwargs_list = [{}, {"buffered_reading": True}, {"state_filter": [0]}] @@ -245,7 +245,7 @@ def test_part_filter(self): self.maxDiff = None - filepath = "test/simple_d3plot/d3plot" + filepath = "test/test_data/simple_d3plot/d3plot" part_ids = [1] d3plot = D3plot(filepath) @@ -260,7 +260,7 @@ def test_part_filter(self): def test_read_solid_integration_points(self): - filepath = "test/d3plot_solid_int/d3plot" + filepath = "test/test_data/d3plot_solid_int/d3plot" # data from META stress_valid = np.array( @@ -345,10 +345,10 @@ def test_write(self): self.maxDiff = None filepaths = [ - "test/simple_d3plot/d3plot", - "test/d3plot_beamip/d3plot", - "test/d3plot_node_temperature/d3plot", - "test/d3plot_solid_int/d3plot", + "test/test_data/simple_d3plot/d3plot", + "test/test_data/d3plot_beamip/d3plot", + "test/test_data/d3plot_node_temperature/d3plot", + "test/test_data/d3plot_solid_int/d3plot", ] d3plot_kwargs_list = [ @@ -457,7 +457,7 @@ def test_append_4_shell_hists_then_read_bug(self): def test_reading_selected_states(self): # read all states - filepath = "test/d3plot_solid_int/d3plot" + filepath = "test/test_data/d3plot_solid_int/d3plot" d3plot = D3plot(filepath) d3plot2 = D3plot(filepath, state_filter=np.arange(0, 22)) diff --git a/lasso/dyna/test_d3plot_header.py b/lasso/dyna/test_d3plot_header.py index d47985a..3dff829 100644 --- a/lasso/dyna/test_d3plot_header.py +++ b/lasso/dyna/test_d3plot_header.py @@ -14,10 +14,10 @@ class D3plotHeaderTest(TestCase): def test_loading(self): filepaths = [ - "test/simple_d3plot/d3plot", - "test/d3plot_node_temperature/d3plot", - "test/d3plot_beamip/d3plot", - "test/d3plot_solid_int/d3plot", + "test/test_data/simple_d3plot/d3plot", + "test/test_data/d3plot_node_temperature/d3plot", + "test/test_data/d3plot_beamip/d3plot", + "test/test_data/d3plot_solid_int/d3plot", ] for filepath in filepaths: diff --git a/lasso/io/test_binary_buffer.py b/lasso/io/test_binary_buffer.py index 2f98768..b79d3e9 100644 --- a/lasso/io/test_binary_buffer.py +++ b/lasso/io/test_binary_buffer.py @@ -10,7 +10,7 @@ class BinaryBufferTest(TestCase): def setUp(self): # read file - self.bb = BinaryBuffer("test/simple_d3plot/d3plot") + self.bb = BinaryBuffer("test/test_data/simple_d3plot/d3plot") def test_init(self): @@ -39,14 +39,14 @@ def test_reading(self): def test_save(self): - self.bb.save("test/tmp") - eq = filecmp.cmp("test/simple_d3plot/d3plot", "test/tmp") - os.remove("test/tmp") + self.bb.save("test/test_data/tmp") + eq = filecmp.cmp("test/test_data/simple_d3plot/d3plot", "test/test_data/tmp") + os.remove("test/test_data/tmp") self.assertEqual(eq, True) def test_writing(self): - bb = BinaryBuffer("test/simple_d3plot/d3plot") + bb = BinaryBuffer("test/test_data/simple_d3plot/d3plot") bb.write_number(44, 13, np.int32) self.assertEqual(bb.read_number(44, np.int32), 13) @@ -56,7 +56,7 @@ def test_writing(self): def test_size(self): - bb = BinaryBuffer("test/simple_d3plot/d3plot") + bb = BinaryBuffer("test/test_data/simple_d3plot/d3plot") self.assertEqual(bb.size, 192512) self.assertEqual(bb.size, len(bb)) diff --git a/lasso/io/test_files.py b/lasso/io/test_files.py index 562b4d6..221da98 100644 --- a/lasso/io/test_files.py +++ b/lasso/io/test_files.py @@ -4,18 +4,18 @@ class Test(unittest.TestCase): def test_collect_files(self): - files = collect_files("test/io_test", "*.txt") + files = collect_files("test/test_data/io_test", "*.txt") self.assertEqual(len(files), 1) - files = collect_files("test/io_test/", "*.txt", recursive=True) + files = collect_files("test/test_data/io_test/", "*.txt", recursive=True) self.assertEqual(len(files), 2) - files1, files2 = collect_files("test/io_test/", ["*.txt", "*.yay"], recursive=True) + files1, files2 = collect_files("test/test_data/io_test/", ["*.txt", "*.yay"], recursive=True) self.assertEqual(len(files1), 2) self.assertEqual(len(files2), 1) files1, files2 = collect_files( - ["test/io_test/", "test/io_test/subfolder"], ["*.txt", "*.yay"] + ["test/test_data/io_test/", "test/test_data/io_test/subfolder"], ["*.txt", "*.yay"] ) self.assertEqual(len(files1), 2) self.assertEqual(len(files2), 1) diff --git a/test/DimredRunTest/verificationFile.hdf5 b/test/test_data/DimredRunTest/verificationFile.hdf5 similarity index 100% rename from test/DimredRunTest/verificationFile.hdf5 rename to test/test_data/DimredRunTest/verificationFile.hdf5 diff --git a/test/d3plot_beamip/d3plot b/test/test_data/d3plot_beamip/d3plot similarity index 100% rename from test/d3plot_beamip/d3plot rename to test/test_data/d3plot_beamip/d3plot diff --git a/test/d3plot_beamip/d3plot01 b/test/test_data/d3plot_beamip/d3plot01 similarity index 100% rename from test/d3plot_beamip/d3plot01 rename to test/test_data/d3plot_beamip/d3plot01 diff --git a/test/d3plot_node_temperature/d3plot b/test/test_data/d3plot_node_temperature/d3plot similarity index 100% rename from test/d3plot_node_temperature/d3plot rename to test/test_data/d3plot_node_temperature/d3plot diff --git a/test/d3plot_node_temperature/d3plot01 b/test/test_data/d3plot_node_temperature/d3plot01 similarity index 100% rename from test/d3plot_node_temperature/d3plot01 rename to test/test_data/d3plot_node_temperature/d3plot01 diff --git a/test/d3plot_solid_int/d3plot b/test/test_data/d3plot_solid_int/d3plot similarity index 100% rename from test/d3plot_solid_int/d3plot rename to test/test_data/d3plot_solid_int/d3plot diff --git a/test/d3plot_solid_int/d3plot01 b/test/test_data/d3plot_solid_int/d3plot01 similarity index 100% rename from test/d3plot_solid_int/d3plot01 rename to test/test_data/d3plot_solid_int/d3plot01 diff --git a/test/d3plot_solid_int/d3plot02 b/test/test_data/d3plot_solid_int/d3plot02 similarity index 100% rename from test/d3plot_solid_int/d3plot02 rename to test/test_data/d3plot_solid_int/d3plot02 diff --git a/test/d3plot_solid_int/d3plot03 b/test/test_data/d3plot_solid_int/d3plot03 similarity index 100% rename from test/d3plot_solid_int/d3plot03 rename to test/test_data/d3plot_solid_int/d3plot03 diff --git a/test/d3plot_solid_int/d3plot04 b/test/test_data/d3plot_solid_int/d3plot04 similarity index 100% rename from test/d3plot_solid_int/d3plot04 rename to test/test_data/d3plot_solid_int/d3plot04 diff --git a/test/d3plot_solid_int/d3plot05 b/test/test_data/d3plot_solid_int/d3plot05 similarity index 100% rename from test/d3plot_solid_int/d3plot05 rename to test/test_data/d3plot_solid_int/d3plot05 diff --git a/test/d3plot_solid_int/d3plot06 b/test/test_data/d3plot_solid_int/d3plot06 similarity index 100% rename from test/d3plot_solid_int/d3plot06 rename to test/test_data/d3plot_solid_int/d3plot06 diff --git a/test/d3plot_solid_int/d3plot07 b/test/test_data/d3plot_solid_int/d3plot07 similarity index 100% rename from test/d3plot_solid_int/d3plot07 rename to test/test_data/d3plot_solid_int/d3plot07 diff --git a/test/d3plot_solid_int/d3plot08 b/test/test_data/d3plot_solid_int/d3plot08 similarity index 100% rename from test/d3plot_solid_int/d3plot08 rename to test/test_data/d3plot_solid_int/d3plot08 diff --git a/test/d3plot_solid_int/d3plot09 b/test/test_data/d3plot_solid_int/d3plot09 similarity index 100% rename from test/d3plot_solid_int/d3plot09 rename to test/test_data/d3plot_solid_int/d3plot09 diff --git a/test/d3plot_solid_int/d3plot10 b/test/test_data/d3plot_solid_int/d3plot10 similarity index 100% rename from test/d3plot_solid_int/d3plot10 rename to test/test_data/d3plot_solid_int/d3plot10 diff --git a/test/d3plot_solid_int/d3plot11 b/test/test_data/d3plot_solid_int/d3plot11 similarity index 100% rename from test/d3plot_solid_int/d3plot11 rename to test/test_data/d3plot_solid_int/d3plot11 diff --git a/test/d3plot_solid_int/d3plot12 b/test/test_data/d3plot_solid_int/d3plot12 similarity index 100% rename from test/d3plot_solid_int/d3plot12 rename to test/test_data/d3plot_solid_int/d3plot12 diff --git a/test/d3plot_solid_int/d3plot13 b/test/test_data/d3plot_solid_int/d3plot13 similarity index 100% rename from test/d3plot_solid_int/d3plot13 rename to test/test_data/d3plot_solid_int/d3plot13 diff --git a/test/d3plot_solid_int/d3plot14 b/test/test_data/d3plot_solid_int/d3plot14 similarity index 100% rename from test/d3plot_solid_int/d3plot14 rename to test/test_data/d3plot_solid_int/d3plot14 diff --git a/test/d3plot_solid_int/d3plot15 b/test/test_data/d3plot_solid_int/d3plot15 similarity index 100% rename from test/d3plot_solid_int/d3plot15 rename to test/test_data/d3plot_solid_int/d3plot15 diff --git a/test/d3plot_solid_int/d3plot16 b/test/test_data/d3plot_solid_int/d3plot16 similarity index 100% rename from test/d3plot_solid_int/d3plot16 rename to test/test_data/d3plot_solid_int/d3plot16 diff --git a/test/d3plot_solid_int/d3plot17 b/test/test_data/d3plot_solid_int/d3plot17 similarity index 100% rename from test/d3plot_solid_int/d3plot17 rename to test/test_data/d3plot_solid_int/d3plot17 diff --git a/test/d3plot_solid_int/d3plot18 b/test/test_data/d3plot_solid_int/d3plot18 similarity index 100% rename from test/d3plot_solid_int/d3plot18 rename to test/test_data/d3plot_solid_int/d3plot18 diff --git a/test/d3plot_solid_int/d3plot19 b/test/test_data/d3plot_solid_int/d3plot19 similarity index 100% rename from test/d3plot_solid_int/d3plot19 rename to test/test_data/d3plot_solid_int/d3plot19 diff --git a/test/d3plot_solid_int/d3plot20 b/test/test_data/d3plot_solid_int/d3plot20 similarity index 100% rename from test/d3plot_solid_int/d3plot20 rename to test/test_data/d3plot_solid_int/d3plot20 diff --git a/test/d3plot_solid_int/d3plot21 b/test/test_data/d3plot_solid_int/d3plot21 similarity index 100% rename from test/d3plot_solid_int/d3plot21 rename to test/test_data/d3plot_solid_int/d3plot21 diff --git a/test/d3plot_solid_int/d3plot22 b/test/test_data/d3plot_solid_int/d3plot22 similarity index 100% rename from test/d3plot_solid_int/d3plot22 rename to test/test_data/d3plot_solid_int/d3plot22 diff --git a/test/femzip/d3plot b/test/test_data/femzip/d3plot similarity index 100% rename from test/femzip/d3plot rename to test/test_data/femzip/d3plot diff --git a/test/femzip/d3plot.fz b/test/test_data/femzip/d3plot.fz similarity index 100% rename from test/femzip/d3plot.fz rename to test/test_data/femzip/d3plot.fz diff --git a/test/femzip/d3plot01 b/test/test_data/femzip/d3plot01 similarity index 100% rename from test/femzip/d3plot01 rename to test/test_data/femzip/d3plot01 diff --git a/test/io_test/file1.txt b/test/test_data/io_test/file1.txt similarity index 100% rename from test/io_test/file1.txt rename to test/test_data/io_test/file1.txt diff --git a/test/io_test/subfolder/file2.txt b/test/test_data/io_test/subfolder/file2.txt similarity index 100% rename from test/io_test/subfolder/file2.txt rename to test/test_data/io_test/subfolder/file2.txt diff --git a/test/io_test/subfolder/file3.yay b/test/test_data/io_test/subfolder/file3.yay similarity index 100% rename from test/io_test/subfolder/file3.yay rename to test/test_data/io_test/subfolder/file3.yay diff --git a/test/order_d3plot/d3plot b/test/test_data/order_d3plot/d3plot similarity index 100% rename from test/order_d3plot/d3plot rename to test/test_data/order_d3plot/d3plot diff --git a/test/order_d3plot/d3plot01 b/test/test_data/order_d3plot/d3plot01 similarity index 100% rename from test/order_d3plot/d3plot01 rename to test/test_data/order_d3plot/d3plot01 diff --git a/test/order_d3plot/d3plot02 b/test/test_data/order_d3plot/d3plot02 similarity index 100% rename from test/order_d3plot/d3plot02 rename to test/test_data/order_d3plot/d3plot02 diff --git a/test/order_d3plot/d3plot10 b/test/test_data/order_d3plot/d3plot10 similarity index 100% rename from test/order_d3plot/d3plot10 rename to test/test_data/order_d3plot/d3plot10 diff --git a/test/order_d3plot/d3plot100 b/test/test_data/order_d3plot/d3plot100 similarity index 100% rename from test/order_d3plot/d3plot100 rename to test/test_data/order_d3plot/d3plot100 diff --git a/test/order_d3plot/d3plot11 b/test/test_data/order_d3plot/d3plot11 similarity index 100% rename from test/order_d3plot/d3plot11 rename to test/test_data/order_d3plot/d3plot11 diff --git a/test/order_d3plot/d3plot12 b/test/test_data/order_d3plot/d3plot12 similarity index 100% rename from test/order_d3plot/d3plot12 rename to test/test_data/order_d3plot/d3plot12 diff --git a/test/order_d3plot/d3plot22 b/test/test_data/order_d3plot/d3plot22 similarity index 100% rename from test/order_d3plot/d3plot22 rename to test/test_data/order_d3plot/d3plot22 diff --git a/test/simple_d3plot/d3plot b/test/test_data/simple_d3plot/d3plot similarity index 100% rename from test/simple_d3plot/d3plot rename to test/test_data/simple_d3plot/d3plot diff --git a/test/simple_d3plot/d3plot01 b/test/test_data/simple_d3plot/d3plot01 similarity index 100% rename from test/simple_d3plot/d3plot01 rename to test/test_data/simple_d3plot/d3plot01 From 42e61458bc3bda8dadf9a3695282597f6920fba7 Mon Sep 17 00:00:00 2001 From: M Laraib Ali Date: Tue, 8 Apr 2025 22:55:33 +0500 Subject: [PATCH 2/5] move test files to `test/unit_tests` --- Taskfile.yml | 6 +- .../plot_creator_helper.py | 64 ++++--------------- .../dimred/svd/test_clustering_betas.py | 0 .../dimred/svd/test_plot_betas_clusters.py | 0 .../dimred/svd/test_pod_functions.py | 0 .../dimred/svd/test_subsampling_methods.py | 6 +- .../unit_tests}/dimred/test_dimred_run.py | 8 ++- .../unit_tests}/dyna/test_d3plot.py | 0 .../unit_tests}/dyna/test_d3plot_header.py | 3 + .../unit_tests}/dyna/test_mapper.py | 6 +- .../unit_tests}/io/test_binary_buffer.py | 0 {lasso => test/unit_tests}/io/test_files.py | 4 +- .../unit_tests}/math/test_sampling.py | 0 .../unit_tests}/math/test_stochastic.py | 0 14 files changed, 31 insertions(+), 66 deletions(-) rename lasso/dimred/test_plot_creator.py => test/plot_creator_helper.py (74%) rename {lasso => test/unit_tests}/dimred/svd/test_clustering_betas.py (100%) rename {lasso => test/unit_tests}/dimred/svd/test_plot_betas_clusters.py (100%) rename {lasso => test/unit_tests}/dimred/svd/test_pod_functions.py (100%) rename {lasso => test/unit_tests}/dimred/svd/test_subsampling_methods.py (93%) rename {lasso => test/unit_tests}/dimred/test_dimred_run.py (95%) rename {lasso => test/unit_tests}/dyna/test_d3plot.py (100%) rename {lasso => test/unit_tests}/dyna/test_d3plot_header.py (94%) rename {lasso => test/unit_tests}/dyna/test_mapper.py (96%) rename {lasso => test/unit_tests}/io/test_binary_buffer.py (100%) rename {lasso => test/unit_tests}/io/test_files.py (81%) rename {lasso => test/unit_tests}/math/test_sampling.py (100%) rename {lasso => test/unit_tests}/math/test_stochastic.py (100%) diff --git a/Taskfile.yml b/Taskfile.yml index 991ff71..25e713f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,8 +9,8 @@ tasks: lint: desc: Lints the code and reports on issues. cmds: - - poetry run black --check lasso - - poetry run ruff check + - poetry run black --check . + - poetry run ruff check . build: desc: Builds the python package @@ -21,7 +21,7 @@ tasks: desc: Runs tests on the code cmds: - > - poetry run pytest + poetry run pytest test --cov=lasso --cov-report=html diff --git a/lasso/dimred/test_plot_creator.py b/test/plot_creator_helper.py similarity index 74% rename from lasso/dimred/test_plot_creator.py rename to test/plot_creator_helper.py index 9f43fc4..d18b614 100644 --- a/lasso/dimred/test_plot_creator.py +++ b/test/plot_creator_helper.py @@ -8,6 +8,7 @@ from lasso.dyna.d3plot import ArrayType, D3plot +# FIXME: there are no tests in this file. probably dead code. def create_fake_d3plots( path: str, element_shell_node_indexes: np.ndarray, @@ -108,51 +109,9 @@ def create_element_shell_node_indexes(n_nodes_x: int = 500, n_nodes_y: int = 10) return new_shell_node_indexes -def create_2_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timesteps=5): +def create_n_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timesteps=5, n=50): """ - creates 2 faked plots - - Parameters - ---------- - folder: str - folder path - n_nodes_x: int - how many nodes in x - n_nodes_y: int - how many nodes in y - n_timesteps: int, default: 5 - how many timesteps - """ - - randy_random = random.Random("The_Seed") - plot_name = "SVDTestPlot{i}" - - element_shell_node_indexes = create_element_shell_node_indexes( - n_nodes_x=n_nodes_x, n_nodes_y=n_nodes_y - ) - - create_fake_d3plots( - path=os.path.join(folder, plot_name.format(i="00")), - element_shell_node_indexes=element_shell_node_indexes, - bend_multiplicator=5 * (1 + randy_random.random()), - n_nodes_x=n_nodes_x, - n_nodes_y=n_nodes_y, - n_timesteps=n_timesteps, - ) - - create_fake_d3plots( - path=os.path.join(folder, plot_name.format(i="01")), - element_shell_node_indexes=element_shell_node_indexes, - bend_multiplicator=5 * (1 + randy_random.random()), - n_nodes_x=n_nodes_x, - n_nodes_y=n_nodes_y, - n_timesteps=n_timesteps, - ) - - -def create_50_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timesteps=5): - """ - creates 50 faked plots, 25 bending up, 25 bending down + creates `n` fake plots, `n/2` bending up, `n/2` bending down Parameters ---------- @@ -164,6 +123,8 @@ def create_50_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timestep how many nodes in y n_timesteps: int, default: 5 how many timesteps + n: int, default: 50 + how many plots """ # init random @@ -176,13 +137,10 @@ def create_50_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timestep n_nodes_x=n_nodes_x, n_nodes_y=n_nodes_y ) - # 25 plots bending up - for i in range(25): - nr = str(i) - if i < 10: - nr = "0" + str(i) + # n plots bending up + for i in range(int(n / 2)): create_fake_d3plots( - path=os.path.join(folder, plot_name.format(i=nr)), + path=os.path.join(folder, plot_name.format(i=f"{i:02d}")), element_shell_node_indexes=element_shell_node_indexes, bend_multiplicator=5 * (1 + randy_random.random()), n_nodes_x=n_nodes_x, @@ -190,10 +148,10 @@ def create_50_fake_plots(folder: str, n_nodes_x: int, n_nodes_y: int, n_timestep n_timesteps=n_timesteps, ) - # 25 plots bending down - for i in range(25): + # n plots bending down + for i in range(int(n / 2)): create_fake_d3plots( - path=os.path.join(folder, plot_name.format(i=i + 25)), + path=os.path.join(folder, plot_name.format(i=f"{i+int(n/2):02d}")), element_shell_node_indexes=element_shell_node_indexes, bend_multiplicator=-5 * (1 + randy_random.random()), n_nodes_x=n_nodes_x, diff --git a/lasso/dimred/svd/test_clustering_betas.py b/test/unit_tests/dimred/svd/test_clustering_betas.py similarity index 100% rename from lasso/dimred/svd/test_clustering_betas.py rename to test/unit_tests/dimred/svd/test_clustering_betas.py diff --git a/lasso/dimred/svd/test_plot_betas_clusters.py b/test/unit_tests/dimred/svd/test_plot_betas_clusters.py similarity index 100% rename from lasso/dimred/svd/test_plot_betas_clusters.py rename to test/unit_tests/dimred/svd/test_plot_betas_clusters.py diff --git a/lasso/dimred/svd/test_pod_functions.py b/test/unit_tests/dimred/svd/test_pod_functions.py similarity index 100% rename from lasso/dimred/svd/test_pod_functions.py rename to test/unit_tests/dimred/svd/test_pod_functions.py diff --git a/lasso/dimred/svd/test_subsampling_methods.py b/test/unit_tests/dimred/svd/test_subsampling_methods.py similarity index 93% rename from lasso/dimred/svd/test_subsampling_methods.py rename to test/unit_tests/dimred/svd/test_subsampling_methods.py index 7ecb2f7..106a144 100644 --- a/lasso/dimred/svd/test_subsampling_methods.py +++ b/test/unit_tests/dimred/svd/test_subsampling_methods.py @@ -6,7 +6,7 @@ import numpy as np from lasso.dimred.svd.subsampling_methods import create_reference_subsample, remap_random_subsample -from lasso.dimred.test_plot_creator import create_2_fake_plots +from test.plot_creator_helper import create_n_fake_plots class TestSubsampling(TestCase): @@ -15,7 +15,7 @@ def test_create_reference_sample(self): with tempfile.TemporaryDirectory() as tmp_dir: - create_2_fake_plots(tmp_dir, 500, 10) + create_n_fake_plots(tmp_dir, 500, 10, n=2) load_path = os.path.join(tmp_dir, "SVDTestPlot00/plot") n_nodes = 200 @@ -55,7 +55,7 @@ def test_remap_random_subsample(self): with tempfile.TemporaryDirectory() as tmp_dir: - create_2_fake_plots(tmp_dir, 500, 10) + create_n_fake_plots(tmp_dir, 500, 10, n=2) ref_path = os.path.join(tmp_dir, "SVDTestPlot00/plot") sample_path = os.path.join(tmp_dir, "SVDTestPlot01/plot") n_nodes = 200 diff --git a/lasso/dimred/test_dimred_run.py b/test/unit_tests/dimred/test_dimred_run.py similarity index 95% rename from lasso/dimred/test_dimred_run.py rename to test/unit_tests/dimred/test_dimred_run.py index c604d80..3e920b8 100644 --- a/lasso/dimred/test_dimred_run.py +++ b/test/unit_tests/dimred/test_dimred_run.py @@ -6,18 +6,20 @@ import numpy as np from lasso.dimred.dimred_run import DIMRED_STAGES, DimredRun, DimredRunError, HDF5FileNames -from lasso.dimred.test_plot_creator import create_50_fake_plots +from test.plot_creator_helper import create_n_fake_plots class TestDimredRun(TestCase): def test_run(self): """Verifies correct function of DimredRun.py""" - verification_hdf5_file = h5py.File("test/test_data/DimredRunTest/verificationFile.hdf5", "r") + verification_hdf5_file = h5py.File( + "test/test_data/DimredRunTest/verificationFile.hdf5", "r" + ) with tempfile.TemporaryDirectory() as tmpdir: # create simulation runs - create_50_fake_plots(folder=tmpdir, n_nodes_x=500, n_nodes_y=10) + create_n_fake_plots(folder=tmpdir, n_nodes_x=500, n_nodes_y=10) # collect all simulation runs # sim_dir = "test/dimredTestPlots" diff --git a/lasso/dyna/test_d3plot.py b/test/unit_tests/dyna/test_d3plot.py similarity index 100% rename from lasso/dyna/test_d3plot.py rename to test/unit_tests/dyna/test_d3plot.py diff --git a/lasso/dyna/test_d3plot_header.py b/test/unit_tests/dyna/test_d3plot_header.py similarity index 94% rename from lasso/dyna/test_d3plot_header.py rename to test/unit_tests/dyna/test_d3plot_header.py index 3dff829..828dc40 100644 --- a/lasso/dyna/test_d3plot_header.py +++ b/test/unit_tests/dyna/test_d3plot_header.py @@ -1,6 +1,7 @@ from unittest import TestCase import numpy as np +import pytest from lasso.dyna.d3plot_header import ( D3plotFiletype, D3plotHeader, @@ -11,6 +12,8 @@ class D3plotHeaderTest(TestCase): + + @pytest.mark.skip(reason="NOT IMPLEMENTED") def test_loading(self): filepaths = [ diff --git a/lasso/dyna/test_mapper.py b/test/unit_tests/dyna/test_mapper.py similarity index 96% rename from lasso/dyna/test_mapper.py rename to test/unit_tests/dyna/test_mapper.py index b959254..99bc88f 100644 --- a/lasso/dyna/test_mapper.py +++ b/test/unit_tests/dyna/test_mapper.py @@ -3,9 +3,9 @@ import numpy as np -from ..femzip.fz_config import FemzipArrayType, FemzipVariableCategory -from .array_type import ArrayType -from .femzip_mapper import FemzipMapper +from lasso.femzip.fz_config import FemzipArrayType, FemzipVariableCategory +from lasso.dyna.array_type import ArrayType +from lasso.dyna.femzip_mapper import FemzipMapper part_global_femzip_translations: Dict[Tuple[FemzipArrayType, FemzipVariableCategory], Set[str]] = { # GLOBAL diff --git a/lasso/io/test_binary_buffer.py b/test/unit_tests/io/test_binary_buffer.py similarity index 100% rename from lasso/io/test_binary_buffer.py rename to test/unit_tests/io/test_binary_buffer.py diff --git a/lasso/io/test_files.py b/test/unit_tests/io/test_files.py similarity index 81% rename from lasso/io/test_files.py rename to test/unit_tests/io/test_files.py index 221da98..7c8adac 100644 --- a/lasso/io/test_files.py +++ b/test/unit_tests/io/test_files.py @@ -10,7 +10,9 @@ def test_collect_files(self): files = collect_files("test/test_data/io_test/", "*.txt", recursive=True) self.assertEqual(len(files), 2) - files1, files2 = collect_files("test/test_data/io_test/", ["*.txt", "*.yay"], recursive=True) + files1, files2 = collect_files( + "test/test_data/io_test/", ["*.txt", "*.yay"], recursive=True + ) self.assertEqual(len(files1), 2) self.assertEqual(len(files2), 1) diff --git a/lasso/math/test_sampling.py b/test/unit_tests/math/test_sampling.py similarity index 100% rename from lasso/math/test_sampling.py rename to test/unit_tests/math/test_sampling.py diff --git a/lasso/math/test_stochastic.py b/test/unit_tests/math/test_stochastic.py similarity index 100% rename from lasso/math/test_stochastic.py rename to test/unit_tests/math/test_stochastic.py From b3d29a749389a19eb66c41334d6d4f3f1cb49779 Mon Sep 17 00:00:00 2001 From: M Laraib Ali Date: Wed, 9 Apr 2025 01:18:39 +0500 Subject: [PATCH 3/5] fix the imports in testSuite --- test/__init__.py | 0 test/unit_tests/__init__.py | 0 test/unit_tests/dimred/__init__.py | 0 test/unit_tests/dimred/svd/__init__.py | 0 test/unit_tests/dyna/__init__.py | 0 test/unit_tests/io/__init__.py | 0 test/unit_tests/math/__init__.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/__init__.py create mode 100644 test/unit_tests/__init__.py create mode 100644 test/unit_tests/dimred/__init__.py create mode 100644 test/unit_tests/dimred/svd/__init__.py create mode 100644 test/unit_tests/dyna/__init__.py create mode 100644 test/unit_tests/io/__init__.py create mode 100644 test/unit_tests/math/__init__.py diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/__init__.py b/test/unit_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/dimred/__init__.py b/test/unit_tests/dimred/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/dimred/svd/__init__.py b/test/unit_tests/dimred/svd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/dyna/__init__.py b/test/unit_tests/dyna/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/io/__init__.py b/test/unit_tests/io/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/unit_tests/math/__init__.py b/test/unit_tests/math/__init__.py new file mode 100644 index 0000000..e69de29 From 0f5c1801569d6a04eb6bdce2890a51ca2e25e484 Mon Sep 17 00:00:00 2001 From: M Laraib Ali Date: Thu, 10 Apr 2025 13:03:07 +0500 Subject: [PATCH 4/5] Update test_d3plot_header.py remove skipping of test add warning about no behavior testing --- test/unit_tests/dyna/test_d3plot_header.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit_tests/dyna/test_d3plot_header.py b/test/unit_tests/dyna/test_d3plot_header.py index 828dc40..185208f 100644 --- a/test/unit_tests/dyna/test_d3plot_header.py +++ b/test/unit_tests/dyna/test_d3plot_header.py @@ -1,6 +1,7 @@ from unittest import TestCase import numpy as np +import warnings import pytest from lasso.dyna.d3plot_header import ( D3plotFiletype, @@ -13,7 +14,6 @@ class D3plotHeaderTest(TestCase): - @pytest.mark.skip(reason="NOT IMPLEMENTED") def test_loading(self): filepaths = [ @@ -27,6 +27,7 @@ def test_loading(self): D3plotHeader().load_file(filepath) # TODO more + warnings.warn("No assertions of behavior, test is incomplete") def test_get_digit(self) -> None: From bec0b62a2eb328d72d023aa5c3569f2b974f0b6c Mon Sep 17 00:00:00 2001 From: M Laraib Ali Date: Thu, 10 Apr 2025 13:06:19 +0500 Subject: [PATCH 5/5] fix linting issue --- test/unit_tests/dyna/test_d3plot_header.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit_tests/dyna/test_d3plot_header.py b/test/unit_tests/dyna/test_d3plot_header.py index 185208f..4d107ed 100644 --- a/test/unit_tests/dyna/test_d3plot_header.py +++ b/test/unit_tests/dyna/test_d3plot_header.py @@ -2,7 +2,6 @@ import numpy as np import warnings -import pytest from lasso.dyna.d3plot_header import ( D3plotFiletype, D3plotHeader,