diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9b38853 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/README.md b/README.md index 5f75d5a..867373c 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To open a file: ```python import FourDimensionalData -data = FourDimensionalData("my_data.blo") +data = FourDimensionalData.from_file("my_data.blo") ``` ### Issues diff --git a/data4d/__init__.py b/data4d/__init__.py index bbc63af..25956a4 100644 --- a/data4d/__init__.py +++ b/data4d/__init__.py @@ -1,3 +1,8 @@ +from pathlib import Path + from .TVIPS import TVIPS from .base import FourDimensionalData from .blockfile import BLO + +__version__ = open(Path(__file__).parent.joinpath("VERSION")).read().strip() +__all__ = ["FourDimensionalData", "BLO", "TVIPS"] diff --git a/data4d/base.py b/data4d/base.py index 47f4b63..026e778 100644 --- a/data4d/base.py +++ b/data4d/base.py @@ -421,10 +421,10 @@ def from_file(fname: Union[str, Path]) -> FourDimensionalData: handler = {"blo": BLO, "tvips": TVIPS} fname = Path(fname) - ext = fname.suffix.strip(os.extsep) + ext = fname.suffix.strip(os.extsep).lower() if ext not in handler: - raise TypeError( + raise ValueError( f"File format not supported. Supported formats are: {handler.keys()}." ) return handler[ext](fname) diff --git a/setup.cfg b/setup.cfg index 9fb17f6..5af8133 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 -description = Parsers for Four Dimensional Electron Microscopy Data +description = Parsers, Classes, and Functions for Four Dimensional Electron Microscopy Data long_description = file: README.md keywords = electron microcopy, diffraction, multi-dimensional data license_files = diff --git a/tests/test_import.py b/tests/test_import.py new file mode 100644 index 0000000..5cbb9e3 --- /dev/null +++ b/tests/test_import.py @@ -0,0 +1,5 @@ +def test_version(): + from data4d import __version__ + from packaging.version import parse + + assert parse(__version__) >= parse("0.1.0")