Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy2 #982

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -56,4 +56,4 @@ jobs:
path: dist
merge-multiple: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions phoebe/backend/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion phoebe/dependencies/distl/distl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion phoebe/dependencies/ligeor/models/polyfit.py
Original file line number Diff line number Diff line change
@@ -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
kecnry marked this conversation as resolved.
Show resolved Hide resolved
from scipy.optimize import minimize
from phoebe.dependencies.ligeor.utils.lcutils import *
from phoebe.dependencies.ligeor.models import Model
Expand Down
10 changes: 8 additions & 2 deletions phoebe/frontend/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
kecnry marked this conversation as resolved.
Show resolved Hide resolved
)

morphology = params[:,1][list(params[:,0]).index('phoebe_model')]

Expand Down
12 changes: 10 additions & 2 deletions phoebe/parameters/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ classifiers = [
"Topic :: Software Development :: User Interfaces"
]
dependencies = [
"numpy < 2.0.0",
"numpy",
"scipy",
"astropy",
"pytest",
Expand All @@ -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]
Expand Down
12 changes: 9 additions & 3 deletions tests/tests/test_legacy_parser/test_legacy_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')])
Expand Down
Loading