diff --git a/Makefile b/Makefile index d2ccaf5..d46632c 100644 --- a/Makefile +++ b/Makefile @@ -51,16 +51,16 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ lint: ## reformat with black and check style with flake8 - isort sensospot_data + isort sensospot_parser isort tests - black sensospot_data tests - flake8 --ignore E231,W503,E402 sensospot_data tests + black sensospot_parser tests + flake8 --ignore E231,W503,E402 sensospot_parser tests test: ## run tests quickly with the default Python pytest tests -x --disable-warnings --failed-first coverage: ## full test suite, check code coverage and open coverage report - pytest tests --cov=sensospot_data + pytest tests --cov=sensospot_parser coverage html $(BROWSER) htmlcov/index.html @@ -80,7 +80,7 @@ repo: devenv ## complete project setup with development environment and git repo git init . git add . git commit -m "import of project template" - git remote add origin https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_data.git + git remote add origin https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_parser.git git push -u origin master --no-verify .venv/bin/pre-commit install --install-hooks diff --git a/pyproject.toml b/pyproject.toml index b7dd605..47528c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,11 +3,11 @@ requires = ["flit"] build-backend = "flit.buildapi" [tool.flit.metadata] -module = "sensospot_data" -dist-name = "sensospot_data" +module = "sensospot_parser" +dist-name = "sensospot_parser" author = "Holger Frey" author-email = "frey@imtek.de" -home-page = "https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_data.git" +home-page = "https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_parser.git" description-file = "README.md" license = "Beerware" @@ -48,7 +48,7 @@ dev = [ ] [tool.flit.scripts] -sensospot_parse = "sensospot_data:main" +sensospot_parse = "sensospot_parser:main" [tool.black] line-length = 79 diff --git a/sensospot_data/__init__.py b/sensospot_parser/__init__.py similarity index 100% rename from sensospot_data/__init__.py rename to sensospot_parser/__init__.py diff --git a/sensospot_data/columns.py b/sensospot_parser/columns.py similarity index 100% rename from sensospot_data/columns.py rename to sensospot_parser/columns.py diff --git a/sensospot_data/parameters.py b/sensospot_parser/parameters.py similarity index 100% rename from sensospot_data/parameters.py rename to sensospot_parser/parameters.py diff --git a/sensospot_data/parser.py b/sensospot_parser/parser.py old mode 100755 new mode 100644 similarity index 100% rename from sensospot_data/parser.py rename to sensospot_parser/parser.py diff --git a/tests/conftest.py b/tests/conftest.py index ad4f5d7..e2ba728 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,7 +30,7 @@ def exposure_df(): @pytest.fixture def normalization_data_frame(): - from sensospot_data.columns import RAW_DATA_NORMALIZATION_MAP + from sensospot_parser.columns import RAW_DATA_NORMALIZATION_MAP overflow_test_values = [ (1, 1, 1, 50, 1, 0), @@ -92,14 +92,14 @@ def normalization_data_frame(): @pytest.fixture(scope="session") def parsed_data_frame_with_params(example_dir): - from sensospot_data.parser import parse_folder + from sensospot_parser.parser import parse_folder return parse_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS) @pytest.fixture(scope="session") def parsed_data_frame_without_params(example_dir): - from sensospot_data.parser import parse_folder + from sensospot_parser.parser import parse_folder return parse_folder(example_dir / EXAMPLE_DIR_WO_PARAMS) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index f2f8d1f..b91fd92 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -4,7 +4,7 @@ from .conftest import EXAMPLE_DIR_WO_PARAMS, EXAMPLE_DIR_WITH_PARAMS def test_search_params_file_ok(example_dir): - from sensospot_data.parameters import _search_params_file + from sensospot_parser.parameters import _search_params_file result = _search_params_file(example_dir / EXAMPLE_DIR_WITH_PARAMS) @@ -12,7 +12,7 @@ def test_search_params_file_ok(example_dir): def test_search_params_file_no_parameters_folder(example_dir): - from sensospot_data.parameters import _search_params_file + from sensospot_parser.parameters import _search_params_file result = _search_params_file(example_dir / EXAMPLE_DIR_WO_PARAMS) @@ -20,7 +20,7 @@ def test_search_params_file_no_parameters_folder(example_dir): def test_ssearch_measurement_params_file_parameters_file(tmpdir): - from sensospot_data.parameters import _search_params_file + from sensospot_parser.parameters import _search_params_file params_dir = tmpdir / "Parameters" params_dir.mkdir() @@ -31,7 +31,7 @@ def test_ssearch_measurement_params_file_parameters_file(tmpdir): def test_parse_channel_info(example_dir): - from sensospot_data.parameters import ( + from sensospot_parser.parameters import ( _search_params_file, _parse_measurement_params, ) @@ -51,7 +51,7 @@ def test_parse_channel_info(example_dir): def test_get_measurement_params_file_found(example_dir): - from sensospot_data.parameters import get_measurement_params + from sensospot_parser.parameters import get_measurement_params result = get_measurement_params(example_dir / EXAMPLE_DIR_WITH_PARAMS) @@ -67,7 +67,7 @@ def test_get_measurement_params_file_found(example_dir): def test_get_measurement_params_file_not_found(example_dir): - from sensospot_data.parameters import get_measurement_params + from sensospot_parser.parameters import get_measurement_params result = get_measurement_params(example_dir / EXAMPLE_DIR_WO_PARAMS) @@ -75,7 +75,7 @@ def test_get_measurement_params_file_not_found(example_dir): def test_add_measurement_parameters_with_params_file(exposure_df, example_dir): - from sensospot_data.parameters import add_measurement_parameters + from sensospot_parser.parameters import add_measurement_parameters folder = example_dir / EXAMPLE_DIR_WITH_PARAMS exposure_df = add_measurement_parameters(exposure_df, folder) @@ -91,7 +91,7 @@ def test_add_measurement_parameters_with_params_file(exposure_df, example_dir): def test_add_measurement_parameters_without_params_file( exposure_df, example_dir ): - from sensospot_data.parameters import add_measurement_parameters + from sensospot_parser.parameters import add_measurement_parameters folder = example_dir / EXAMPLE_DIR_WO_PARAMS exposure_df = add_measurement_parameters(exposure_df, folder) diff --git a/tests/test_parser.py b/tests/test_parser.py index 5e0853f..785e612 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -21,7 +21,7 @@ from .conftest import EXAMPLE_DIR_WO_PARAMS, EXAMPLE_DIR_WITH_PARAMS ], ) def test_parse_csv(example_dir, sub_dir, file_name): - from sensospot_data.parser import _parse_csv + from sensospot_parser.parser import _parse_csv result = _parse_csv(example_dir / sub_dir / file_name) @@ -56,7 +56,7 @@ def test_parse_csv(example_dir, sub_dir, file_name): def test_parse_csv_no_array(example_dir): - from sensospot_data.parser import _parse_csv + from sensospot_parser.parser import _parse_csv result = _parse_csv(example_dir / "no_array_A1_1.csv") @@ -70,7 +70,7 @@ def test_parse_csv_no_array(example_dir): def test_guess_decimal_separator_returns_correct_separator(input, expected): from io import StringIO - from sensospot_data.parser import _guess_decimal_separator + from sensospot_parser.parser import _guess_decimal_separator handle = StringIO(f"header\n{input}\n") result = _guess_decimal_separator(handle) @@ -81,7 +81,7 @@ def test_guess_decimal_separator_returns_correct_separator(input, expected): def test_guess_decimal_separator_rewinds_handle(): from io import StringIO - from sensospot_data.parser import _guess_decimal_separator + from sensospot_parser.parser import _guess_decimal_separator handle = StringIO("\n".join(["header", "data_line"])) _guess_decimal_separator(handle) @@ -90,7 +90,7 @@ def test_guess_decimal_separator_rewinds_handle(): def test_well_regex_ok(): - from sensospot_data.parser import REGEX_WELL + from sensospot_parser.parser import REGEX_WELL result = REGEX_WELL.match("AbC123") @@ -100,7 +100,7 @@ def test_well_regex_ok(): @pytest.mark.parametrize("input", ["", "A", "1", "1A", "-1", "A-"]) def test_well_regex_no_match(input): - from sensospot_data.parser import REGEX_WELL + from sensospot_parser.parser import REGEX_WELL result = REGEX_WELL.match(input) @@ -112,7 +112,7 @@ def test_well_regex_no_match(input): [("A1_1.csv", ("A", 1, 1)), ("test/measurement_1_H12_2", ("H", 12, 2))], ) def test_extract_measurement_info_ok(filename, expected): - from sensospot_data.parser import _extract_measurement_info + from sensospot_parser.parser import _extract_measurement_info result = _extract_measurement_info(filename) @@ -121,7 +121,7 @@ def test_extract_measurement_info_ok(filename, expected): @pytest.mark.parametrize("filename", ["wrong_exposure_A1_B", "no_well_XX_1"]) def test_extract_measurement_info_raises_error(filename): - from sensospot_data.parser import _extract_measurement_info + from sensospot_parser.parser import _extract_measurement_info with pytest.raises(ValueError): _extract_measurement_info(filename) @@ -130,7 +130,7 @@ def test_extract_measurement_info_raises_error(filename): def test_cleanup_data_columns(): from pandas import DataFrame - from sensospot_data.parser import _cleanup_data_columns + from sensospot_parser.parser import _cleanup_data_columns columns = ["Rect.", "Contour", " ID ", "Found", "Dia."] data = {col: [i] for i, col in enumerate(columns)} @@ -145,7 +145,7 @@ def test_cleanup_data_columns(): def test_parse_file(example_file): - from sensospot_data.parser import parse_file + from sensospot_parser.parser import parse_file result = parse_file(example_file) @@ -184,7 +184,7 @@ def test_parse_file(example_file): def test_parse_file_raises_error(example_dir): - from sensospot_data.parser import parse_file + from sensospot_parser.parser import parse_file csv_file = ( example_dir / EXAMPLE_DIR_WITH_PARAMS / "should_raise_value_error.csv" @@ -195,7 +195,7 @@ def test_parse_file_raises_error(example_dir): def test_parse_file_silenced_returns_data_frame(example_file): - from sensospot_data.parser import _parse_file_silenced + from sensospot_parser.parser import _parse_file_silenced result = _parse_file_silenced(example_file) @@ -205,7 +205,7 @@ def test_parse_file_silenced_returns_data_frame(example_file): def test_parse_file_silenced_returns_none_on_error(example_dir): - from sensospot_data.parser import _parse_file_silenced + from sensospot_parser.parser import _parse_file_silenced csv_file = ( example_dir / EXAMPLE_DIR_WITH_PARAMS / "should_raise_value_error.csv" @@ -227,7 +227,7 @@ def test_parse_file_silenced_returns_none_on_error(example_dir): ], ) def testparse_multiple_files_ok(example_dir, file_list): - from sensospot_data.parser import parse_multiple_files + from sensospot_parser.parser import parse_multiple_files sub_dir = example_dir / EXAMPLE_DIR_WO_PARAMS files = [sub_dir / file for file in file_list] @@ -240,14 +240,14 @@ def testparse_multiple_files_ok(example_dir, file_list): def testparse_multiple_files_empty_file_list(): - from sensospot_data.parser import parse_multiple_files + from sensospot_parser.parser import parse_multiple_files with pytest.raises(ValueError): parse_multiple_files([]) def testparse_multiple_files_empty_array(example_dir): - from sensospot_data.parser import parse_multiple_files + from sensospot_parser.parser import parse_multiple_files files = [example_dir / "no_array_A1_1.csv"] @@ -258,7 +258,7 @@ def testparse_multiple_files_empty_array(example_dir): def test_find_csv_files(example_dir): - from sensospot_data.parser import find_csv_files + from sensospot_parser.parser import find_csv_files result = list(find_csv_files(example_dir / EXAMPLE_DIR_WITH_PARAMS)) @@ -268,7 +268,7 @@ def test_find_csv_files(example_dir): def test_parse_folder(example_dir): - from sensospot_data.parser import parse_folder + from sensospot_parser.parser import parse_folder data_frame = parse_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS) @@ -282,7 +282,7 @@ def test_parse_folder(example_dir): def test_sanity_check_ok(example_dir): - from sensospot_data.parser import _sanity_check, parse_multiple_files + from sensospot_parser.parser import _sanity_check, parse_multiple_files sub_dir = example_dir / EXAMPLE_DIR_WO_PARAMS file_list = [ @@ -298,7 +298,7 @@ def test_sanity_check_ok(example_dir): def test_sanity_check_raises_value_error(example_dir): - from sensospot_data.parser import _sanity_check, parse_multiple_files + from sensospot_parser.parser import _sanity_check, parse_multiple_files sub_dir = example_dir / EXAMPLE_DIR_WO_PARAMS file_list = [ diff --git a/tests/test_sensospot_data.py b/tests/test_sensospot_data.py index 90e4cd6..549de0d 100644 --- a/tests/test_sensospot_data.py +++ b/tests/test_sensospot_data.py @@ -2,7 +2,7 @@ def test_import_api(): - from sensospot_data import main # noqa: F401 - from sensospot_data import columns # noqa: F401 - from sensospot_data import parse_file # noqa: F401 - from sensospot_data import parse_folder # noqa: F401 + from sensospot_parser import main # noqa: F401 + from sensospot_parser import columns # noqa: F401 + from sensospot_parser import parse_file # noqa: F401 + from sensospot_parser import parse_folder # noqa: F401