Accepting request 1200197 from devel:languages:python:numeric

OBS-URL: https://build.opensuse.org/request/show/1200197
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python3-espressomd?expand=0&rev=22
This commit is contained in:
Ana Guerrero 2024-09-12 14:56:38 +00:00 committed by Git OBS Bridge
commit 9ef8e4b0c4
4 changed files with 149 additions and 1 deletions

33
cmake.patch Normal file
View File

@ -0,0 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac0432c34..bff6f289b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,13 @@ if(POLICY CMP0148)
cmake_policy(SET CMP0148 OLD)
endif()
+if(POLICY CMP0167)
+ # use BoostConfig.cmake shipped with Boost 1.70+ instead of the one in CMake
+ cmake_policy(SET CMP0167 NEW)
+endif()
# CMake modules/macros are in a subdirectory to keep this file cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+project(ESPResSo)
+
# C++ standard
enable_language(CXX)
@@ -49,5 +55,4 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include(FeatureSummary)
include(GNUInstallDirs)
-project(ESPResSo)
include(option_enum)
if(POLICY CMP0074)
@@ -268,7 +273,5 @@ if(WITH_STOKESIAN_DYNAMICS)
set(STOKESIAN_DYNAMICS 1)
if(NOT stokesian_dynamics_POPULATED)
- FetchContent_Populate(stokesian_dynamics)
- add_subdirectory(${stokesian_dynamics_SOURCE_DIR}
- ${stokesian_dynamics_BINARY_DIR})
+ FetchContent_MakeAvailable(stokesian_dynamics)
endif()
endif(WITH_STOKESIAN_DYNAMICS)

100
numpy.patch Normal file
View File

@ -0,0 +1,100 @@
diff --git a/testsuite/python/brownian_dynamics.py b/testsuite/python/brownian_dynamics.py
index 223340e15..f99d94018 100644
--- a/testsuite/python/brownian_dynamics.py
+++ b/testsuite/python/brownian_dynamics.py
@@ -161,5 +161,5 @@ class BrownianThermostat(ut.TestCase):
system.integrator.run(3)
np.testing.assert_allclose(
- part.omega_lab, [0, 0, 1.3 / 1.5], atol=1e-14)
+ np.copy(part.omega_lab), [0, 0, 1.3 / 1.5], atol=1e-14)
# noise only
@@ -168,5 +168,5 @@ class BrownianThermostat(ut.TestCase):
kT=1, gamma=1, gamma_rotation=1.5, act_on_virtual=False, seed=41)
system.integrator.run(3)
- self.assertGreater(np.linalg.norm(part.omega_lab), 0.)
+ self.assertGreater(np.linalg.norm(np.copy(part.omega_lab)), 0.)
diff --git a/testsuite/python/lees_edwards.py b/testsuite/python/lees_edwards.py
index 002340bd2..4539f1af5 100644
--- a/testsuite/python/lees_edwards.py
+++ b/testsuite/python/lees_edwards.py
@@ -397,5 +397,5 @@ class LeesEdwards(ut.TestCase):
a=k_non_bonded / 2, n=-2, cutoff=r_cut)
system.integrator.run(0)
- r_12 = system.distance_vec(p1, p2)
+ r_12 = np.copy(system.distance_vec(p1, p2))
np.testing.assert_allclose(
@@ -405,5 +405,5 @@ class LeesEdwards(ut.TestCase):
np.testing.assert_allclose(
np.copy(system.analysis.pressure_tensor()["non_bonded"]),
- np.outer(r_12, p2.f) / system.volume())
+ np.outer(r_12, np.copy(p2.f)) / system.volume())
np.testing.assert_almost_equal(
@@ -438,5 +438,5 @@ class LeesEdwards(ut.TestCase):
shear_direction="x", shear_plane_normal="y", protocol=lin_protocol)
# Test position and velocity of VS with Le shift
- old_p3_pos = p3.pos
+ old_p3_pos = np.copy(p3.pos)
expected_p3_pos = old_p3_pos - \
np.array((get_lin_pos_offset(system.time, **params_lin), 0, 0))
@@ -444,5 +444,5 @@ class LeesEdwards(ut.TestCase):
np.testing.assert_allclose(np.copy(p3.pos_folded), expected_p3_pos)
np.testing.assert_allclose(
- p3.v, p1.v + np.array((params_lin["shear_velocity"], 0, 0)))
+ np.copy(p3.v), np.copy(p1.v) + np.array((params_lin["shear_velocity"], 0, 0)))
# Check distances
diff --git a/testsuite/python/test_checkpoint.py b/testsuite/python/test_checkpoint.py
index f295cec44..4b30aaefb 100644
--- a/testsuite/python/test_checkpoint.py
+++ b/testsuite/python/test_checkpoint.py
@@ -217,12 +217,12 @@ class CheckpointTest(ut.TestCase):
np.testing.assert_allclose(np.copy(p3.ext_torque), [0.3, 0.5, 0.7])
if espressomd.has_features('ROTATIONAL_INERTIA'):
- np.testing.assert_allclose(p3.rinertia, [2., 3., 4.])
+ np.testing.assert_allclose(np.copy(p3.rinertia), [2., 3., 4.])
if espressomd.has_features('THERMOSTAT_PER_PARTICLE'):
gamma = 2.
if espressomd.has_features('PARTICLE_ANISOTROPY'):
gamma = np.array([2., 3., 4.])
- np.testing.assert_allclose(p4.gamma, gamma)
+ np.testing.assert_allclose(np.copy(p4.gamma), gamma)
if espressomd.has_features('ROTATION'):
- np.testing.assert_allclose(p3.gamma_rot, 2. * gamma)
+ np.testing.assert_allclose(np.copy(p3.gamma_rot), 2. * gamma)
if espressomd.has_features('ENGINE'):
self.assertEqual(p3.swimming, {"f_swim": 0.03, "mode": "N/A",
@@ -237,9 +237,11 @@ class CheckpointTest(ut.TestCase):
q_ind = ([1, 2, 3, 0],) # convert from scalar-first to scalar-last
vs_id, vs_dist, vs_quat = p2.vs_relative
- d = p2.pos - p1.pos
+ d = np.copy(p2.pos - p1.pos)
+ vs_quat = np.copy(vs_quat)
+ p_quat = np.copy(p1.quat)
theta = np.arccos(d[2] / np.linalg.norm(d))
assert abs(theta - 3. * np.pi / 4.) < 1e-8
q = np.array([0., 0., np.sin(theta / 2.), -np.cos(theta / 2.)])
- r = R.from_quat(p1.quat[q_ind]) * R.from_quat(vs_quat[q_ind])
+ r = R.from_quat(p_quat[q_ind]) * R.from_quat(vs_quat[q_ind])
self.assertEqual(vs_id, p1.id)
np.testing.assert_allclose(vs_dist, np.sqrt(2.))
@@ -500,5 +502,5 @@ class CheckpointTest(ut.TestCase):
self.assertEqual(p_virt.vs_relative[1], np.sqrt(2.))
np.testing.assert_allclose(
- p_real.vs_relative[2], [1., 0., 0., 0.], atol=1e-10)
+ np.copy(p_real.vs_relative[2]), [1., 0., 0., 0.], atol=1e-10)
def test_mean_variance_calculator(self):
@@ -785,6 +787,6 @@ class CheckpointTest(ut.TestCase):
p2 = system.part.add(pos=[system.box_l[0] - 1., 1.6, 0.], type=6)
system.integrator.run(0, recalc_forces=True)
- np.testing.assert_allclose(p1.f, [0., 1e8, 0.], atol=1e-3)
- np.testing.assert_allclose(p2.f, [0., 1e8, 0.], atol=1e-3)
+ np.testing.assert_allclose(np.copy(p1.f), [0., 1e8, 0.], atol=1e-3)
+ np.testing.assert_allclose(np.copy(p2.f), [0., 1e8, 0.], atol=1e-3)
p1.remove()
p2.remove()

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Sep 11 19:01:36 UTC 2024 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>
- Fix numpy.patch
-------------------------------------------------------------------
Wed Sep 11 18:36:23 UTC 2024 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>
- Add numpy.patch to improve NumPy 2.0 compatibility (gh#espressomd/espresso#4992)
- Add cmake.patch to address CMake warnings (gh#espressomd/espresso#4992)
-------------------------------------------------------------------
Wed May 22 16:08:22 UTC 2024 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>

View File

@ -28,6 +28,10 @@ Summary: Parallel simulation software for soft matter research
License: GPL-3.0-or-later
URL: http://espressomd.org
Source: https://github.com/%{modname}/%{pkgname}/releases/download/%{version}/%{pkgname}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM numpy.patch gh#espressomd/espresso#4992
Patch0: numpy.patch
# PATCH-FIX-UPSTREAM cmake.patch gh#espressomd/espresso#4992
Patch1: cmake.patch
# According to gh#espressomd/espresso#4537 32bit architectures are not supported any more
ExcludeArch: %{ix86} armv7l
BuildRequires: cmake
@ -43,7 +47,7 @@ BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_mpi-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_test-devel
BuildRequires: python3-Cython < 3
BuildRequires: python3-Cython < 3.0.10
BuildRequires: python3-devel
BuildRequires: python3-h5py
BuildRequires: python3-numpy-devel