Browse Source

renamed project

xmlparsing
Holger Frey 5 years ago
parent
commit
ec1d7bd8f3
  1. 6
      .pre-commit-config.yaml
  2. 12
      Makefile
  3. 6
      pyproject.toml
  4. 0
      sensospot_data/__init__.py
  5. 0
      sensospot_data/parser.py
  6. 72
      tests/test_parser.py
  7. 10
      tests/test_sensovation_data_parser.py

6
.pre-commit-config.yaml

@ -12,7 +12,7 @@ repos:
hooks: hooks:
- id: isort-project - id: isort-project
name: isort_project name: isort_project
entry: isort -rc sensovation_data_parser entry: isort -rc sensospot_data
language: system language: system
pass_filenames: false pass_filenames: false
- id: isort-test - id: isort-test
@ -22,12 +22,12 @@ repos:
pass_filenames: false pass_filenames: false
- id: black - id: black
name: black name: black
entry: black sensovation_data_parser tests entry: black sensospot_data tests
language: system language: system
pass_filenames: false pass_filenames: false
- id: flake8 - id: flake8
name: flake8 name: flake8
entry: flake8 --ignore E231 sensovation_data_parser tests entry: flake8 --ignore E231 sensospot_data tests
language: system language: system
pass_filenames: false pass_filenames: false
- id: pytest - id: pytest

12
Makefile

@ -51,16 +51,16 @@ clean-test: ## remove test and coverage artifacts
rm -fr htmlcov/ rm -fr htmlcov/
lint: ## reformat with black and check style with flake8 lint: ## reformat with black and check style with flake8
isort -rc sensovation_data_parser isort -rc sensospot_data
isort -rc tests isort -rc tests
black sensovation_data_parser tests black sensospot_data tests
flake8 --ignore E231 sensovation_data_parser tests flake8 --ignore E231 sensospot_data tests
test: ## run tests quickly with the default Python test: ## run tests quickly with the default Python
pytest tests -x --disable-warnings -k "not app" pytest tests -x --disable-warnings -k "not app"
coverage: ## full test suite, check code coverage and open coverage report coverage: ## full test suite, check code coverage and open coverage report
pytest tests --cov=sensovation_data_parser pytest tests --cov=sensospot_data
coverage html coverage html
$(BROWSER) htmlcov/index.html $(BROWSER) htmlcov/index.html
@ -71,7 +71,7 @@ install: ## install updated project.toml with flint
flit install --pth-file flit install --pth-file
devenv: ## setup development environment devenv: ## setup development environment
python3 -m venv --prompt sensovation .venv python3 -m venv --prompt sensospot .venv
.venv/bin/pip3 install --upgrade pip .venv/bin/pip3 install --upgrade pip
.venv/bin/pip3 install flit .venv/bin/pip3 install flit
.venv/bin/flit install --pth-file .venv/bin/flit install --pth-file
@ -80,7 +80,7 @@ repo: devenv ## complete project setup with development environment and git repo
git init . git init .
git add . git add .
git commit -m "import of project template" git commit -m "import of project template"
git remote add origin https://git.cpi.imtek.uni-freiburg.de/holgi/sensovation-data-parser.git git remote add origin https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_data.git
git push -u origin master --no-verify git push -u origin master --no-verify
.venv/bin/pre-commit install --install-hooks .venv/bin/pre-commit install --install-hooks

6
pyproject.toml

@ -3,11 +3,11 @@ requires = ["flit"]
build-backend = "flit.buildapi" build-backend = "flit.buildapi"
[tool.flit.metadata] [tool.flit.metadata]
module = "sensovation_data_parser" module = "sensospot_data"
dist-name = "sensovation_data_parser" dist-name = "sensospot_data"
author = "Holger Frey" author = "Holger Frey"
author-email = "frey@imtek.de" author-email = "frey@imtek.de"
home-page = "https://github.com/holgi/sensovation_data_parser" home-page = "https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_data.git"
description-file = "README.md" description-file = "README.md"
license = "Beerware" license = "Beerware"

