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/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 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/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 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/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 88% rename from lasso/dimred/test_dimred_run.py rename to test/unit_tests/dimred/test_dimred_run.py index adba6fb..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/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" @@ -33,7 +35,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 +140,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 +163,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 +176,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 +189,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 +201,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 +213,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 +226,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 +241,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 +252,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/test/unit_tests/dyna/__init__.py b/test/unit_tests/dyna/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lasso/dyna/test_d3plot.py b/test/unit_tests/dyna/test_d3plot.py similarity index 92% rename from lasso/dyna/test_d3plot.py rename to test/unit_tests/dyna/test_d3plot.py index 73de673..4ba00f9 100644 --- a/lasso/dyna/test_d3plot.py +++ b/test/unit_tests/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/test/unit_tests/dyna/test_d3plot_header.py similarity index 87% rename from lasso/dyna/test_d3plot_header.py rename to test/unit_tests/dyna/test_d3plot_header.py index d47985a..4d107ed 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 warnings from lasso.dyna.d3plot_header import ( D3plotFiletype, D3plotHeader, @@ -11,19 +12,21 @@ 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: D3plotHeader().load_file(filepath) # TODO more + warnings.warn("No assertions of behavior, test is incomplete") def test_get_digit(self) -> None: 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/test/unit_tests/io/__init__.py b/test/unit_tests/io/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lasso/io/test_binary_buffer.py b/test/unit_tests/io/test_binary_buffer.py similarity index 79% rename from lasso/io/test_binary_buffer.py rename to test/unit_tests/io/test_binary_buffer.py index 2f98768..b79d3e9 100644 --- a/lasso/io/test_binary_buffer.py +++ b/test/unit_tests/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/test/unit_tests/io/test_files.py similarity index 51% rename from lasso/io/test_files.py rename to test/unit_tests/io/test_files.py index 562b4d6..7c8adac 100644 --- a/lasso/io/test_files.py +++ b/test/unit_tests/io/test_files.py @@ -4,18 +4,20 @@ 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/unit_tests/math/__init__.py b/test/unit_tests/math/__init__.py new file mode 100644 index 0000000..e69de29 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