Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Slowroll:Base:1
python-ase
ase-mr3400-numpy2.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ase-mr3400-numpy2.patch of Package python-ase
From 06c59143e7fdf15483491cf71800afba8b862bda Mon Sep 17 00:00:00 2001 From: yuzie007 <yuji.ikeda.ac.jp@gmail.com> Date: Thu, 20 Jun 2024 17:44:31 +0200 Subject: [PATCH 1/7] Use `np.exceptions.ComplexWarning` --- ase/test/vibrations/test_vib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) Index: ase-3.23.0/ase/test/vibrations/test_vib.py =================================================================== --- ase-3.23.0.orig/ase/test/vibrations/test_vib.py +++ ase-3.23.0/ase/test/vibrations/test_vib.py @@ -6,6 +6,10 @@ import numpy as np import pytest from numpy.testing import (assert_array_almost_equal, assert_array_equal) +try: + from numpy.exceptions import ComplexWarning # NumPy 2.0.0 +except ImportError: + from numpy import ComplexWarning import ase.io from ase import Atoms, units @@ -438,14 +442,14 @@ def test_constrained_atoms(n2_data): def test_dos(n2_vibdata): - with pytest.warns(np.ComplexWarning): + with pytest.warns(ComplexWarning): dos = n2_vibdata.get_dos() assert_array_almost_equal(dos.get_energies(), n2_vibdata.get_energies()) def test_pdos(n2_vibdata): - with pytest.warns(np.ComplexWarning): + with pytest.warns(ComplexWarning): pdos = n2_vibdata.get_pdos() assert_array_almost_equal(pdos[0].get_energies(), n2_vibdata.get_energies()) Index: ase-3.23.0/ase/constraints.py =================================================================== --- ase-3.23.0.orig/ase/constraints.py +++ ase-3.23.0/ase/constraints.py @@ -1161,19 +1161,19 @@ class FixInternals(FixConstraint): # Projection hh = [] for i, constraint in enumerate(self.constraints): - hh.append(aa[:, i] * np.row_stack(aa[:, i])) + hh.append(aa[:, i] * np.vstack(aa[:, i])) - txx = aa[:, self.n] * np.row_stack(aa[:, self.n]) - tyy = aa[:, self.n + 1] * np.row_stack(aa[:, self.n + 1]) - tzz = aa[:, self.n + 2] * np.row_stack(aa[:, self.n + 2]) - rxx = aa[:, self.n + 3] * np.row_stack(aa[:, self.n + 3]) - ryy = aa[:, self.n + 4] * np.row_stack(aa[:, self.n + 4]) - rzz = aa[:, self.n + 5] * np.row_stack(aa[:, self.n + 5]) + txx = aa[:, self.n] * np.vstack(aa[:, self.n]) + tyy = aa[:, self.n + 1] * np.vstack(aa[:, self.n + 1]) + tzz = aa[:, self.n + 2] * np.vstack(aa[:, self.n + 2]) + rxx = aa[:, self.n + 3] * np.vstack(aa[:, self.n + 3]) + ryy = aa[:, self.n + 4] * np.vstack(aa[:, self.n + 4]) + rzz = aa[:, self.n + 5] * np.vstack(aa[:, self.n + 5]) T = txx + tyy + tzz + rxx + ryy + rzz for vec in hh: T += vec - ff = np.dot(T, np.row_stack(ff)) - forces[:, :] -= np.dot(T, np.row_stack(ff)).reshape(-1, 3) + ff = np.dot(T, np.vstack(ff)) + forces[:, :] -= np.dot(T, np.vstack(ff)).reshape(-1, 3) def __repr__(self): constraints = [repr(constr) for constr in self.constraints] Index: ase-3.23.0/ase/mep/autoneb.py =================================================================== --- ase-3.23.0.orig/ase/mep/autoneb.py +++ ase-3.23.0/ase/mep/autoneb.py @@ -544,7 +544,7 @@ class AutoNEB: try: energies.append(a.get_potential_energy()) except RuntimeError: - energies.append(np.NaN) + energies.append(np.nan) return energies def get_energies_one_image(self, image): @@ -553,7 +553,7 @@ class AutoNEB: try: energy = image.get_potential_energy() except RuntimeError: - energy = np.NaN + energy = np.nan return energy def get_highest_energy_index(self): Index: ase-3.23.0/ase/dft/__init__.py =================================================================== --- ase-3.23.0.orig/ase/dft/__init__.py +++ ase-3.23.0/ase/dft/__init__.py @@ -1,4 +1,8 @@ import numpy as np +try: + from numpy import trapezoid # NumPy 2.0.0 +except ImportError: + from numpy import trapz as trapezoid from ase.dft.dos import DOS from ase.dft.kpoints import monkhorst_pack @@ -19,9 +23,9 @@ def get_distribution_moment(x, y, order= y = np.asarray(y) if order == 0: - return np.trapz(y, x) + return trapezoid(y, x) elif isinstance(order, int): - return np.trapz(x**order * y, x) / np.trapz(y, x) + return trapezoid(x**order * y, x) / trapezoid(y, x) elif hasattr(order, '__iter__'): return [get_distribution_moment(x, y, n) for n in order] else: Index: ase-3.23.0/ase/md/switch_langevin.py =================================================================== --- ase-3.23.0.orig/ase/md/switch_langevin.py +++ ase-3.23.0/ase/md/switch_langevin.py @@ -1,6 +1,10 @@ from typing import Any, List, Optional import numpy as np +try: + from numpy import trapezoid # NumPy 2.0.0 +except ImportError: + from numpy import trapz as trapezoid from ase import Atoms from ase.calculators.mixing import MixedCalculator @@ -117,7 +121,7 @@ class SwitchLangevin(Langevin): lambdas = self.path_data[:, 1] U1 = self.path_data[:, 2] U2 = self.path_data[:, 3] - delta_F = np.trapz(U2 - U1, lambdas) + delta_F = trapezoid(U2 - U1, lambdas) return delta_F Index: ase-3.23.0/ase/test/calculator/test_harmonic.py =================================================================== --- ase-3.23.0.orig/ase/test/calculator/test_harmonic.py +++ ase-3.23.0/ase/test/calculator/test_harmonic.py @@ -1,6 +1,10 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal +try: + from numpy import trapezoid # NumPy 2.0.0 +except ImportError: + from numpy import trapz as trapezoid from ase import Atoms from ase.calculators.calculator import CalculationFailed, CalculatorSetupError @@ -266,7 +270,7 @@ def test_thermodynamic_integration(): e0, e1 = calc_linearCombi.get_energy_contributions(atoms) ediffs[lamb].append(float(e1) - float(e0)) ediffs[lamb] = np.mean(ediffs[lamb]) - dA = np.trapz([ediffs[lamb] for lamb in lambs], x=lambs) # anharm. corr. + dA = trapezoid([ediffs[lamb] for lamb in lambs], x=lambs) # anharm. corr. assert -0.005 < dA < 0.005 # the MD run is to short for convergence if dA == 0.0: raise ValueError('there is most likely something wrong, but it could ' Index: ase-3.23.0/ase/io/octopus/input.py =================================================================== --- ase-3.23.0.orig/ase/io/octopus/input.py +++ ase-3.23.0/ase/io/octopus/input.py @@ -516,7 +516,7 @@ def atoms2kwargs(atoms, use_ase_cell): if atoms.cell.orthorhombic: Lsize = 0.5 * np.diag(cell) - kwargs['lsize'] = [[repr(size) for size in Lsize]] + kwargs['lsize'] = [[str(size) for size in Lsize]] # ASE uses (0...cell) while Octopus uses -L/2...L/2. # Lsize is really cell / 2, and we have to adjust our # positions by subtracting Lsize (see construction of the coords @@ -533,7 +533,7 @@ def atoms2kwargs(atoms, use_ase_cell): if sym is None: raise ValueError('Cannot represent atom X without tags and ' 'species info in atoms.info') - coord_block.append([repr(sym)] + [repr(x) for x in pos]) + coord_block.append([repr(sym)] + [str(x) for x in pos]) kwargs[coordtype] = coord_block npbc = sum(atoms.pbc) Index: ase-3.23.0/ase/dft/band_structure.py =================================================================== --- ase-3.23.0.orig/ase/dft/band_structure.py +++ ase-3.23.0/ase/dft/band_structure.py @@ -1,6 +1,9 @@ import warnings -from numpy import VisibleDeprecationWarning +try: + from numpy.exceptions import VisibleDeprecationWarning # NumPy 2.0.0 +except ImportError: + from numpy import VisibleDeprecationWarning from ase.spectrum.band_structure import * # noqa: F401,F403 Index: ase-3.23.0/ase/test/test_imports.py =================================================================== --- ase-3.23.0.orig/ase/test/test_imports.py +++ ase-3.23.0/ase/test/test_imports.py @@ -3,7 +3,10 @@ from importlib import import_module from pathlib import Path import pytest -from numpy import VisibleDeprecationWarning +try: + from numpy.exceptions import VisibleDeprecationWarning # NumPy 2.0.0 +except ImportError: + from numpy import VisibleDeprecationWarning import ase
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor