From db84e71fa113f1bcb01d037bf30c96523f857fa9 Mon Sep 17 00:00:00 2001 From: Marcin Wrona Date: Tue, 12 Nov 2024 19:26:25 -0500 Subject: [PATCH 1/4] Added support for NumPy >= 2.0 --- .spyproject/config/backups/codestyle.ini.bak | 8 ++++++++ .spyproject/config/backups/encoding.ini.bak | 6 ++++++ .spyproject/config/backups/vcs.ini.bak | 7 +++++++ .spyproject/config/backups/workspace.ini.bak | 12 ++++++++++++ .spyproject/config/codestyle.ini | 8 ++++++++ .../config/defaults/defaults-codestyle-0.2.0.ini | 5 +++++ .../config/defaults/defaults-encoding-0.2.0.ini | 3 +++ .spyproject/config/defaults/defaults-vcs-0.2.0.ini | 4 ++++ .../config/defaults/defaults-workspace-0.2.0.ini | 6 ++++++ .spyproject/config/encoding.ini | 6 ++++++ .spyproject/config/vcs.ini | 7 +++++++ .spyproject/config/workspace.ini | 12 ++++++++++++ phoebe/backend/universe.py | 4 ++-- phoebe/dependencies/distl/distl.py | 2 +- phoebe/dependencies/ligeor/models/polyfit.py | 2 +- phoebe/frontend/io.py | 12 ++++++++++-- phoebe/parameters/parameters.py | 12 ++++++++++-- pyproject.toml | 8 ++++---- .../tests/test_legacy_parser/test_legacy_parser.py | 14 +++++++++++--- 19 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 .spyproject/config/backups/codestyle.ini.bak create mode 100644 .spyproject/config/backups/encoding.ini.bak create mode 100644 .spyproject/config/backups/vcs.ini.bak create mode 100644 .spyproject/config/backups/workspace.ini.bak create mode 100644 .spyproject/config/codestyle.ini create mode 100644 .spyproject/config/defaults/defaults-codestyle-0.2.0.ini create mode 100644 .spyproject/config/defaults/defaults-encoding-0.2.0.ini create mode 100644 .spyproject/config/defaults/defaults-vcs-0.2.0.ini create mode 100644 .spyproject/config/defaults/defaults-workspace-0.2.0.ini create mode 100644 .spyproject/config/encoding.ini create mode 100644 .spyproject/config/vcs.ini create mode 100644 .spyproject/config/workspace.ini diff --git a/.spyproject/config/backups/codestyle.ini.bak b/.spyproject/config/backups/codestyle.ini.bak new file mode 100644 index 000000000..0f54b4c43 --- /dev/null +++ b/.spyproject/config/backups/codestyle.ini.bak @@ -0,0 +1,8 @@ +[codestyle] +indentation = True +edge_line = True +edge_line_columns = 79 + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/backups/encoding.ini.bak b/.spyproject/config/backups/encoding.ini.bak new file mode 100644 index 000000000..a17acedd7 --- /dev/null +++ b/.spyproject/config/backups/encoding.ini.bak @@ -0,0 +1,6 @@ +[encoding] +text_encoding = utf-8 + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/backups/vcs.ini.bak b/.spyproject/config/backups/vcs.ini.bak new file mode 100644 index 000000000..fd66eae01 --- /dev/null +++ b/.spyproject/config/backups/vcs.ini.bak @@ -0,0 +1,7 @@ +[vcs] +use_version_control = False +version_control_system = + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/backups/workspace.ini.bak b/.spyproject/config/backups/workspace.ini.bak new file mode 100644 index 000000000..8cd8a339d --- /dev/null +++ b/.spyproject/config/backups/workspace.ini.bak @@ -0,0 +1,12 @@ +[workspace] +restore_data_on_startup = True +save_data_on_exit = True +save_history = True +save_non_project_files = False +project_type = 'empty-project-type' +recent_files = ['../../../.config/spyder-py3/temp.py', 'pyproject.toml'] + +[main] +version = 0.2.0 +recent_files = [] + diff --git a/.spyproject/config/codestyle.ini b/.spyproject/config/codestyle.ini new file mode 100644 index 000000000..0f54b4c43 --- /dev/null +++ b/.spyproject/config/codestyle.ini @@ -0,0 +1,8 @@ +[codestyle] +indentation = True +edge_line = True +edge_line_columns = 79 + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini b/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini new file mode 100644 index 000000000..0b95e5cee --- /dev/null +++ b/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini @@ -0,0 +1,5 @@ +[codestyle] +indentation = True +edge_line = True +edge_line_columns = 79 + diff --git a/.spyproject/config/defaults/defaults-encoding-0.2.0.ini b/.spyproject/config/defaults/defaults-encoding-0.2.0.ini new file mode 100644 index 000000000..0ce193c1e --- /dev/null +++ b/.spyproject/config/defaults/defaults-encoding-0.2.0.ini @@ -0,0 +1,3 @@ +[encoding] +text_encoding = utf-8 + diff --git a/.spyproject/config/defaults/defaults-vcs-0.2.0.ini b/.spyproject/config/defaults/defaults-vcs-0.2.0.ini new file mode 100644 index 000000000..ee2548333 --- /dev/null +++ b/.spyproject/config/defaults/defaults-vcs-0.2.0.ini @@ -0,0 +1,4 @@ +[vcs] +use_version_control = False +version_control_system = + diff --git a/.spyproject/config/defaults/defaults-workspace-0.2.0.ini b/.spyproject/config/defaults/defaults-workspace-0.2.0.ini new file mode 100644 index 000000000..2a73ab7ad --- /dev/null +++ b/.spyproject/config/defaults/defaults-workspace-0.2.0.ini @@ -0,0 +1,6 @@ +[workspace] +restore_data_on_startup = True +save_data_on_exit = True +save_history = True +save_non_project_files = False + diff --git a/.spyproject/config/encoding.ini b/.spyproject/config/encoding.ini new file mode 100644 index 000000000..a17acedd7 --- /dev/null +++ b/.spyproject/config/encoding.ini @@ -0,0 +1,6 @@ +[encoding] +text_encoding = utf-8 + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/vcs.ini b/.spyproject/config/vcs.ini new file mode 100644 index 000000000..fd66eae01 --- /dev/null +++ b/.spyproject/config/vcs.ini @@ -0,0 +1,7 @@ +[vcs] +use_version_control = False +version_control_system = + +[main] +version = 0.2.0 + diff --git a/.spyproject/config/workspace.ini b/.spyproject/config/workspace.ini new file mode 100644 index 000000000..8cd8a339d --- /dev/null +++ b/.spyproject/config/workspace.ini @@ -0,0 +1,12 @@ +[workspace] +restore_data_on_startup = True +save_data_on_exit = True +save_history = True +save_non_project_files = False +project_type = 'empty-project-type' +recent_files = ['../../../.config/spyder-py3/temp.py', 'pyproject.toml'] + +[main] +version = 0.2.0 +recent_files = [] + 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..b4b67a7d1 100644 --- a/phoebe/frontend/io.py +++ b/phoebe/frontend/io.py @@ -465,8 +465,16 @@ 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='=', + converters={0: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip(), + 1: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip()}, + 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..2b65cc6b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ [project] name = "phoebe" -version = "2.4.17" +version = "2.4.16" description = "PHOEBE: modeling and analysis of eclipsing binary stars" readme = "README.md" requires-python = ">=3.8" @@ -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] @@ -122,4 +122,4 @@ packages = [ script-files = [ "client-server/phoebe-server", "client-server/phoebe-autofig", -] +] \ No newline at end of file diff --git a/tests/tests/test_legacy_parser/test_legacy_parser.py b/tests/tests/test_legacy_parser/test_legacy_parser.py index 30cf5b4cf..24299c8a2 100644 --- a/tests/tests/test_legacy_parser/test_legacy_parser.py +++ b/tests/tests/test_legacy_parser/test_legacy_parser.py @@ -20,9 +20,17 @@ 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='=', + converters={0: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip(), + 1: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip()}, + 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 f102b42c1aacf3c97c0c264f42bf1e87419fbcad Mon Sep 17 00:00:00 2001 From: Marcin Wrona Date: Tue, 12 Nov 2024 19:47:29 -0500 Subject: [PATCH 2/4] Remove .spyproject directory --- .spyproject/config/backups/codestyle.ini.bak | 8 -------- .spyproject/config/backups/encoding.ini.bak | 6 ------ .spyproject/config/backups/vcs.ini.bak | 7 ------- .spyproject/config/backups/workspace.ini.bak | 12 ------------ .spyproject/config/codestyle.ini | 8 -------- .../config/defaults/defaults-codestyle-0.2.0.ini | 5 ----- .../config/defaults/defaults-encoding-0.2.0.ini | 3 --- .spyproject/config/defaults/defaults-vcs-0.2.0.ini | 4 ---- .../config/defaults/defaults-workspace-0.2.0.ini | 6 ------ .spyproject/config/encoding.ini | 6 ------ .spyproject/config/vcs.ini | 7 ------- .spyproject/config/workspace.ini | 12 ------------ pyproject.toml | 4 ++-- 13 files changed, 2 insertions(+), 86 deletions(-) delete mode 100644 .spyproject/config/backups/codestyle.ini.bak delete mode 100644 .spyproject/config/backups/encoding.ini.bak delete mode 100644 .spyproject/config/backups/vcs.ini.bak delete mode 100644 .spyproject/config/backups/workspace.ini.bak delete mode 100644 .spyproject/config/codestyle.ini delete mode 100644 .spyproject/config/defaults/defaults-codestyle-0.2.0.ini delete mode 100644 .spyproject/config/defaults/defaults-encoding-0.2.0.ini delete mode 100644 .spyproject/config/defaults/defaults-vcs-0.2.0.ini delete mode 100644 .spyproject/config/defaults/defaults-workspace-0.2.0.ini delete mode 100644 .spyproject/config/encoding.ini delete mode 100644 .spyproject/config/vcs.ini delete mode 100644 .spyproject/config/workspace.ini diff --git a/.spyproject/config/backups/codestyle.ini.bak b/.spyproject/config/backups/codestyle.ini.bak deleted file mode 100644 index 0f54b4c43..000000000 --- a/.spyproject/config/backups/codestyle.ini.bak +++ /dev/null @@ -1,8 +0,0 @@ -[codestyle] -indentation = True -edge_line = True -edge_line_columns = 79 - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/backups/encoding.ini.bak b/.spyproject/config/backups/encoding.ini.bak deleted file mode 100644 index a17acedd7..000000000 --- a/.spyproject/config/backups/encoding.ini.bak +++ /dev/null @@ -1,6 +0,0 @@ -[encoding] -text_encoding = utf-8 - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/backups/vcs.ini.bak b/.spyproject/config/backups/vcs.ini.bak deleted file mode 100644 index fd66eae01..000000000 --- a/.spyproject/config/backups/vcs.ini.bak +++ /dev/null @@ -1,7 +0,0 @@ -[vcs] -use_version_control = False -version_control_system = - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/backups/workspace.ini.bak b/.spyproject/config/backups/workspace.ini.bak deleted file mode 100644 index 8cd8a339d..000000000 --- a/.spyproject/config/backups/workspace.ini.bak +++ /dev/null @@ -1,12 +0,0 @@ -[workspace] -restore_data_on_startup = True -save_data_on_exit = True -save_history = True -save_non_project_files = False -project_type = 'empty-project-type' -recent_files = ['../../../.config/spyder-py3/temp.py', 'pyproject.toml'] - -[main] -version = 0.2.0 -recent_files = [] - diff --git a/.spyproject/config/codestyle.ini b/.spyproject/config/codestyle.ini deleted file mode 100644 index 0f54b4c43..000000000 --- a/.spyproject/config/codestyle.ini +++ /dev/null @@ -1,8 +0,0 @@ -[codestyle] -indentation = True -edge_line = True -edge_line_columns = 79 - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini b/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini deleted file mode 100644 index 0b95e5cee..000000000 --- a/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +++ /dev/null @@ -1,5 +0,0 @@ -[codestyle] -indentation = True -edge_line = True -edge_line_columns = 79 - diff --git a/.spyproject/config/defaults/defaults-encoding-0.2.0.ini b/.spyproject/config/defaults/defaults-encoding-0.2.0.ini deleted file mode 100644 index 0ce193c1e..000000000 --- a/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +++ /dev/null @@ -1,3 +0,0 @@ -[encoding] -text_encoding = utf-8 - diff --git a/.spyproject/config/defaults/defaults-vcs-0.2.0.ini b/.spyproject/config/defaults/defaults-vcs-0.2.0.ini deleted file mode 100644 index ee2548333..000000000 --- a/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +++ /dev/null @@ -1,4 +0,0 @@ -[vcs] -use_version_control = False -version_control_system = - diff --git a/.spyproject/config/defaults/defaults-workspace-0.2.0.ini b/.spyproject/config/defaults/defaults-workspace-0.2.0.ini deleted file mode 100644 index 2a73ab7ad..000000000 --- a/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +++ /dev/null @@ -1,6 +0,0 @@ -[workspace] -restore_data_on_startup = True -save_data_on_exit = True -save_history = True -save_non_project_files = False - diff --git a/.spyproject/config/encoding.ini b/.spyproject/config/encoding.ini deleted file mode 100644 index a17acedd7..000000000 --- a/.spyproject/config/encoding.ini +++ /dev/null @@ -1,6 +0,0 @@ -[encoding] -text_encoding = utf-8 - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/vcs.ini b/.spyproject/config/vcs.ini deleted file mode 100644 index fd66eae01..000000000 --- a/.spyproject/config/vcs.ini +++ /dev/null @@ -1,7 +0,0 @@ -[vcs] -use_version_control = False -version_control_system = - -[main] -version = 0.2.0 - diff --git a/.spyproject/config/workspace.ini b/.spyproject/config/workspace.ini deleted file mode 100644 index 8cd8a339d..000000000 --- a/.spyproject/config/workspace.ini +++ /dev/null @@ -1,12 +0,0 @@ -[workspace] -restore_data_on_startup = True -save_data_on_exit = True -save_history = True -save_non_project_files = False -project_type = 'empty-project-type' -recent_files = ['../../../.config/spyder-py3/temp.py', 'pyproject.toml'] - -[main] -version = 0.2.0 -recent_files = [] - diff --git a/pyproject.toml b/pyproject.toml index 2b65cc6b2..1f47c4c2e 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" @@ -122,4 +122,4 @@ packages = [ script-files = [ "client-server/phoebe-server", "client-server/phoebe-autofig", -] \ No newline at end of file +] From 368952274ae53847b25e8cf2a5814c696aef4010 Mon Sep 17 00:00:00 2001 From: Marcin Wrona Date: Wed, 13 Nov 2024 12:25:38 -0500 Subject: [PATCH 3/4] Removing converters as autostrip=True is effectively the sameand we don't need to handle the decode logic manually --- phoebe/frontend/io.py | 2 -- tests/tests/test_legacy_parser/test_legacy_parser.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/phoebe/frontend/io.py b/phoebe/frontend/io.py index b4b67a7d1..72d45eb4a 100644 --- a/phoebe/frontend/io.py +++ b/phoebe/frontend/io.py @@ -469,8 +469,6 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True, filename, dtype='str', delimiter='=', - converters={0: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip(), - 1: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip()}, comments='#', filling_values='', autostrip=True diff --git a/tests/tests/test_legacy_parser/test_legacy_parser.py b/tests/tests/test_legacy_parser/test_legacy_parser.py index 24299c8a2..f7c66dce5 100644 --- a/tests/tests/test_legacy_parser/test_legacy_parser.py +++ b/tests/tests/test_legacy_parser/test_legacy_parser.py @@ -24,8 +24,6 @@ def _legacy_test(filename='default.phoebe', verbose=True): os.path.join(dir, filename), dtype='str', delimiter='=', - converters={0: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip(), - 1: lambda s: s.strip().decode() if isinstance(s, bytes) else s.strip()}, comments='#', filling_values='', autostrip=True From 97ad0f1213877682a323875622d6e5753b4c42f4 Mon Sep 17 00:00:00 2001 From: Marcin Wrona Date: Wed, 13 Nov 2024 12:42:31 -0500 Subject: [PATCH 4/4] Skip building i686 wheels. They are no longer supported by NumPy --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 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