From 5d80a9070cda96e1a95731735bda0faaa1b205ef Mon Sep 17 00:00:00 2001 From: Alan Pearl Date: Mon, 27 Jan 2025 10:52:17 -0600 Subject: [PATCH 1/5] Fix fail message for multiple matches --- halotools/sim_manager/cached_halo_catalog.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/halotools/sim_manager/cached_halo_catalog.py b/halotools/sim_manager/cached_halo_catalog.py index 0b383e167..f3505c35e 100644 --- a/halotools/sim_manager/cached_halo_catalog.py +++ b/halotools/sim_manager/cached_halo_catalog.py @@ -395,11 +395,11 @@ def _retrieve_matching_ptcl_cache_log_entry(self): else: msg += "redshift = ``" + str(self.redshift) + "``\n" - msg += ("\nThere is no matching catalog in cache " - "within dz_tol = "+str(self._dz_tol)+" of these inputs.\n" - ) - if len(matching_entries) == 0: + msg += ( + "\nThere is no matching catalog in cache " + "within dz_tol = " + str(self._dz_tol) + " of these inputs.\n" + ) suggestion_preamble = ("\nThe following entries in the cache log " "most closely match your inputs:\n\n") alt_list1 = list(gen1) # discard the redshift requirement From ed4fcbb8b4b1ccc158018ccb11349796ace6d132 Mon Sep 17 00:00:00 2001 From: Alan Pearl Date: Mon, 27 Jan 2025 10:54:08 -0600 Subject: [PATCH 2/5] Numpy 1 -> 2 * Update numpy version requirements for build and install * Replace all `int_t` with `int64_t` * Replace `string_` with `bytes_` and `unicode_` with `str_` --- .../occupation_models/tinker13_components.py | 2 +- .../cpairs/pairwise_distance_3d_engine.pyx | 4 ++-- .../cpairs/pairwise_distance_xy_z_engine.pyx | 4 ++-- .../cpairs/pairwise_distances.pyx | 18 +++++++++--------- .../conditional_pairwise_distances.pyx | 14 +++++++------- halotools/sim_manager/rockstar_hlist_reader.py | 16 ++++++++-------- .../sim_manager/user_supplied_halo_catalog.py | 16 ++++++++-------- .../sim_manager/user_supplied_ptcl_catalog.py | 12 ++++++------ pyproject.toml | 4 ++-- requirements.txt | 2 +- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/halotools/empirical_models/occupation_models/tinker13_components.py b/halotools/empirical_models/occupation_models/tinker13_components.py index c8de1a8e0..ab0b9fd3d 100644 --- a/halotools/empirical_models/occupation_models/tinker13_components.py +++ b/halotools/empirical_models/occupation_models/tinker13_components.py @@ -237,7 +237,7 @@ def mean_occupation(self, **kwargs): "you must pass both ``prim_haloprop`` and ``sfr_designation`` keyword arguments" ) raise HalotoolsError(msg) - if type(sfr_designation[0]) in (str, unicode, np.string_, np.unicode_): + if type(sfr_designation[0]) in (str, unicode, np.bytes_, np.str_): if sfr_designation[0] not in ["active", "quiescent"]: msg = ( "The only acceptable values of " diff --git a/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_3d_engine.pyx b/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_3d_engine.pyx index 995bd4ea5..e1133ab68 100644 --- a/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_3d_engine.pyx +++ b/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_3d_engine.pyx @@ -70,8 +70,8 @@ def pairwise_distance_3d_engine(double_mesh, x1in, y1in, z1in, x2in, y2in, z2in, cdef cnp.float64_t[:] y2 = np.ascontiguousarray(y2in[double_mesh.mesh2.idx_sorted], dtype=np.float64) cdef cnp.float64_t[:] z2 = np.ascontiguousarray(z2in[double_mesh.mesh2.idx_sorted], dtype=np.float64) - cdef vector[cnp.int_t] i_ind - cdef vector[cnp.int_t] j_ind + cdef vector[cnp.int64_t] i_ind + cdef vector[cnp.int64_t] j_ind cdef vector[cnp.float64_t] distances cdef cnp.int64_t icell1, icell2 diff --git a/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_xy_z_engine.pyx b/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_xy_z_engine.pyx index 719008bea..eba6c9b8e 100644 --- a/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_xy_z_engine.pyx +++ b/halotools/mock_observables/pair_counters/cpairs/pairwise_distance_xy_z_engine.pyx @@ -78,8 +78,8 @@ def pairwise_distance_xy_z_engine(double_mesh, x1in, y1in, z1in, x2in, y2in, z2i cdef cnp.float64_t[:] y2 = np.ascontiguousarray(y2in[double_mesh.mesh2.idx_sorted], dtype=np.float64) cdef cnp.float64_t[:] z2 = np.ascontiguousarray(z2in[double_mesh.mesh2.idx_sorted], dtype=np.float64) - cdef vector[cnp.int_t] i_ind - cdef vector[cnp.int_t] j_ind + cdef vector[cnp.int64_t] i_ind + cdef vector[cnp.int64_t] j_ind cdef vector[cnp.float64_t] rp_distances cdef vector[cnp.float64_t] pi_distances diff --git a/halotools/mock_observables/pair_counters/cpairs/pairwise_distances.pyx b/halotools/mock_observables/pair_counters/cpairs/pairwise_distances.pyx index 620b6048f..e34932a39 100644 --- a/halotools/mock_observables/pair_counters/cpairs/pairwise_distances.pyx +++ b/halotools/mock_observables/pair_counters/cpairs/pairwise_distances.pyx @@ -87,11 +87,11 @@ def pairwise_distance_no_pbc(np.ndarray[np.float64_t, ndim=1] x_icell1, """ #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] distances cdef double d - cdef np.int_t i, j, n + cdef np.int64_t i, j, n cdef int Ni = len(x_icell1) cdef int Nj = len(x_icell2) @@ -195,8 +195,8 @@ def pairwise_distance_pbc(np.ndarray[np.float64_t, ndim=1] x_icell1, """ #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] distances cdef double d cdef int i, j, n @@ -307,8 +307,8 @@ def pairwise_xy_z_distance_no_pbc( #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] para_distances cdef vector[np.float64_t] perp_distances cdef double d_perp, d_para @@ -429,8 +429,8 @@ def pairwise_xy_z_distance_pbc( """ #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] para_distances cdef vector[np.float64_t] perp_distances cdef double d_perp, d_para diff --git a/halotools/mock_observables/pair_counters/marked_cpairs/conditional_pairwise_distances.pyx b/halotools/mock_observables/pair_counters/marked_cpairs/conditional_pairwise_distances.pyx index 1f6928266..246e6ac29 100644 --- a/halotools/mock_observables/pair_counters/marked_cpairs/conditional_pairwise_distances.pyx +++ b/halotools/mock_observables/pair_counters/marked_cpairs/conditional_pairwise_distances.pyx @@ -30,7 +30,7 @@ def conditional_pairwise_distance_no_pbc(np.ndarray[np.float64_t, ndim=1] x_icel np.float64_t max_r, np.ndarray[np.float64_t, ndim=2] w_icell1, np.ndarray[np.float64_t, ndim=2] w_icell2, - np.int_t cond_func_id): + np.int64_t cond_func_id): """ Calculate the conditional limited pairwise distance matrix, :math:`d_{ij}`. @@ -101,11 +101,11 @@ def conditional_pairwise_distance_no_pbc(np.ndarray[np.float64_t, ndim=1] x_icel """ #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] distances cdef double d - cdef np.int_t i, j, n + cdef np.int64_t i, j, n cdef int Ni = len(x_icell1) cdef int Nj = len(x_icell2) @@ -149,7 +149,7 @@ def conditional_pairwise_xy_z_distance_no_pbc(np.ndarray[np.float64_t, ndim=1] x np.float64_t max_rp, np.float64_t max_pi, np.ndarray[np.float64_t, ndim=2] w_icell1, np.ndarray[np.float64_t, ndim=2] w_icell2, - np.int_t cond_func_id): + np.int64_t cond_func_id): """ Calculate the conditional limited pairwise distance matrices, :math:`d_{{\perp}ij}` and :math:`d_{{\parallel}ij}`. @@ -228,8 +228,8 @@ def conditional_pairwise_xy_z_distance_no_pbc(np.ndarray[np.float64_t, ndim=1] x #c definitions - cdef vector[np.int_t] i_ind - cdef vector[np.int_t] j_ind + cdef vector[np.int64_t] i_ind + cdef vector[np.int64_t] j_ind cdef vector[np.float64_t] para_distances cdef vector[np.float64_t] perp_distances cdef double d_perp, d_para diff --git a/halotools/sim_manager/rockstar_hlist_reader.py b/halotools/sim_manager/rockstar_hlist_reader.py index 9ac3e8173..008262d60 100644 --- a/halotools/sim_manager/rockstar_hlist_reader.py +++ b/halotools/sim_manager/rockstar_hlist_reader.py @@ -708,22 +708,22 @@ def _write_metadata(self): # Now add the metadata f = h5py.File(self.output_fname, 'a') - f.attrs.create('simname', np.string_(self.simname)) - f.attrs.create('halo_finder', np.string_(self.halo_finder)) - redshift_string = np.string_(get_redshift_string(self.redshift)) + f.attrs.create('simname', np.bytes_(self.simname)) + f.attrs.create('halo_finder', np.bytes_(self.halo_finder)) + redshift_string = np.bytes_(get_redshift_string(self.redshift)) f.attrs.create('redshift', redshift_string) - f.attrs.create('version_name', np.string_(self.version_name)) - f.attrs.create('fname', np.string_(self.output_fname)) + f.attrs.create('version_name', np.bytes_(self.version_name)) + f.attrs.create('fname', np.bytes_(self.output_fname)) f.attrs.create('Lbox', self.Lbox) f.attrs.create('particle_mass', self.particle_mass) - f.attrs.create('orig_ascii_fname', np.string_(self.input_fname)) + f.attrs.create('orig_ascii_fname', np.bytes_(self.input_fname)) - time_right_now = np.string_(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) + time_right_now = np.bytes_(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) f.attrs.create('time_of_catalog_production', time_right_now) if self.processing_notes is not None: - f.attrs.create('processing_notes', np.string_(self.processing_notes)) + f.attrs.create('processing_notes', np.bytes_(self.processing_notes)) # Store all the choices for row cuts as metadata for haloprop_key, cut_value in self.row_cut_min_dict.items(): diff --git a/halotools/sim_manager/user_supplied_halo_catalog.py b/halotools/sim_manager/user_supplied_halo_catalog.py index 1a0cadbd9..cbfc176ea 100644 --- a/halotools/sim_manager/user_supplied_halo_catalog.py +++ b/halotools/sim_manager/user_supplied_halo_catalog.py @@ -415,11 +415,11 @@ def add_halocat_to_cache(self, redshift_string = get_redshift_string(self.redshift) - f.attrs.create('simname', np.string_(simname)) - f.attrs.create('halo_finder', np.string_(halo_finder)) - f.attrs.create('version_name', np.string_(version_name)) - f.attrs.create('redshift', np.string_(redshift_string)) - f.attrs.create('fname', np.string_(fname)) + f.attrs.create('simname', np.bytes_(simname)) + f.attrs.create('halo_finder', np.bytes_(halo_finder)) + f.attrs.create('version_name', np.bytes_(version_name)) + f.attrs.create('redshift', np.bytes_(redshift_string)) + f.attrs.create('fname', np.bytes_(fname)) f.attrs.create('Lbox', self.Lbox) f.attrs.create('particle_mass', self.particle_mass) @@ -427,12 +427,12 @@ def add_halocat_to_cache(self, time_right_now = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') - f.attrs.create('time_catalog_was_originally_cached', np.string_(time_right_now)) + f.attrs.create('time_catalog_was_originally_cached', np.bytes_(time_right_now)) - f.attrs.create('processing_notes', np.string_(processing_notes)) + f.attrs.create('processing_notes', np.bytes_(processing_notes)) for key, value in additional_metadata.items(): - f.attrs.create(key, np.string_(value)) + f.attrs.create(key, np.bytes_(value)) f.close() ############################################################ diff --git a/halotools/sim_manager/user_supplied_ptcl_catalog.py b/halotools/sim_manager/user_supplied_ptcl_catalog.py index 2c09e38a4..dffd8d417 100644 --- a/halotools/sim_manager/user_supplied_ptcl_catalog.py +++ b/halotools/sim_manager/user_supplied_ptcl_catalog.py @@ -300,19 +300,19 @@ def add_ptclcat_to_cache(self, fname, simname, version_name, redshift_string = get_redshift_string(self.redshift) - f.attrs.create('simname', np.string_(simname)) - f.attrs.create('version_name', np.string_(version_name)) - f.attrs.create('redshift', np.string_(redshift_string)) - f.attrs.create('fname', np.string_(fname)) + f.attrs.create('simname', np.bytes_(simname)) + f.attrs.create('version_name', np.bytes_(version_name)) + f.attrs.create('redshift', np.bytes_(redshift_string)) + f.attrs.create('fname', np.bytes_(fname)) f.attrs.create('Lbox', self.Lbox) f.attrs.create('particle_mass', self.particle_mass) time_right_now = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') - f.attrs.create('time_catalog_was_originally_cached', np.string_(time_right_now)) + f.attrs.create('time_catalog_was_originally_cached', np.bytes_(time_right_now)) - f.attrs.create('processing_notes', np.string_(processing_notes)) + f.attrs.create('processing_notes', np.bytes_(processing_notes)) f.close() diff --git a/pyproject.toml b/pyproject.toml index 9ae592c04..6a1331089 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,8 +51,8 @@ markers = ["slow", "installation_test"] requires = ["setuptools>=42.0.0", "setuptools_scm", "wheel", - "oldest-supported-numpy", - "cython==3.0.2", + "numpy>=2.0", + "cython>=3.0.2", "extension-helpers==1.*"] build-backend = 'setuptools.build_meta' diff --git a/requirements.txt b/requirements.txt index 8c6dd39d6..4411c6c9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ astropy -numpy<2 +numpy scipy requests beautifulsoup4 From f8529d6df2ca0e559edc51d8c4a8bf123da7bc3c Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Thu, 30 Jan 2025 13:49:22 -0600 Subject: [PATCH 3/5] Require python>=3.11 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6a1331089..9fde4cd60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: BSD License", ] -requires-python = ">=3.10" +requires-python = ">=3.11" [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} From 4ae50fe7fd3c55761945779fcd45429226e16578 Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Thu, 30 Jan 2025 13:53:53 -0600 Subject: [PATCH 4/5] Drop python 3.10 in ci workflows --- .github/workflows/ci_tests.yaml | 10 ---------- .github/workflows/cron_tests.yaml | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index e66cb4ee1..74f481a7e 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -18,16 +18,6 @@ jobs: strategy: matrix: include: - - name: Ubuntu - Python 3.10 with all optional dependencies - os: ubuntu-latest - python: "3.10" - toxenv: 'py10-test-alldeps' - - - name: MacOs - Python 3.10 with all optional dependencies - os: macos-latest - python: "3.10" - toxenv: 'py10-test-alldeps' - - name: Ubuntu - Python 3.11 with all optional dependencies os: ubuntu-latest python: "3.11" diff --git a/.github/workflows/cron_tests.yaml b/.github/workflows/cron_tests.yaml index 6a70075de..301e5750b 100644 --- a/.github/workflows/cron_tests.yaml +++ b/.github/workflows/cron_tests.yaml @@ -15,16 +15,6 @@ jobs: strategy: matrix: include: - - name: Ubuntu - Python 3.10 with all optional dependencies - os: ubuntu-latest - python: "3.10" - toxenv: 'py10-test-alldeps' - - - name: MacOs - Python 3.10 with all optional dependencies - os: macos-latest - python: "3.10" - toxenv: 'py10-test-alldeps' - - name: Ubuntu - Python 3.11 with all optional dependencies os: ubuntu-latest python: "3.11" From 15ce02d7ae67a718849cddc3fdd6458419fbdeec Mon Sep 17 00:00:00 2001 From: Andrew Hearin Date: Thu, 30 Jan 2025 13:55:47 -0600 Subject: [PATCH 5/5] Update rtd build env to 3.11 [skip ci] --- .readthedocs.yaml | 2 +- docs/installing_halotools_with_virtualenv.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 81356460a..461586dc0 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -5,7 +5,7 @@ build: apt_packages: - graphviz tools: - python: "3.10" + python: "3.11" sphinx: configuration: docs/conf.py diff --git a/docs/installing_halotools_with_virtualenv.rst b/docs/installing_halotools_with_virtualenv.rst index 99c18feb1..3e2e85091 100644 --- a/docs/installing_halotools_with_virtualenv.rst +++ b/docs/installing_halotools_with_virtualenv.rst @@ -12,7 +12,7 @@ create a virtual environment that will automatically have compatible versions of By installing into a virtual environment, you will not change any of the packages that are already installed system-wide on your machine. In the example below, we will use conda to create a virtual environment with all the dependencies handled automatically:: - conda create -n htenv python=3.9 halotools=0.8 h5py ipython jupyter matplotlib + conda create -n htenv python=3.11 halotools=0.9 h5py ipython jupyter matplotlib In order to activate this environment::