From 595f5fbdfa430c021074bc1d17a76d19f8fe7381 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 25 Oct 2024 18:00:35 -0400 Subject: [PATCH 1/4] prepare readme and changelog for 2.4.17 bugfix --- README.md | 2 ++ phoebe/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c66c4727e..6ae0b56aa 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ To understand how to use PHOEBE, please consult the [tutorials, scripts and manu CHANGELOG ---------- +### 2.4.17 + ### 2.4.16 * Fix handling of floating-point precision near the aligned case that used to result in error from libphoebe. [#965] diff --git a/phoebe/__init__.py b/phoebe/__init__.py index 7e273049b..04e2855c6 100644 --- a/phoebe/__init__.py +++ b/phoebe/__init__.py @@ -17,7 +17,7 @@ """ -__version__ = '2.4.16' +__version__ = '2.4.17' import os as _os import sys as _sys diff --git a/pyproject.toml b/pyproject.toml index 7d71fadfb..80a7d2fae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ [project] name = "phoebe" -version = "2.4.16" +version = "2.4.17" description = "PHOEBE: modeling and analysis of eclipsing binary stars" readme = "README.md" requires-python = ">=3.8" From 0c6af3d980f6b67912baa5d588e1e6d939a3646c Mon Sep 17 00:00:00 2001 From: mwrona77 <125769279+mwrona77@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:13:19 -0500 Subject: [PATCH 2/4] Numpy2 (#982) * Added support for NumPy >= 2.0 * Skip building i686 wheels. They are no longer supported by NumPy --------- Co-authored-by: Marcin Wrona --- .github/workflows/publish.yml | 4 ++-- phoebe/backend/universe.py | 4 ++-- phoebe/dependencies/distl/distl.py | 2 +- phoebe/dependencies/ligeor/models/polyfit.py | 2 +- phoebe/frontend/io.py | 10 ++++++++-- phoebe/parameters/parameters.py | 12 ++++++++++-- pyproject.toml | 4 ++-- tests/tests/test_legacy_parser/test_legacy_parser.py | 12 +++++++++--- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e95524960..d235ce52c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,7 +32,7 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.21.2 env: - CIBW_SKIP: pp37-* pp38-* pp39-* pp31*-macosx* + CIBW_SKIP: pp37-* pp38-* pp39-* pp31*-macosx* *-manylinux_i686 - uses: actions/upload-artifact@v4 with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} @@ -56,4 +56,4 @@ jobs: path: dist merge-multiple: true - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/phoebe/backend/universe.py b/phoebe/backend/universe.py index 20a10e12e..5760561c0 100644 --- a/phoebe/backend/universe.py +++ b/phoebe/backend/universe.py @@ -2955,8 +2955,8 @@ def split_mesh(mesh, q, pot): # a bit of array reshaping magic, but it works triangind_primsec_f = mesh['triangles'][triangind_primsec].flatten().copy() triangind_secprim_f = mesh['triangles'][triangind_secprim].flatten().copy() - indices_prim = np.where(np.in1d(triangind_primsec_f, vertind_primsec))[0] - indices_sec = np.where(np.in1d(triangind_secprim_f, vertind_secprim))[0] + indices_prim = np.where(np.isin(triangind_primsec_f, vertind_primsec))[0] + indices_sec = np.where(np.isin(triangind_secprim_f, vertind_secprim))[0] triangind_primsec_f[indices_prim] = new_triangle_indices_prim triangind_secprim_f[indices_sec] = new_triangle_indices_sec diff --git a/phoebe/dependencies/distl/distl.py b/phoebe/dependencies/distl/distl.py index 1281efd76..ad65bcba7 100644 --- a/phoebe/dependencies/distl/distl.py +++ b/phoebe/dependencies/distl/distl.py @@ -4714,7 +4714,7 @@ def dist_constructor_args(self): # TODO: do we need to remove duplicates? x.sort() if self.math == '__and__': - pdf = _np.product([d.pdf(x) for d in self.dists], axis=0) + pdf = _np.prod([d.pdf(x) for d in self.dists], axis=0) # unfortunately we'll need to integrate to get the cdf... we'll do that later cdf = None elif self.math == '__or__': diff --git a/phoebe/dependencies/ligeor/models/polyfit.py b/phoebe/dependencies/ligeor/models/polyfit.py index 25e32ee80..0cf214c9a 100644 --- a/phoebe/dependencies/ligeor/models/polyfit.py +++ b/phoebe/dependencies/ligeor/models/polyfit.py @@ -1,7 +1,7 @@ import numpy as np from operator import itemgetter from itertools import groupby -from numpy.core.fromnumeric import mean +from numpy import mean from scipy.optimize import minimize from phoebe.dependencies.ligeor.utils.lcutils import * from phoebe.dependencies.ligeor.models import Model diff --git a/phoebe/frontend/io.py b/phoebe/frontend/io.py index 06da8d0a9..72d45eb4a 100644 --- a/phoebe/frontend/io.py +++ b/phoebe/frontend/io.py @@ -465,8 +465,14 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True, raise TypeError("filename must be string or file object, got {}".format(type(filename))) # load the phoebe file - params = np.loadtxt(filename, dtype='str', delimiter='=', - converters={0: lambda s: s.strip(), 1: lambda s: s.strip()}) + params = np.genfromtxt( + filename, + dtype='str', + delimiter='=', + comments='#', + filling_values='', + autostrip=True + ) morphology = params[:,1][list(params[:,0]).index('phoebe_model')] diff --git a/phoebe/parameters/parameters.py b/phoebe/parameters/parameters.py index dfb195dc3..c9970d89a 100644 --- a/phoebe/parameters/parameters.py +++ b/phoebe/parameters/parameters.py @@ -11948,9 +11948,17 @@ def get_values(vars, safe_label=True, string_safe_arrays=False, use_distribution def _single_value(quantity, string_safe_arrays=False): if isinstance(quantity, u.Quantity): if self.in_solar_units: - v = np.float64(u.to_solar(quantity).value) + v = u.to_solar(quantity).value else: - v = np.float64(quantity.si.value) + v = quantity.si.value + + if isinstance(v, np.ndarray): + if v.size == 1: + v = np.float64(v[0]) # Convert single-element arrays to scalar avoid DeprecationWarning: Conversion of an array with ndim > 0 to a scalar + else: + v = np.float64(v) + else: + v = np.float64(v) if isinstance(v, np.ndarray) and string_safe_arrays: v = v.tolist() diff --git a/pyproject.toml b/pyproject.toml index 80a7d2fae..1f47c4c2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ classifiers = [ "Topic :: Software Development :: User Interfaces" ] dependencies = [ - "numpy < 2.0.0", + "numpy", "scipy", "astropy", "pytest", @@ -79,7 +79,7 @@ repository = "https://github.com/phoebe-project/phoebe2" documentation = "http://phoebe-project.org/docs" [build-system] -requires = ["setuptools", "numpy < 2.0.0", "wheel"] +requires = ["setuptools", "numpy", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools] diff --git a/tests/tests/test_legacy_parser/test_legacy_parser.py b/tests/tests/test_legacy_parser/test_legacy_parser.py index 30cf5b4cf..f7c66dce5 100644 --- a/tests/tests/test_legacy_parser/test_legacy_parser.py +++ b/tests/tests/test_legacy_parser/test_legacy_parser.py @@ -20,9 +20,15 @@ def _legacy_test(filename='default.phoebe', verbose=True): # locate file dir = os.path.dirname(os.path.realpath(__file__)) # load in phoebe parameter file - params = np.loadtxt( - os.path.join(dir, filename), dtype='str', delimiter='=', - converters={0: lambda s: s.strip(), 1: lambda s: s.strip()}) + params = np.genfromtxt( + os.path.join(dir, filename), + dtype='str', + delimiter='=', + comments='#', + filling_values='', + autostrip=True + ) + lcno = int(params[:,1][list(params[:,0]).index('phoebe_lcno')]) rvno = int(params[:,1][list(params[:,0]).index('phoebe_rvno')]) From 20a2ae54a806fce68aa6e322b0d06e41b4669f08 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Tue, 19 Nov 2024 09:58:18 -0500 Subject: [PATCH 3/4] update readme (#984) bring readme header up to date * docs to point to 2.4 * remove placeholder for unpublished paper * update python requirement * update build instructions to suggest pip over setup.py --- README.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6ae0b56aa..de4c134c4 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,15 @@ PHOEBE 2.4

- + - +
-

@@ -57,15 +56,9 @@ To download the PHOEBE 2 source code, use git: To install PHOEBE 2 from the source locally, go to the `phoebe2/` directory and issue: - python3 setup.py build - python3 setup.py install --user + pip install . -To install PHOEBE 2 from the source site-wide, go to the `phoebe2/` directory and issue: - - python3 setup.py build - sudo python3 setup.py install - -Note that as of the 2.3 release, PHOEBE requires Python 3.6 or later. For further details on pre-requisites consult the [PHOEBE project webpage](http://phoebe-project.org/install/2.4). +Note that as of the 2.4.16 release, PHOEBE requires Python 3.8 or later. For further details on pre-requisites consult the [PHOEBE project webpage](http://phoebe-project.org/install/2.4). GETTING STARTED From 048eace510dd1a61f3271834735a18bb97ab7149 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 20 Nov 2024 08:57:20 -0500 Subject: [PATCH 4/4] update changelog --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index de4c134c4..fa63f5381 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ CHANGELOG ### 2.4.17 +* Fix support for numpy 2.0. [#982] + + ### 2.4.16 * Fix handling of floating-point precision near the aligned case that used to result in error from libphoebe. [#965]