|
|
@ -68,9 +68,10 @@ 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 sensospot_data.parser import _guess_decimal_separator |
|
|
|
|
|
|
|
from io import StringIO |
|
|
|
from io import StringIO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from sensospot_data.parser import _guess_decimal_separator |
|
|
|
|
|
|
|
|
|
|
|
handle = StringIO(f"header\n{input}\n") |
|
|
|
handle = StringIO(f"header\n{input}\n") |
|
|
|
result = _guess_decimal_separator(handle) |
|
|
|
result = _guess_decimal_separator(handle) |
|
|
|
|
|
|
|
|
|
|
@ -78,9 +79,10 @@ 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 sensospot_data.parser import _guess_decimal_separator |
|
|
|
|
|
|
|
from io import StringIO |
|
|
|
from io import StringIO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from sensospot_data.parser import _guess_decimal_separator |
|
|
|
|
|
|
|
|
|
|
|
handle = StringIO("\n".join(["header", "data_line"])) |
|
|
|
handle = StringIO("\n".join(["header", "data_line"])) |
|
|
|
_guess_decimal_separator(handle) |
|
|
|
_guess_decimal_separator(handle) |
|
|
|
|
|
|
|
|
|
|
@ -126,9 +128,10 @@ def test_extract_measurement_info_raises_error(filename): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_cleanup_data_columns(): |
|
|
|
def test_cleanup_data_columns(): |
|
|
|
from sensospot_data.parser import _cleanup_data_columns |
|
|
|
|
|
|
|
from pandas import DataFrame |
|
|
|
from pandas import DataFrame |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from sensospot_data.parser import _cleanup_data_columns |
|
|
|
|
|
|
|
|
|
|
|
columns = ["Rect.", "Contour", " ID ", "Found", "Dia."] |
|
|
|
columns = ["Rect.", "Contour", " ID ", "Found", "Dia."] |
|
|
|
data = {col: [i] for i, col in enumerate(columns)} |
|
|
|
data = {col: [i] for i, col in enumerate(columns)} |
|
|
|
data_frame = DataFrame(data=data) |
|
|
|
data_frame = DataFrame(data=data) |
|
|
@ -274,8 +277,8 @@ def test_sanity_check_raises_value_error(example_dir): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_cache_table_name(): |
|
|
|
def test_get_cache_table_name(): |
|
|
|
from sensospot_data.parser import _get_cache_table_name |
|
|
|
|
|
|
|
from sensospot_data import VERSION_TABLE_NAME |
|
|
|
from sensospot_data import VERSION_TABLE_NAME |
|
|
|
|
|
|
|
from sensospot_data.parser import _get_cache_table_name |
|
|
|
|
|
|
|
|
|
|
|
result = _get_cache_table_name() |
|
|
|
result = _get_cache_table_name() |
|
|
|
|
|
|
|
|
|
|
@ -283,7 +286,7 @@ def test_get_cache_table_name(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_process_folder_creates_cache(dir_for_caching): |
|
|
|
def test_process_folder_creates_cache(dir_for_caching): |
|
|
|
from sensospot_data.parser import process_folder, CACHE_FILE_NAME |
|
|
|
from sensospot_data.parser import CACHE_FILE_NAME, process_folder |
|
|
|
|
|
|
|
|
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
|
assert not cache_path.is_file() |
|
|
|
assert not cache_path.is_file() |
|
|
@ -309,7 +312,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 sensospot_data.parser import process_folder, CACHE_FILE_NAME |
|
|
|
from sensospot_data.parser import CACHE_FILE_NAME, process_folder |
|
|
|
|
|
|
|
|
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
|
exposure_df.to_hdf(cache_path, "unknown table") |
|
|
|
exposure_df.to_hdf(cache_path, "unknown table") |
|
|
@ -321,9 +324,9 @@ def test_process_folder_read_cache_fails_silently( |
|
|
|
|
|
|
|
|
|
|
|
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 sensospot_data.parser import ( |
|
|
|
from sensospot_data.parser import ( |
|
|
|
|
|
|
|
CACHE_FILE_NAME, |
|
|
|
process_folder, |
|
|
|
process_folder, |
|
|
|
_get_cache_table_name, |
|
|
|
_get_cache_table_name, |
|
|
|
CACHE_FILE_NAME, |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
|
cache_path = dir_for_caching / CACHE_FILE_NAME |
|
|
@ -335,7 +338,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 sensospot_data.parser import process_folder, CACHE_FILE_NAME |
|
|
|
from sensospot_data.parser import CACHE_FILE_NAME, process_folder |
|
|
|
|
|
|
|
|
|
|
|
process_folder(dir_for_caching, use_cache=True) |
|
|
|
process_folder(dir_for_caching, use_cache=True) |
|
|
|
|
|
|
|
|
|
|
@ -344,7 +347,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 sensospot_data.parser import process_folder, CACHE_FILE_NAME |
|
|
|
from sensospot_data.parser import CACHE_FILE_NAME, process_folder |
|
|
|
|
|
|
|
|
|
|
|
process_folder(dir_for_caching, use_cache=False) |
|
|
|
process_folder(dir_for_caching, use_cache=False) |
|
|
|
|
|
|
|
|
|
|
|