0
sensovation_data_parser/__init__.py → sensospot_data/__init__.py

0
sensovation_data_parser/parser.py → sensospot_data/parser.py

72
tests/test_parser.py

@ -52,7 +52,7 @@ def dir_for_caching(tmpdir, example_file):
], ],
) )
def test_parse_csv(example_dir, sub_dir, file_name): def test_parse_csv(example_dir, sub_dir, file_name):
from sensovation_data_parser.parser import _parse_csv from sensospot_data.parser import _parse_csv
result = _parse_csv(example_dir / sub_dir / file_name) result = _parse_csv(example_dir / sub_dir / file_name)
@ -87,7 +87,7 @@ def test_parse_csv(example_dir, sub_dir, file_name):
def test_parse_csv_no_array(example_dir): def test_parse_csv_no_array(example_dir):
from sensovation_data_parser.parser import _parse_csv from sensospot_data.parser import _parse_csv
result = _parse_csv(example_dir / "no_array_A1_1.csv") result = _parse_csv(example_dir / "no_array_A1_1.csv")
@ -99,7 +99,7 @@ def test_parse_csv_no_array(example_dir):
"input, expected", [("", "."), ("..,", "."), (".,,", ","), ("..,,", "."),] "input, expected", [("", "."), ("..,", "."), (".,,", ","), ("..,,", "."),]
) )
def test_guess_decimal_separator_returns_correct_separator(input, expected): def test_guess_decimal_separator_returns_correct_separator(input, expected):
from sensovation_data_parser.parser import _guess_decimal_separator from sensospot_data.parser import _guess_decimal_separator
from io import StringIO from io import StringIO
handle = StringIO(f"header\n{input}\n") handle = StringIO(f"header\n{input}\n")
@ -109,7 +109,7 @@ def test_guess_decimal_separator_returns_correct_separator(input, expected):
def test_guess_decimal_separator_rewinds_handle(): def test_guess_decimal_separator_rewinds_handle():
from sensovation_data_parser.parser import _guess_decimal_separator from sensospot_data.parser import _guess_decimal_separator
from io import StringIO from io import StringIO
handle = StringIO(f"header\n{input}\n") handle = StringIO(f"header\n{input}\n")
@ -119,7 +119,7 @@ def test_guess_decimal_separator_rewinds_handle():
def test_well_regex_ok(): def test_well_regex_ok():
from sensovation_data_parser.parser import REGEX_WELL from sensospot_data.parser import REGEX_WELL
result = REGEX_WELL.match("AbC123") result = REGEX_WELL.match("AbC123")
@ -129,7 +129,7 @@ def test_well_regex_ok():
@pytest.mark.parametrize("input", ["", "A", "1", "1A", "-1", "A-"]) @pytest.mark.parametrize("input", ["", "A", "1", "1A", "-1", "A-"])
def test_well_regex_no_match(input): def test_well_regex_no_match(input):
from sensovation_data_parser.parser import REGEX_WELL from sensospot_data.parser import REGEX_WELL
result = REGEX_WELL.match(input) result = REGEX_WELL.match(input)
@ -141,7 +141,7 @@ def test_well_regex_no_match(input):
[("A1_1.csv", ("A", 1, 1)), ("test/measurement_1_H12_2", ("H", 12, 2)),], [("A1_1.csv", ("A", 1, 1)), ("test/measurement_1_H12_2", ("H", 12, 2)),],
) )
def test_extract_measurement_info_ok(filename, expected): def test_extract_measurement_info_ok(filename, expected):
from sensovation_data_parser.parser import _extract_measurement_info from sensospot_data.parser import _extract_measurement_info
result = _extract_measurement_info(filename) result = _extract_measurement_info(filename)
@ -150,14 +150,14 @@ def test_extract_measurement_info_ok(filename, expected):
@pytest.mark.parametrize("filename", ["wrong_exposure_A1_B", "no_well_XX_1"]) @pytest.mark.parametrize("filename", ["wrong_exposure_A1_B", "no_well_XX_1"])
def test_extract_measurement_info_raises_error(filename): def test_extract_measurement_info_raises_error(filename):
from sensovation_data_parser.parser import _extract_measurement_info from sensospot_data.parser import _extract_measurement_info
with pytest.raises(ValueError): with pytest.raises(ValueError):
_extract_measurement_info(filename) _extract_measurement_info(filename)
def test_cleanup_data_columns(): def test_cleanup_data_columns():
from sensovation_data_parser.parser import _cleanup_data_columns from sensospot_data.parser import _cleanup_data_columns
from pandas import DataFrame from pandas import DataFrame
columns = ["Rect.", "Contour", " ID ", "Found", "Dia."] columns = ["Rect.", "Contour", " ID ", "Found", "Dia."]
@ -173,7 +173,7 @@ def test_cleanup_data_columns():
def test_parse_file(example_file): def test_parse_file(example_file):
from sensovation_data_parser.parser import parse_file from sensospot_data.parser import parse_file
result = parse_file(example_file) result = parse_file(example_file)
@ -218,7 +218,7 @@ def test_parse_file(example_file):
], ],
) )
def testparse_multiple_files_ok(example_dir, file_list): def testparse_multiple_files_ok(example_dir, file_list):
from sensovation_data_parser.parser import parse_multiple_files from sensospot_data.parser import parse_multiple_files
sub_dir = example_dir / EXAMPLE_DIR_WO_PARAMS sub_dir = example_dir / EXAMPLE_DIR_WO_PARAMS
files = [sub_dir / file for file in file_list] files = [sub_dir / file for file in file_list]
@ -231,14 +231,14 @@ def testparse_multiple_files_ok(example_dir, file_list):
def testparse_multiple_files_empty_file_list(): def testparse_multiple_files_empty_file_list():
from sensovation_data_parser.parser import parse_multiple_files from sensospot_data.parser import parse_multiple_files
with pytest.raises(ValueError): with pytest.raises(ValueError):
parse_multiple_files([]) parse_multiple_files([])
def testparse_multiple_files_empty_array(example_dir): def testparse_multiple_files_empty_array(example_dir):
from sensovation_data_parser.parser import parse_multiple_files from sensospot_data.parser import parse_multiple_files
files = [example_dir / "no_array_A1_1.csv"] files = [example_dir / "no_array_A1_1.csv"]
@ -249,7 +249,7 @@ def testparse_multiple_files_empty_array(example_dir):
def test_list_csv_files(example_dir): def test_list_csv_files(example_dir):
from sensovation_data_parser.parser import _list_csv_files from sensospot_data.parser import _list_csv_files
result = list(_list_csv_files(example_dir / EXAMPLE_DIR_WITH_PARAMS)) result = list(_list_csv_files(example_dir / EXAMPLE_DIR_WITH_PARAMS))
@ -259,7 +259,7 @@ def test_list_csv_files(example_dir):
def test_parse_folder(example_dir): def test_parse_folder(example_dir):
from sensovation_data_parser.parser import parse_folder from sensospot_data.parser import parse_folder
data_frame = parse_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS) data_frame = parse_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS)
@ -271,7 +271,7 @@ def test_parse_folder(example_dir):
def test_sanity_check_ok(example_dir): def test_sanity_check_ok(example_dir):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
_sanity_check, _sanity_check,
parse_multiple_files, parse_multiple_files,
) )
@ -290,7 +290,7 @@ def test_sanity_check_ok(example_dir):
def test_sanity_check_raises_value_error(example_dir): def test_sanity_check_raises_value_error(example_dir):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
_sanity_check, _sanity_check,
parse_multiple_files, parse_multiple_files,
) )
@ -309,7 +309,7 @@ def test_sanity_check_raises_value_error(example_dir):
def test_search_channel_info_file_ok(example_dir): def test_search_channel_info_file_ok(example_dir):
from sensovation_data_parser.parser import _search_channel_info_file from sensospot_data.parser import _search_channel_info_file
result = _search_channel_info_file(example_dir / EXAMPLE_DIR_WITH_PARAMS) result = _search_channel_info_file(example_dir / EXAMPLE_DIR_WITH_PARAMS)
@ -317,7 +317,7 @@ def test_search_channel_info_file_ok(example_dir):
def test_search_channel_info_file_no_parameters_folder(example_dir): def test_search_channel_info_file_no_parameters_folder(example_dir):
from sensovation_data_parser.parser import _search_channel_info_file from sensospot_data.parser import _search_channel_info_file
result = _search_channel_info_file(example_dir / EXAMPLE_DIR_WO_PARAMS) result = _search_channel_info_file(example_dir / EXAMPLE_DIR_WO_PARAMS)
@ -325,7 +325,7 @@ def test_search_channel_info_file_no_parameters_folder(example_dir):
def test_search_channel_info_file_no_parameters_file(tmpdir): def test_search_channel_info_file_no_parameters_file(tmpdir):
from sensovation_data_parser.parser import _search_channel_info_file from sensospot_data.parser import _search_channel_info_file
params_dir = tmpdir / "Parameters" params_dir = tmpdir / "Parameters"
params_dir.mkdir() params_dir.mkdir()
@ -336,7 +336,7 @@ def test_search_channel_info_file_no_parameters_file(tmpdir):
def test_parse_channel_info(example_dir): def test_parse_channel_info(example_dir):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
_search_channel_info_file, _search_channel_info_file,
_parse_channel_info, _parse_channel_info,
) )
@ -351,7 +351,7 @@ def test_parse_channel_info(example_dir):
def test_get_valid_exposure_map_provided_ok(exposure_df): def test_get_valid_exposure_map_provided_ok(exposure_df):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
_get_valid_exposure_map, _get_valid_exposure_map,
ExposureInfo, ExposureInfo,
) )
@ -367,7 +367,7 @@ def test_get_valid_exposure_map_provided_ok(exposure_df):
def test_get_valid_exposure_map_provided_not_ok(exposure_df): def test_get_valid_exposure_map_provided_not_ok(exposure_df):
from sensovation_data_parser.parser import _get_valid_exposure_map from sensospot_data.parser import _get_valid_exposure_map
exposure_map = {1: None, 2: None} exposure_map = {1: None, 2: None}
@ -380,7 +380,7 @@ def test_get_valid_exposure_map_provided_not_ok(exposure_df):
def test_get_valid_exposure_map_info_from_file_ok(example_dir, exposure_df): def test_get_valid_exposure_map_info_from_file_ok(example_dir, exposure_df):
from sensovation_data_parser.parser import _get_valid_exposure_map from sensospot_data.parser import _get_valid_exposure_map
result = _get_valid_exposure_map( result = _get_valid_exposure_map(
example_dir / EXAMPLE_DIR_WITH_PARAMS, exposure_df, exposure_map=None example_dir / EXAMPLE_DIR_WITH_PARAMS, exposure_df, exposure_map=None
@ -395,7 +395,7 @@ def test_get_valid_exposure_map_info_from_file_ok(example_dir, exposure_df):
def test_get_valid_exposure_map_info_from_file_not_ok( def test_get_valid_exposure_map_info_from_file_not_ok(
example_dir, exposure_df example_dir, exposure_df
): ):
from sensovation_data_parser.parser import _get_valid_exposure_map from sensospot_data.parser import _get_valid_exposure_map
data_frame = exposure_df.drop(exposure_df.index[1]) data_frame = exposure_df.drop(exposure_df.index[1])
@ -408,7 +408,7 @@ def test_get_valid_exposure_map_info_from_file_not_ok(
def test_augment_exposure_map(exposure_df): def test_augment_exposure_map(exposure_df):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
_augment_exposure_map, _augment_exposure_map,
ExposureInfo, ExposureInfo,
) )
@ -433,7 +433,7 @@ def test_augment_exposure_map(exposure_df):
def test_process_folder_with_exposure_map(example_dir): def test_process_folder_with_exposure_map(example_dir):
from sensovation_data_parser.parser import _process_folder from sensospot_data.parser import _process_folder
result = _process_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS) result = _process_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS)
@ -448,7 +448,7 @@ def test_process_folder_with_exposure_map(example_dir):
def test_process_folder_without_exposure_map(example_dir): def test_process_folder_without_exposure_map(example_dir):
from sensovation_data_parser.parser import _process_folder from sensospot_data.parser import _process_folder
from pandas import isnull from pandas import isnull
result = _process_folder(example_dir / EXAMPLE_DIR_WO_PARAMS) result = _process_folder(example_dir / EXAMPLE_DIR_WO_PARAMS)
@ -464,7 +464,7 @@ def test_process_folder_without_exposure_map(example_dir):
def test_process_folder_creates_cache(dir_for_caching): def test_process_folder_creates_cache(dir_for_caching):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
process_folder, process_folder,
CACHE_FILE_NAME, CACHE_FILE_NAME,
) )
@ -479,7 +479,7 @@ def test_process_folder_creates_cache(dir_for_caching):
def test_process_folder_reads_from_cache(dir_for_caching, example_file): def test_process_folder_reads_from_cache(dir_for_caching, example_file):
from sensovation_data_parser.parser import process_folder from sensospot_data.parser import process_folder
process_folder(dir_for_caching) process_folder(dir_for_caching)
@ -493,7 +493,7 @@ def test_process_folder_reads_from_cache(dir_for_caching, example_file):
def test_process_folder_read_cache_fails_silently( def test_process_folder_read_cache_fails_silently(
dir_for_caching, exposure_df dir_for_caching, exposure_df
): ):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
process_folder, process_folder,
CACHE_FILE_NAME, CACHE_FILE_NAME,
) )
@ -507,8 +507,8 @@ def test_process_folder_read_cache_fails_silently(
def test_get_cache_table_name(): def test_get_cache_table_name():
from sensovation_data_parser.parser import _get_cache_table_name from sensospot_data.parser import _get_cache_table_name
from sensovation_data_parser import __version__ from sensospot_data import __version__
result = _get_cache_table_name() result = _get_cache_table_name()
@ -517,7 +517,7 @@ def test_get_cache_table_name():
def test_process_folder_read_cache_no_cache_arg(dir_for_caching, exposure_df): def test_process_folder_read_cache_no_cache_arg(dir_for_caching, exposure_df):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
process_folder, process_folder,
_get_cache_table_name, _get_cache_table_name,
CACHE_FILE_NAME, CACHE_FILE_NAME,
@ -532,7 +532,7 @@ def test_process_folder_read_cache_no_cache_arg(dir_for_caching, exposure_df):
def test_process_folder_writes_cache(dir_for_caching): def test_process_folder_writes_cache(dir_for_caching):
from sensovation_data_parser.parser import ( from sensospot_data.parser import (
process_folder, process_folder,
CACHE_FILE_NAME, CACHE_FILE_NAME,
) )
@ -544,7 +544,7 @@ def test_process_folder_writes_cache(dir_for_caching):
def test_process_folder_writes_cache_no_cache_arg(dir_for_caching): def test_process_folder_writes_cache_no_cache_arg(dir_for_caching):
from sensovation_data_parser.parser import process_folder, CACHE_FILE_NAME from sensospot_data.parser import process_folder, CACHE_FILE_NAME
process_folder(dir_for_caching, use_cache=False) process_folder(dir_for_caching, use_cache=False)

10
tests/test_sensovation_data_parser.py

@ -2,8 +2,8 @@
def test_import_api(): def test_import_api():
from sensovation_data_parser import ExposureInfo # noqa: F401 from sensospot_data import ExposureInfo # noqa: F401
from sensovation_data_parser import parse_file # noqa: F401 from sensospot_data import parse_file # noqa: F401
from sensovation_data_parser import parse_multiple_files # noqa: F401 from sensospot_data import parse_multiple_files # noqa: F401
from sensovation_data_parser import parse_folder # noqa: F401 from sensospot_data import parse_folder # noqa: F401
from sensovation_data_parser import process_folder # noqa: F401 from sensospot_data import process_folder # noqa: F401

Loading…
Cancel
Save