diff --git a/docs/source/userguide/as_an_api.rst b/docs/source/userguide/as_an_api.rst index 020bb17..e2ed762 100644 --- a/docs/source/userguide/as_an_api.rst +++ b/docs/source/userguide/as_an_api.rst @@ -13,7 +13,7 @@ Pandora provides a full python API which can be used to compute disparity maps a import pandora from pandora import common from pandora.img_tools import read_img, read_disp - from pandora.check_json import check_conf, read_config_file + from pandora.check_configuration import check_conf, read_config_file from pandora.state_machine import PandoraMachine def pandora_stereo(cfg_path: str, output: str, verbose: bool) -> None: diff --git a/notebooks/advanced_examples/api_check_conf.ipynb b/notebooks/advanced_examples/api_check_conf.ipynb index 2064dc5..5e424b2 100644 --- a/notebooks/advanced_examples/api_check_conf.ipynb +++ b/notebooks/advanced_examples/api_check_conf.ipynb @@ -40,7 +40,7 @@ "outputs": [], "source": [ "from pandora import import_plugin\n", - "from pandora.check_json import (\n", + "from pandora.check_configuration import (\n", " check_conf,\n", " get_config_input,\n", " check_input_section,\n", diff --git a/notebooks/advanced_examples/cost_profile_analysis.ipynb b/notebooks/advanced_examples/cost_profile_analysis.ipynb index 9783843..b437697 100644 --- a/notebooks/advanced_examples/cost_profile_analysis.ipynb +++ b/notebooks/advanced_examples/cost_profile_analysis.ipynb @@ -28,7 +28,7 @@ "source": [ "import pandora\n", "from pandora.img_tools import read_img\n", - "from pandora.check_json import check_pipeline_section, concat_conf\n", + "from pandora.check_configuration import check_pipeline_section, concat_conf\n", "from pandora.state_machine import PandoraMachine\n", "from pandora import import_plugin, check_conf" ] diff --git a/notebooks/introduction_and_basic_usage.ipynb b/notebooks/introduction_and_basic_usage.ipynb index a4ee094..d9e593a 100644 --- a/notebooks/introduction_and_basic_usage.ipynb +++ b/notebooks/introduction_and_basic_usage.ipynb @@ -182,7 +182,7 @@ "# Load pandora imports\n", "import pandora\n", "from pandora.img_tools import read_img\n", - "from pandora.check_json import check_pipeline_section, concat_conf, memory_consumption_estimation, get_metadata, get_config_pipeline\n", + "from pandora.check_configuration import check_pipeline_section, concat_conf, memory_consumption_estimation, get_metadata, get_config_pipeline\n", "from pandora.state_machine import PandoraMachine\n", "from pandora import import_plugin, check_conf" ] diff --git a/notebooks/statistical_and_visual_analysis.ipynb b/notebooks/statistical_and_visual_analysis.ipynb index fe50f46..932febf 100644 --- a/notebooks/statistical_and_visual_analysis.ipynb +++ b/notebooks/statistical_and_visual_analysis.ipynb @@ -87,7 +87,7 @@ "# Load pandora imports\n", "import pandora\n", "from pandora.img_tools import read_img\n", - "from pandora.check_json import check_pipeline_section, concat_conf, get_metadata, get_config_pipeline\n", + "from pandora.check_configuration import check_pipeline_section, concat_conf, get_metadata, get_config_pipeline\n", "from pandora.state_machine import PandoraMachine\n", "from pandora import import_plugin, check_conf" ] diff --git a/notebooks/usage_with_multiscale.ipynb b/notebooks/usage_with_multiscale.ipynb index fd5a1d2..d87a533 100644 --- a/notebooks/usage_with_multiscale.ipynb +++ b/notebooks/usage_with_multiscale.ipynb @@ -207,7 +207,7 @@ "# Load pandora imports\n", "import pandora\n", "from pandora.img_tools import read_img\n", - "from pandora.check_json import check_pipeline_section, concat_conf, get_metadata, get_config_pipeline\n", + "from pandora.check_configuration import check_pipeline_section, concat_conf, get_metadata, get_config_pipeline\n", "from pandora.state_machine import PandoraMachine\n", "from pandora import import_plugin, check_conf" ] diff --git a/pandora/__init__.py b/pandora/__init__.py index 6b917c5..2f8e76a 100644 --- a/pandora/__init__.py +++ b/pandora/__init__.py @@ -33,7 +33,7 @@ from . import common from .img_tools import read_img, read_disp -from .check_json import check_conf, read_config_file, read_multiscale_params +from .check_configuration import check_conf, read_config_file, read_multiscale_params from .state_machine import PandoraMachine diff --git a/pandora/check_json.py b/pandora/check_configuration.py similarity index 100% rename from pandora/check_json.py rename to pandora/check_configuration.py diff --git a/tests/test_confidence.py b/tests/test_confidence.py index 91ea6e2..ad71b1a 100644 --- a/tests/test_confidence.py +++ b/tests/test_confidence.py @@ -164,7 +164,7 @@ def test_ambiguity_std_full_pipeline(): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_im, right_im, -1, 1, cfg) @@ -278,7 +278,7 @@ def test_non_normalized_ambiguity_std_full_pipeline(): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_im, right_im, -1, 1, cfg) diff --git a/tests/test_config.py b/tests/test_config.py index 418ab7a..17ed6eb 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -32,7 +32,7 @@ import numpy as np import xarray as xr from tests import common -import pandora.check_json as JSON_checker +from pandora import check_configuration from pandora.state_machine import PandoraMachine @@ -55,19 +55,19 @@ def test_check_input_section(): # Test configuration with left disparity grids and right disparity = none cfg = {"input": copy.deepcopy(common.input_cfg_left_grids)} - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if (cfg_return["input"]["disp_min_right"] is not None) and (cfg_return["input"]["disp_max_right"] is not None): raise AssertionError # Test configuration with left disparity as integer cfg = {"input": copy.deepcopy(common.input_cfg_basic)} - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if (cfg_return["input"]["disp_min_right"] is not None) and (cfg_return["input"]["disp_max_right"] is not None): raise AssertionError # Test configuration with left and right disparity grids cfg = {"input": copy.deepcopy(common.input_cfg_left_right_grids)} - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if (cfg_return["input"]["disp_min_right"] != "tests/pandora/right_disp_min_grid.tif") and ( cfg_return["input"]["disp_max_right"] != "tests/pandora/right_disp_max_grid.tif" @@ -76,7 +76,7 @@ def test_check_input_section(): # Test configuration with left disparity grids and right disparity = none and classif and segm = none cfg = {"input": copy.deepcopy(common.input_cfg_left_grids)} - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if ( (cfg_return["input"]["left_classif"] is not None) and (cfg_return["input"]["left_segm"] is not None) @@ -91,7 +91,7 @@ def test_check_input_section(): cfg["input"]["left_classif"] = "tests/pandora/right.png" cfg["input"]["left_segm"] = "tests/pandora/left.png" - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if ( (cfg_return["input"]["left_classif"] != "tests/pandora/right.png") and (cfg_return["input"]["left_segm"] != "tests/pandora/left.png") @@ -106,7 +106,7 @@ def test_check_input_section(): cfg["input"]["right_classif"] = "tests/pandora/right.png" cfg["input"]["right_segm"] = "tests/pandora/left.png" - cfg_return = JSON_checker.check_input_section(cfg) + cfg_return = check_configuration.check_input_section(cfg) if ( (cfg_return["input"]["right_classif"] != "tests/pandora/right.png") and (cfg_return["input"]["right_segm"] != "tests/pandora/left.png") @@ -124,28 +124,28 @@ def test_check_input_section_with_error(self): cfg["input"]["disp_max"] = 45 # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity max as integer cfg = {"input": copy.deepcopy(common.input_cfg_left_grids)} cfg["input"]["disp_max_right"] = -4 # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity max as integer cfg = {"input": copy.deepcopy(common.input_cfg_left_right_grids)} cfg["input"]["disp_max_right"] = -4 # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity min as integer cfg = {"input": copy.deepcopy(common.input_cfg_left_grids)} cfg["input"]["disp_min_right"] = -4 # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparities as integer cfg = {"input": copy.deepcopy(common.input_cfg_left_grids)} @@ -153,7 +153,7 @@ def test_check_input_section_with_error(self): cfg["input"]["disp_max_right"] = 0 # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity as int and right disparites as str cfg = { @@ -167,7 +167,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids inverted cfg = { @@ -179,7 +179,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(SystemExit, JSON_checker.check_input_section, cfg) + self.assertRaises(SystemExit, check_configuration.check_input_section, cfg) # Test configuration with left disparity inverted cfg = { @@ -191,7 +191,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(SystemExit, JSON_checker.check_input_section, cfg) + self.assertRaises(SystemExit, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity grids inverted cfg = { @@ -205,7 +205,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(SystemExit, JSON_checker.check_input_section, cfg) + self.assertRaises(SystemExit, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity max as str cfg = { @@ -218,7 +218,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity grids and right disparity min as str cfg = { @@ -231,7 +231,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity as int and right disparity min as str cfg = { @@ -244,7 +244,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) # Test configuration with left disparity as int and right disparity max as str cfg = { @@ -257,7 +257,7 @@ def test_check_input_section_with_error(self): } } # Json checker must raise an error - self.assertRaises(json_checker.core.exceptions.DictCheckerError, JSON_checker.check_input_section, cfg) + self.assertRaises(json_checker.core.exceptions.DictCheckerError, check_configuration.check_input_section, cfg) def test_get_metadata(self): """ @@ -268,7 +268,7 @@ def test_get_metadata(self): cfg = {"input": copy.deepcopy(common.input_cfg_basic)} # get metadata without classif and mask - metadata_img = JSON_checker.get_metadata( + metadata_img = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) @@ -295,7 +295,7 @@ def test_multiband_pipeline(self): }, } - cfg_return = JSON_checker.check_conf(cfg, pandora_machine) + cfg_return = check_configuration.check_conf(cfg, pandora_machine) cfg_gt = { "input": { @@ -339,13 +339,13 @@ def test_failed_multiband_pipeline(self): "disparity": {"disparity_method": "wta"}, }, } - img_left = JSON_checker.get_metadata( + img_left = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) - img_right = JSON_checker.get_metadata(cfg["input"]["img_right"], None, None) + img_right = check_configuration.get_metadata(cfg["input"]["img_right"], None, None) # Check that the check_conf function raises an error with pytest.raises(SystemExit): - JSON_checker.check_conf(cfg, pandora_machine) + check_configuration.check_conf(cfg, pandora_machine) # Check that the check_band_pipeline raises an error (this shall be the source of check_conf's error) with pytest.raises(SystemExit): pandora_machine.check_band_pipeline( @@ -368,15 +368,15 @@ def test_failed_multiband_pipeline(self): "disparity": {"disparity_method": "wta"}, }, } - img_left = JSON_checker.get_metadata( + img_left = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) - img_right = JSON_checker.get_metadata(cfg["input"]["img_right"], None, None) + img_right = check_configuration.get_metadata(cfg["input"]["img_right"], None, None) pandora_machine = PandoraMachine() # Check that the check_conf function raises an error with pytest.raises(SystemExit): - JSON_checker.check_conf(cfg, pandora_machine) + check_configuration.check_conf(cfg, pandora_machine) # Check that the check_band_pipeline raises an error (this shall be the source of check_conf's error) with pytest.raises(SystemExit): # We add the band argument ad None because normally it is completed in the check_conf function, @@ -411,7 +411,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if (not np.isnan(cfg_return["input"]["nodata_left"])) or (not np.isnan(cfg_return["input"]["nodata_right"])): raise AssertionError @@ -428,7 +428,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if not cfg_return["input"]["nodata_left"] == np.inf or not cfg_return["input"]["nodata_right"] == np.inf: raise AssertionError @@ -445,7 +445,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if not cfg_return["input"]["nodata_left"] == -np.inf or not cfg_return["input"]["nodata_right"] == -np.inf: raise AssertionError @@ -462,7 +462,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if not cfg_return["input"]["nodata_left"] == 3 or not cfg_return["input"]["nodata_right"] == -7: raise AssertionError @@ -478,7 +478,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if not np.isnan(cfg_return["input"]["nodata_left"]) or not cfg_return["input"]["nodata_right"] == -9999: raise AssertionError @@ -494,7 +494,7 @@ def test_update_conf(): } } - cfg_return = JSON_checker.update_conf(JSON_checker.default_short_configuration_input, user_cfg) + cfg_return = check_configuration.update_conf(check_configuration.default_short_configuration_input, user_cfg) if not (cfg_return["input"]["nodata_left"] == -9999) or not np.isnan(cfg_return["input"]["nodata_right"]): raise AssertionError @@ -515,7 +515,7 @@ def test_check_conf(self): }, } - cfg_return = JSON_checker.check_conf(cfg, pandora_machine) + cfg_return = check_configuration.check_conf(cfg, pandora_machine) cfg_gt = { "input": { "nodata_left": -9999, @@ -549,7 +549,7 @@ def test_check_conf(self): "disparity": {"disparity_method": "wta"}, }, } - cfg_return = JSON_checker.check_conf(cfg, pandora_machine) + cfg_return = check_configuration.check_conf(cfg, pandora_machine) cfg_gt = { "input": { @@ -584,7 +584,7 @@ def test_check_conf(self): } # When left disparities are grids and right are none, cross checking method cannot be used : the program exits - self.assertRaises(SystemExit, JSON_checker.check_conf, cfg, pandora_machine) + self.assertRaises(SystemExit, check_configuration.check_conf, cfg, pandora_machine) # Check the configuration returned with left and right disparity grids and cross checking method cfg = { @@ -593,7 +593,7 @@ def test_check_conf(self): } # When left and right disparities are grids, cross checking method can be used pandora_machine = PandoraMachine() - cfg_return = JSON_checker.check_conf(cfg, pandora_machine) + cfg_return = check_configuration.check_conf(cfg, pandora_machine) cfg_gt = { "input": { "nodata_left": -9999, @@ -625,7 +625,7 @@ def test_check_conf(self): } # When left disparities are grids and multiscale processing cannot be used : the program exits - self.assertRaises(SystemExit, JSON_checker.check_conf, cfg, pandora_machine) + self.assertRaises(SystemExit, check_configuration.check_conf, cfg, pandora_machine) # Check the configuration returned with left disparity integer and multiscale processing pandora_machine = PandoraMachine() @@ -634,7 +634,7 @@ def test_check_conf(self): "pipeline": copy.deepcopy(common.multiscale_pipeline_cfg), } - cfg_return = JSON_checker.check_conf(cfg, pandora_machine) + cfg_return = check_configuration.check_conf(cfg, pandora_machine) cfg_gt = { "input": { @@ -675,12 +675,14 @@ def test_check_pipeline_section_with_error(self): } pandora_machine = PandoraMachine() - img_left = JSON_checker.get_metadata( + img_left = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) - img_right = JSON_checker.get_metadata(cfg["input"]["img_right"], None, None) + img_right = check_configuration.get_metadata(cfg["input"]["img_right"], None, None) - self.assertRaises(MachineError, JSON_checker.check_pipeline_section, cfg, img_left, img_right, pandora_machine) + self.assertRaises( + MachineError, check_configuration.check_pipeline_section, cfg, img_left, img_right, pandora_machine + ) @staticmethod def test_memory_consumption_estimation(): @@ -705,7 +707,7 @@ def test_memory_consumption_estimation(): pandora_machine = PandoraMachine() pipeline_cfg = {"pipeline": copy.deepcopy(common.basic_pipeline_cfg)} - min_mem_consump, max_mem_consump = JSON_checker.memory_consumption_estimation( + min_mem_consump, max_mem_consump = check_configuration.memory_consumption_estimation( pipeline_cfg, (img_left_path, disp_min, disp_max), pandora_machine ) np.testing.assert_allclose((min_mem_consump, max_mem_consump), consumption_vt, rtol=1e-02) @@ -713,7 +715,7 @@ def test_memory_consumption_estimation(): # Run memory_consumption_estimation giving the input parameters in a dict pandora_machine = PandoraMachine() input_cfg = {"input": copy.deepcopy(common.input_cfg_basic)} - min_mem_consump, max_mem_consump = JSON_checker.memory_consumption_estimation( + min_mem_consump, max_mem_consump = check_configuration.memory_consumption_estimation( pipeline_cfg, input_cfg, pandora_machine ) np.testing.assert_allclose((min_mem_consump, max_mem_consump), consumption_vt, rtol=1e-02) @@ -740,15 +742,15 @@ def test_memory_consumption_estimation_with_already_check_pipeline(): disp_max = 0 pandora_machine = PandoraMachine() cfg = {"input": copy.deepcopy(common.input_cfg_basic), "pipeline": copy.deepcopy(common.basic_pipeline_cfg)} - img_left = JSON_checker.get_metadata( + img_left = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) - img_right = JSON_checker.get_metadata(cfg["input"]["img_right"], None, None) + img_right = check_configuration.get_metadata(cfg["input"]["img_right"], None, None) # check pipeline before memory_consumption_estimation - pipeline_cfg = JSON_checker.check_pipeline_section(cfg, img_left, img_right, pandora_machine) + pipeline_cfg = check_configuration.check_pipeline_section(cfg, img_left, img_right, pandora_machine) - min_mem_consump, max_mem_consump = JSON_checker.memory_consumption_estimation( + min_mem_consump, max_mem_consump = check_configuration.memory_consumption_estimation( pipeline_cfg, (img_left_path, disp_min, disp_max), pandora_machine, True ) np.testing.assert_allclose((min_mem_consump, max_mem_consump), consumption_vt, rtol=1e-02) @@ -756,7 +758,7 @@ def test_memory_consumption_estimation_with_already_check_pipeline(): # Run memory_consumption_estimation giving the input parameters in a dict pandora_machine = PandoraMachine() input_cfg = {"input": copy.deepcopy(common.input_cfg_basic)} - min_mem_consump, max_mem_consump = JSON_checker.memory_consumption_estimation( + min_mem_consump, max_mem_consump = check_configuration.memory_consumption_estimation( pipeline_cfg, input_cfg, pandora_machine, True ) np.testing.assert_allclose((min_mem_consump, max_mem_consump), consumption_vt, rtol=1e-02) @@ -776,13 +778,15 @@ def test_right_disp_map_none_with_validation(self): "validation": {"validation_method": "cross_checking"}, }, } - img_left = JSON_checker.get_metadata( + img_left = check_configuration.get_metadata( cfg["input"]["img_left"], cfg["input"]["disp_min"], cfg["input"]["disp_max"] ) - img_right = JSON_checker.get_metadata(cfg["input"]["img_right"], None, None) + img_right = check_configuration.get_metadata(cfg["input"]["img_right"], None, None) pandora_machine = PandoraMachine() - self.assertRaises(MachineError, JSON_checker.check_pipeline_section, cfg, img_left, img_right, pandora_machine) + self.assertRaises( + MachineError, check_configuration.check_pipeline_section, cfg, img_left, img_right, pandora_machine + ) if __name__ == "__main__": diff --git a/tests/test_disparity.py b/tests/test_disparity.py index ee17e3c..99c4c81 100644 --- a/tests/test_disparity.py +++ b/tests/test_disparity.py @@ -304,7 +304,7 @@ def test_right_disparity_comparaison(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration pandora_left = read_img("tests/pandora/left.png", no_data=np.nan, mask=None) pandora_right = read_img("tests/pandora/right.png", no_data=np.nan, mask=None) @@ -321,7 +321,7 @@ def test_right_disparity_comparaison(): } pandora_machine_fast = PandoraMachine() - cfg = pandora.check_json.update_conf(default_cfg, fast_cfg) + cfg = pandora.check_configuration.update_conf(default_cfg, fast_cfg) left, right_fast = pandora.run( # pylint: disable=unused-variable pandora_machine_fast, pandora_left, pandora_right, -60, 0, cfg ) @@ -338,7 +338,7 @@ def test_right_disparity_comparaison(): } pandora_machine_acc = PandoraMachine() - cfg = pandora.check_json.update_conf(default_cfg, acc_cfg) + cfg = pandora.check_configuration.update_conf(default_cfg, acc_cfg) left, right_acc = pandora.run(pandora_machine_acc, pandora_left, pandora_right, -60, 0, cfg) # Check if the calculated disparity map in fast mode is equal to the disparity map in accurate mode np.testing.assert_array_equal(right_fast["disparity_map"].data, right_acc["disparity_map"].data) diff --git a/tests/test_filter.py b/tests/test_filter.py index 3af7c60..df0a1fc 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -238,10 +238,10 @@ def test_bilateral_gauss_spatial_kernel(): user_cfg = {"filter": {"filter_method": "bilateral", "sigma_color": 4.0, "sigma_space": 6.0}} # Build the default configuration - cfg = pandora.check_json.default_short_configuration + cfg = pandora.check_configuration.default_short_configuration # Update the configuration with default values - cfg = pandora.check_json.update_conf(cfg, user_cfg) + cfg = pandora.check_configuration.update_conf(cfg, user_cfg) filter_bilateral = flt.AbstractFilter(**cfg["filter"]) @@ -304,10 +304,10 @@ def test_bilateral_filter(): user_cfg = {"filter": {"filter_method": "bilateral", "sigma_color": 4.0, "sigma_space": 6.0}} # Build the default configuration - cfg = pandora.check_json.default_short_configuration + cfg = pandora.check_configuration.default_short_configuration # Update the configuration with default values - cfg = pandora.check_json.update_conf(cfg, user_cfg) + cfg = pandora.check_configuration.update_conf(cfg, user_cfg) filter_bilateral = flt.AbstractFilter(**cfg["filter"]) @@ -403,10 +403,10 @@ def test_bilateral_filter_with_nans(): user_cfg = {"filter": {"filter_method": "bilateral", "sigma_color": 4.0, "sigma_space": 6.0}} # Build the default configuration - cfg = pandora.check_json.default_short_configuration + cfg = pandora.check_configuration.default_short_configuration # Update the configuration with default values - cfg = pandora.check_json.update_conf(cfg, user_cfg) + cfg = pandora.check_configuration.update_conf(cfg, user_cfg) filter_bilateral = flt.AbstractFilter(**cfg["filter"]) @@ -552,10 +552,10 @@ def test_bilateral_filter_with_invalid_center(): user_cfg = {"filter": {"filter_method": "bilateral", "sigma_color": 4.0, "sigma_space": 6.0}} # Build the default configuration - cfg = pandora.check_json.default_short_configuration + cfg = pandora.check_configuration.default_short_configuration # Update the configuration with default values - cfg = pandora.check_json.update_conf(cfg, user_cfg) + cfg = pandora.check_configuration.update_conf(cfg, user_cfg) filter_bilateral = flt.AbstractFilter(**cfg["filter"]) disp = np.array( diff --git a/tests/test_pandora.py b/tests/test_pandora.py index c1e04f4..93cefeb 100644 --- a/tests/test_pandora.py +++ b/tests/test_pandora.py @@ -98,7 +98,7 @@ def test_run_with_validation(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, right = pandora.run(pandora_machine, self.left, self.right, -60, 0, cfg) @@ -129,7 +129,7 @@ def test_run_without_validation(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, right = pandora.run( # pylint: disable = unused-variable @@ -161,7 +161,7 @@ def test_run_2_scales(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, right = pandora.run(pandora_machine, self.left, self.right, -60, 0, cfg) @@ -196,7 +196,7 @@ def test_run_3_scales(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, right = pandora.run(pandora_machine, self.left, self.right, -60, 0, cfg) @@ -243,7 +243,7 @@ def test_multiechelles_and_confidence(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, right = pandora.run(pandora_machine, self.left, self.right, -60, 0, cfg) @@ -324,7 +324,7 @@ def test_confidence_measure(): pandora_machine = PandoraMachine() - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) import_plugin() # Run the Pandora pipeline @@ -455,7 +455,7 @@ def test_dataset_image(): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) left_img = read_img("tests/pandora/left.png", no_data=np.nan, mask=None) right_img = read_img("tests/pandora/right.png", no_data=np.nan, mask=None) @@ -521,7 +521,7 @@ def test_main_with_rgb_image(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_rgb, right_rgb, -60, 0, cfg) @@ -550,7 +550,7 @@ def test_main_with_rgb_image_and_mask(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_rgb, right_rgb, -60, 0, cfg) @@ -579,7 +579,7 @@ def test_multiscale_with_rgb_image_and_mask(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_rgb, right_rgb, -60, 0, cfg) @@ -608,7 +608,7 @@ def test_validation_with_rgb_image_and_mask(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline left, _ = pandora.run(pandora_machine, left_rgb, right_rgb, -60, 0, cfg) diff --git a/tests/test_pandora_image.py b/tests/test_pandora_image.py index 519e120..40cfc91 100644 --- a/tests/test_pandora_image.py +++ b/tests/test_pandora_image.py @@ -267,7 +267,7 @@ def test_read_img(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # left_img = array([[ -9999., 1., 2., 3., -9999.], # [ 5., 6., 7., 8., 9.], # [ -9999., -9999., 23., 5., 6.], @@ -353,7 +353,7 @@ def test_read_img_classif(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image # The classes present in left_classif are "cornfields", "olive tree", "forest" @@ -376,7 +376,7 @@ def test_read_img_rgb_classif(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image # The classes present in left_classif are "cornfields", "olive tree", "forest" @@ -403,7 +403,7 @@ def test_read_img_segm(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image dst_left = img_tools.read_img( @@ -446,7 +446,7 @@ def test_check_dataset(self): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image dst__correct = img_tools.read_img(img="tests/image/left_img.tif", no_data=default_cfg["input"]["nodata_left"]) @@ -494,7 +494,7 @@ def test_read_img_with_geotransform(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image dst_left = img_tools.read_img(img="tests/pandora/left.png", no_data=default_cfg["input"]["nodata_left"]) @@ -513,7 +513,7 @@ def test_read_img_without_geotransform(): """ # Build the default configuration - default_cfg = pandora.check_json.default_short_configuration + default_cfg = pandora.check_configuration.default_short_configuration # Computes the dataset image dst_left = img_tools.read_img(img="tests/image/left_img.tif", no_data=default_cfg["input"]["nodata_left"]) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 973918c..a529392 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -71,7 +71,7 @@ def test_run_with_semantic_segmentation(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline with self.assertRaises(KeyError) as error: @@ -101,7 +101,7 @@ def test_run_with_sgm_optimization(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline with self.assertRaises(KeyError) as error: @@ -126,7 +126,7 @@ def test_run_with_mc_cnn_matching_cost(self): pandora_machine = PandoraMachine() # Update the user configuration with default values - cfg = pandora.check_json.update_conf(pandora.check_json.default_short_configuration, user_cfg) + cfg = pandora.check_configuration.update_conf(pandora.check_configuration.default_short_configuration, user_cfg) # Run the pandora pipeline with self.assertRaises(KeyError) as error: