From cc08e94bc1f39c553b30e6fd27ecd237be27aaab Mon Sep 17 00:00:00 2001 From: Avinash Anand <36325275+anand-avinash@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:31:58 +0100 Subject: [PATCH] brought tests dir from brahmap/ to root; updated github workflow for pytest; updated package discovery in pyproject.toml --- .github/workflows/tests.yaml | 34 +++++++++++++++++++ MANIFEST.in | 4 +++ README.md | 2 +- brahmap/src/__init__.py | 0 brahmap/src/process_samples.cpp | 28 +++++++-------- brahmap/utilities/__init__.py | 10 ++++-- docs/index.md | 2 +- pyproject.toml | 7 ++-- .../helper_BlkDiagPrecondLO.py | 0 {brahmap/tests => tests}/helper_SparseLO.py | 0 .../tests => tests}/helper_initweigths.py | 0 {brahmap/tests => tests}/helper_repixelize.py | 0 .../test_BlkDiagPrecondLO_tools_cpp.py | 0 .../test_SparseLO_tools_cpp.py | 0 .../test_process_samples_cpp.py | 0 .../tests => tests}/test_repixelize_cpp.py | 0 16 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/tests.yaml create mode 100644 brahmap/src/__init__.py rename {brahmap/tests => tests}/helper_BlkDiagPrecondLO.py (100%) rename {brahmap/tests => tests}/helper_SparseLO.py (100%) rename {brahmap/tests => tests}/helper_initweigths.py (100%) rename {brahmap/tests => tests}/helper_repixelize.py (100%) rename {brahmap/tests => tests}/test_BlkDiagPrecondLO_tools_cpp.py (100%) rename {brahmap/tests => tests}/test_SparseLO_tools_cpp.py (100%) rename {brahmap/tests => tests}/test_process_samples_cpp.py (100%) rename {brahmap/tests => tests}/test_repixelize_cpp.py (100%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..483c445 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,34 @@ +### Running pytest + +name: BrahMap testing +on: + push: + branches: + - main +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install BrahMap + env: + CC: gcc-10 + CXX: g++-10 + run: | + python -m pip install --upgrade pip + python -m pip install . + - name: Test BrahMap with pytest + run: | + pytest diff --git a/MANIFEST.in b/MANIFEST.in index eff8add..27bba1b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,5 @@ recursive-include extern * +recursive-include tests * +global-exclude */__pycache__/* +global-exclude *.pyc +global-exclude */.pytest_cache/* diff --git a/README.md b/README.md index 698a5ec..93ce25f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ for a completer reference to `BrahMap` API. ```shell # Clone the repository -git clone https://github.com/anand-avinash/BrahMap.git +git clone --recursive https://github.com/anand-avinash/BrahMap.git cd BrahMap diff --git a/brahmap/src/__init__.py b/brahmap/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/brahmap/src/process_samples.cpp b/brahmap/src/process_samples.cpp index 603d269..bcc5d81 100644 --- a/brahmap/src/process_samples.cpp +++ b/brahmap/src/process_samples.cpp @@ -209,19 +209,19 @@ get_mask_pol(int pol, py::array_t counts, PYBIND11_MODULE(process_samples, m) { m.doc() = "process_samples"; - m.def("py_process_pol1", &process_pol1, "test"); - m.def("py_process_pol1", &process_pol1, "test"); - m.def("py_process_pol1", &process_pol1, "test"); - m.def("py_process_pol1", &process_pol1, "test"); - m.def("py_process_pol2", &process_pol2, "test"); - m.def("py_process_pol2", &process_pol2, "test"); - m.def("py_process_pol2", &process_pol2, "test"); - m.def("py_process_pol2", &process_pol2, "test"); + m.def("py_process_pol1", &process_pol1, "test"); + m.def("py_process_pol1", &process_pol1, "test"); + m.def("py_process_pol1", &process_pol1, "test"); + m.def("py_process_pol1", &process_pol1, "test"); + m.def("py_process_pol2", &process_pol2, "test"); + m.def("py_process_pol2", &process_pol2, "test"); + m.def("py_process_pol2", &process_pol2, "test"); + m.def("py_process_pol2", &process_pol2, "test"); // m.def("py_process_pol3", &process_pol3, "test"); - m.def("py_process_pol3", &process_pol3, "test"); - m.def("py_process_pol3", &process_pol3, "test"); - m.def("py_process_pol3", &process_pol3, "test"); - m.def("py_process_pol3", &process_pol3, "test"); - m.def("py_get_mask_pol", &get_mask_pol<_Float32>, "test"); - m.def("py_get_mask_pol", &get_mask_pol<_Float64>, "test"); + m.def("py_process_pol3", &process_pol3, "test"); + m.def("py_process_pol3", &process_pol3, "test"); + m.def("py_process_pol3", &process_pol3, "test"); + m.def("py_process_pol3", &process_pol3, "test"); + m.def("py_get_mask_pol", &get_mask_pol, "test"); + m.def("py_get_mask_pol", &get_mask_pol, "test"); } diff --git a/brahmap/utilities/__init__.py b/brahmap/utilities/__init__.py index e81c9a6..16e64d8 100644 --- a/brahmap/utilities/__init__.py +++ b/brahmap/utilities/__init__.py @@ -19,8 +19,14 @@ ) from .process_ces import ProcessTimeSamples -from .lbsim_interface import lbs_process_timesamples +from importlib.util import find_spec + +# suggestion taken from: +if find_spec("litebird_sim") is not None: + import_str = "lbs_process_timesamples" +else: + import_str = None __all__ = [ "is_sorted", @@ -36,5 +42,5 @@ "subscan_resize", "system_setup", "ProcessTimeSamples", - "lbs_process_timesamples", + import_str, ] diff --git a/docs/index.md b/docs/index.md index c355c23..8e4eedb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,7 +23,7 @@ for a completer reference to `BrahMap` API. ```shell # Clone the repository -git clone https://github.com/anand-avinash/BrahMap.git +git clone --recursive https://github.com/anand-avinash/BrahMap.git cd BrahMap diff --git a/pyproject.toml b/pyproject.toml index cb506e5..e06f6eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ requires-python = ">=3.9,<3.13" dependencies = [ "numpy", "scipy", + "healpy", "krypy", "ruff", "pre-commit", @@ -32,8 +33,10 @@ Documentation = "https://anand-avinash.github.io/BrahMap/" Issues = "https://github.com/anand-avinash/BrahMap/issues" # Changelog = -[tool.setuptools] -packages = ["brahmap"] +[tool.setuptools.packages.find] +where = ["."] +include = ["brahmap*"] +namespaces = false [tool.pytest.ini_options] norecursedirs = ["extern"] diff --git a/brahmap/tests/helper_BlkDiagPrecondLO.py b/tests/helper_BlkDiagPrecondLO.py similarity index 100% rename from brahmap/tests/helper_BlkDiagPrecondLO.py rename to tests/helper_BlkDiagPrecondLO.py diff --git a/brahmap/tests/helper_SparseLO.py b/tests/helper_SparseLO.py similarity index 100% rename from brahmap/tests/helper_SparseLO.py rename to tests/helper_SparseLO.py diff --git a/brahmap/tests/helper_initweigths.py b/tests/helper_initweigths.py similarity index 100% rename from brahmap/tests/helper_initweigths.py rename to tests/helper_initweigths.py diff --git a/brahmap/tests/helper_repixelize.py b/tests/helper_repixelize.py similarity index 100% rename from brahmap/tests/helper_repixelize.py rename to tests/helper_repixelize.py diff --git a/brahmap/tests/test_BlkDiagPrecondLO_tools_cpp.py b/tests/test_BlkDiagPrecondLO_tools_cpp.py similarity index 100% rename from brahmap/tests/test_BlkDiagPrecondLO_tools_cpp.py rename to tests/test_BlkDiagPrecondLO_tools_cpp.py diff --git a/brahmap/tests/test_SparseLO_tools_cpp.py b/tests/test_SparseLO_tools_cpp.py similarity index 100% rename from brahmap/tests/test_SparseLO_tools_cpp.py rename to tests/test_SparseLO_tools_cpp.py diff --git a/brahmap/tests/test_process_samples_cpp.py b/tests/test_process_samples_cpp.py similarity index 100% rename from brahmap/tests/test_process_samples_cpp.py rename to tests/test_process_samples_cpp.py diff --git a/brahmap/tests/test_repixelize_cpp.py b/tests/test_repixelize_cpp.py similarity index 100% rename from brahmap/tests/test_repixelize_cpp.py rename to tests/test_repixelize_cpp.py