From acee11bdf767aaa7a4c535d97416001a5448804f Mon Sep 17 00:00:00 2001 From: Patrick Wells Date: Sun, 20 Apr 2025 10:05:06 -0500 Subject: [PATCH 1/5] Very small fix --- opencosmo/link/collection.py | 2 +- opencosmo/link/io.py | 4 ++++ pyproject.toml | 2 +- test/test_collection.py | 8 ++++++++ test/test_read.py | 4 ++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/opencosmo/link/collection.py b/opencosmo/link/collection.py index 36593a16..c1f3aa54 100644 --- a/opencosmo/link/collection.py +++ b/opencosmo/link/collection.py @@ -58,7 +58,7 @@ def __init__( self.__filters = filters def __repr__(self): - structure_type = self.header.file.data_type.split("_")[0] + "s" + structure_type = self.__header.file.data_type.split("_")[0] + "s" dtype_str = ", ".join(self.__handlers.keys()) return f"Collection of {structure_type} with linked datasets {dtype_str}" diff --git a/opencosmo/link/io.py b/opencosmo/link/io.py index 9f0b33dc..6a801667 100644 --- a/opencosmo/link/io.py +++ b/opencosmo/link/io.py @@ -92,6 +92,10 @@ def open_linked_files(*files: Path): Open a collection of files that are linked together, such as a properties file and a particle file. """ + if len(files) == 1 and isinstance(files[0], list): + return open_linked_files(*files[0]) + + file_handles = [File(file, "r") for file in files] headers = [read_header(file) for file in file_handles] properties_file, linked_files = verify_links(*headers) diff --git a/pyproject.toml b/pyproject.toml index 592cdac6..0ba1f4cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "opencosmo" -version = "0.6.0" +version = "0.6.1" description = "OpenCosmo Python Toolkit" authors = ["Patrick Wells "] readme = "README.md" diff --git a/test/test_collection.py b/test/test_collection.py index 7a6cb446..fa454605 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -42,6 +42,9 @@ def test_multi_filter(multi_path): for ds in collection.values(): assert all(ds.data["sod_halo_mass"] > 0) +def test_multi_repr(multi_path): + collection = oc.read(multi_path) + assert isinstance(collection.__repr__(), str) def test_multi_filter_write(multi_path, tmp_path): collection = oc.read(multi_path) @@ -85,6 +88,11 @@ def test_data_linking(halo_paths): assert n_particles > 0 assert n_profiles > 0 +def test_data_link_repr(halo_paths): + collection = open_linked_files(halo_paths) + assert isinstance(collection.__repr__(), str) + + def test_data_link_selection(halo_paths): collection = open_linked_files(*halo_paths) diff --git a/test/test_read.py b/test/test_read.py index 8b7b3aef..95d05084 100644 --- a/test/test_read.py +++ b/test/test_read.py @@ -34,3 +34,7 @@ def test_all_columns_included(input_path): def test_read_multi(multi_path): dataset = oc.read(multi_path) assert isinstance(dataset, oc.collection.collection.SimulationCollection) + +def test_dataset_repr(input_path): + dataset = oc.read(input_path) + assert isinstance(dataset.__repr__(), str) From 67731341e38cb8fee821565783a0ab157af06394 Mon Sep 17 00:00:00 2001 From: Patrick Wells Date: Sun, 20 Apr 2025 10:09:17 -0500 Subject: [PATCH 2/5] Cache linting deps --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 76b7db56..0faef785 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: opencosmo CI +nme: opencosmo CI on: pull_request: @@ -27,6 +27,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.13' + cache: poetry - name: setup mpi uses: mpi4py/setup-mpi@v1 - name: Install Poetry From b897aa957f57acd90a8540ce4e8c6a86ee864de8 Mon Sep 17 00:00:00 2001 From: Patrick Wells Date: Sun, 20 Apr 2025 10:11:01 -0500 Subject: [PATCH 3/5] Cache linting deps --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0faef785..b57142cc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -nme: opencosmo CI +name: opencosmo CI on: pull_request: From 631cf0b974eada825b82adfa573e349f6f9c6961 Mon Sep 17 00:00:00 2001 From: Patrick Wells Date: Sun, 20 Apr 2025 10:12:11 -0500 Subject: [PATCH 4/5] Cache linting deps --- .github/workflows/build.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b57142cc..b5201993 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,11 +23,6 @@ jobs: - name: setup mpi uses: mpi4py/setup-mpi@v1 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.13' - cache: poetry - name: setup mpi uses: mpi4py/setup-mpi@v1 - name: Install Poetry @@ -35,6 +30,11 @@ jobs: with: virtualenvs-create: true virtualenvs-in-project: true + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.13' + cache: poetry - name: check pyproject.toml run: cat pyproject.toml From b20a1f40cbd7262723be5596a1f8be00172a3efc Mon Sep 17 00:00:00 2001 From: Patrick Wells Date: Sun, 20 Apr 2025 10:16:31 -0500 Subject: [PATCH 5/5] Check cache --- .github/workflows/build.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b5201993..7f599099 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,9 +20,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: setup mpi - uses: mpi4py/setup-mpi@v1 - name: setup mpi uses: mpi4py/setup-mpi@v1 - name: Install Poetry @@ -48,7 +45,6 @@ jobs: run: poetry run mypy opencosmo build-docs: - needs: lint-typecheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -176,7 +172,6 @@ jobs: build: name: build runs-on: ubuntu-latest - needs: [run-tests, run-parallel-tests, lint-typecheck] steps: - name: Checkout repository uses: actions/checkout@v4