diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 813019b6..f415137b 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -72,7 +72,7 @@ jobs: run: | python -c "import tangos" - name: Install pynbody and yt - run: python -m pip install pynbody yt --no-build-isolation + run: python -m pip install pynbody 'yt<4.4.0' --no-build-isolation - name: Set up MySQL if: ${{ matrix.TANGOS_TESTING_DB_BACKEND == 'mysql+pymysql' }} run: | diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 08d281c5..963138b1 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -47,8 +47,8 @@ jobs: run: python -m pip install --pre pynbody # Or: python -m pip install git+https://github.com/pynbody/pynbody.git - - name: Install latest yt - run: python -m pip install yt + - name: Install yt + run: python -m pip install 'yt<4.4.0' - name: Build test database working-directory: test_tutorial_build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ad3245c..7d964bb3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - - id: trailing-whitespace - id: end-of-file-fixer - id: no-commit-to-branch args: [--branch, master] diff --git a/tangos/input_handlers/pynbody.py b/tangos/input_handlers/pynbody.py index 08eff29b..7fd4f2be 100644 --- a/tangos/input_handlers/pynbody.py +++ b/tangos/input_handlers/pynbody.py @@ -615,37 +615,12 @@ def available_object_property_names_for_timestep(self, ts_extension, object_type ) - def _get_map_child_subhalos(self, ts_extension): - h = self.get_catalogue(ts_extension, 'halo') - halo_children = defaultdict(list) - for halo in h: - iparent = halo.properties["hostHalo"] # Returns the unique ID (NOT the halo_id index) of the host - if iparent == -1: # If halo is its own host (i.e. -1), move on to next object - continue - - halo_children[iparent].append(halo.properties["halo_id"]) # Otherwise store the halo_id index of the host - return halo_children - - - def _get_map_IDs_to_halo_ids(self, ts_extension): - # IDs and halo_ids are usually related by ID = halo_id - 1, - # but they can be entirely independent when using specific AHF options or running with MPI - # This allows to map between one and the other - h = self.get_catalogue(ts_extension, 'halo') - return { - halo.properties["ID"]: halo.properties["halo_id"] for halo in h - } - def iterate_object_properties_for_timestep(self, ts_extension, object_typetag, property_names): h = self.get_catalogue(ts_extension, object_typetag) h.physical_units() - if "child" in property_names: - map_child_parent = self._get_map_child_subhalos(ts_extension) - - if "parent" in property_names: - map_ID_to_halo_id = self._get_map_IDs_to_halo_ids(ts_extension) + # Manually mapping IDs etc used to be setup here, but should no longer be required with pynbody v2 for halo in h: # Tangos expect us to yield first the finder offset (index in the pynbody catalogue, halo_id in our case) @@ -659,7 +634,7 @@ def iterate_object_properties_for_timestep(self, ts_extension, object_typetag, p if parent_ID != -1: # If halo is not its own parent, link to parent data = proxy_object.IncompleteProxyObjectFromFinderId( - map_ID_to_halo_id[parent_ID], + parent_ID, 'halo' ) else: @@ -668,12 +643,10 @@ def iterate_object_properties_for_timestep(self, ts_extension, object_typetag, p halo_props['halo_id'], 'halo' ) - - elif k == "child": data = [ proxy_object.IncompleteProxyObjectFromFinderId(ichild, 'halo') - for ichild in map_child_parent[halo_props["ID"]] + for ichild in halo_props['children'] ] elif k == "shrink_center": data = np.array([halo_props[k] for k in ("Xc", "Yc", "Zc")])