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

adapt for numpy v2 #338

Merged
merged 10 commits into from
Jun 21, 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
11 changes: 10 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Changelog
=========

.. X.Y.0 / 2023-MM-DD (Unreleased)
.. X.Y.0 / 2024-MM-DD (Unreleased)
.. -------------------
..
.. Breaking Changes
Expand All @@ -20,6 +20,15 @@ Changelog
.. +++++


0.28.0 / 2024-06-19
-------------------

Enhancements
++++++++++++
- (:pr:`338`) Adapts for numpy v2 (only works with pint >= v0.24). v1 still compatible.
- (:pr:`335`, :issue:`334`) Numpy >=1.26 only works with pint >=0.21. @


0.27.1 / 2023-10-26
-------------------

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ classifiers = [
[tool.poetry.dependencies]
numpy = [
{ version = ">=1.12.0", python = "3.8" },
{ version = ">=1.26.1,<2.0", python = ">=3.9,<3.10" },
{ version = ">=1.26.1", python = ">=3.9,<3.13" },
]
# qcel is compatible with most any numpy, v1 or v2, but numpy v2 only works with pint >=0.24, which is only available for py >=3.10
python = "^3.7"
pint = [
{ version = ">=0.10", python = ">=3.7,<3.9" },
{ version = ">=0.21", python = ">=3.9,<3.13" },
{ version = ">=0.23", python = ">=3.9,<3.10" },
{ version = ">=0.24", python = ">=3.10,<3.13" },
]
pydantic = ">=1.8.2"
nglview = { version = "^3.0.3", optional = true }
Expand Down
6 changes: 5 additions & 1 deletion qcelemental/models/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ def __init__(self, orient: bool = False, validate: Optional[bool] = None, **kwar
values = self.__dict__

if validate:
values["symbols"] = np.core.defchararray.title(self.symbols) # Title case for consistency
# Title case for consistency
if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1":
values["symbols"] = np.char.chararray.title(self.symbols)
else:
values["symbols"] = np.core.defchararray.title(self.symbols)

if orient:
values["geometry"] = float_prep(self._orient_molecule_internal(), geometry_noise)
Expand Down
2 changes: 1 addition & 1 deletion qcelemental/models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
items = {"type": "number", "multipleOf": 1.0}
elif dt is float or np.issubdtype(dt, np.floating):
items = {"type": "number"}
elif dt is str or np.issubdtype(dt, np.string_):
elif dt is str or np.issubdtype(dt, np.bytes_):
items = {"type": "string"}
elif dt is bool or np.issubdtype(dt, np.bool_):
items = {"type": "boolean"}
Expand Down
2 changes: 1 addition & 1 deletion qcelemental/tests/test_datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_complex_scalar():


def test_complex_array():
datum1 = qcel.Datum("complex array", "", np.arange(3, dtype=np.complex_) + 1j)
datum1 = qcel.Datum("complex array", "", np.arange(3, dtype=np.complex128) + 1j)
ans = {
"label": "complex array",
"units": "",
Expand Down
Loading