From 111283a0e0184e1674ef29ec0bd873a099574096 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= <jgrad@icp.uni-stuttgart.de>
Date: Tue, 18 Apr 2023 10:46:51 +0200
Subject: [PATCH] python: Update deprecated setuptools functionality

Starting with setuptools v67.3.0, the pkg_resources module is being
progressively phased out from the setuptools main module.
---
 doc/tutorials/constant_pH/constant_pH.ipynb     | 4 ++--
 maintainer/benchmarks/mc_acid_base_reservoir.py | 4 ++--
 testsuite/python/unittest_decorators.py         | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/tutorials/constant_pH/constant_pH.ipynb b/doc/tutorials/constant_pH/constant_pH.ipynb
index bcfd5bdf993..ca4029465a4 100644
--- a/doc/tutorials/constant_pH/constant_pH.ipynb
+++ b/doc/tutorials/constant_pH/constant_pH.ipynb
@@ -137,10 +137,10 @@
     "plt.rcParams.update({'font.size': 18})\n",
     "\n",
     "import numpy as np\n",
-    "import setuptools\n",
+    "import pkg_resources\n",
     "import pint  # module for working with units and dimensions\n",
     "import time\n",
-    "assert setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \\\n",
+    "assert pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \\\n",
     "  f'pint version {pint.__version__} is too old: several numpy operations can cast away the unit'\n",
     "\n",
     "import espressomd\n",
diff --git a/maintainer/benchmarks/mc_acid_base_reservoir.py b/maintainer/benchmarks/mc_acid_base_reservoir.py
index 97e465e8c70..a7a7a965f73 100644
--- a/maintainer/benchmarks/mc_acid_base_reservoir.py
+++ b/maintainer/benchmarks/mc_acid_base_reservoir.py
@@ -24,7 +24,7 @@
 import espressomd
 import espressomd.electrostatics
 import espressomd.reaction_methods
-import setuptools
+import pkg_resources
 import argparse
 
 parser = argparse.ArgumentParser(description="Benchmark MC simulations in the grand-reaction ensemble. "
@@ -45,7 +45,7 @@
 # process and check arguments
 assert args.particles_per_core >= 100, "you need to use at least 100 particles per core to avoid finite-size effects in the simulation"
 espressomd.assert_features(['WCA', 'ELECTROSTATICS'])
-assert setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \
+assert pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \
     f'pint version {pint.__version__} is too old: several numpy operations can cast away the unit'
 
 
diff --git a/testsuite/python/unittest_decorators.py b/testsuite/python/unittest_decorators.py
index 109f89cc8d7..a9a0e5200c4 100644
--- a/testsuite/python/unittest_decorators.py
+++ b/testsuite/python/unittest_decorators.py
@@ -19,7 +19,7 @@
 
 import sys
 import importlib
-import setuptools
+import pkg_resources
 import unittest
 
 import espressomd
@@ -74,7 +74,7 @@ def skipIfUnmetModuleVersionRequirement(module, version_requirement):
         _module = importlib.import_module(module)
     except ImportError:
         return skipIfMissingModules(module)
-    if not setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet(
+    if not pkg_resources.packaging.specifiers.SpecifierSet(
             version_requirement).contains(_module.__version__):
         return unittest.skip(
             "Skipping test: version requirement not met for module {}".format(module))
From bff5e2703d4371f06f281d48181431558066d566 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= <jgrad@icp.uni-stuttgart.de>
Date: Tue, 20 Dec 2022 19:36:34 +0100
Subject: [PATCH] tests: Replace deprecated numpy option

Option 'normed' in numpy.histogramdd was deprecated since 1.15 and
removed in 1.24.
---
 testsuite/python/observable_profile.py   | 2 +-
 testsuite/python/observable_profileLB.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuite/python/observable_profile.py b/testsuite/python/observable_profile.py
index 9692449185b..0a7b7eafff5 100644
--- a/testsuite/python/observable_profile.py
+++ b/testsuite/python/observable_profile.py
@@ -51,7 +51,7 @@ def test_density_profile(self):
         obs_bin_centers = density_profile.bin_centers()
         np_hist, np_edges = tests_common.get_histogram(
             np.copy(self.system.part.all().pos), self.kwargs, 'cartesian',
-            normed=True)
+            density=True)
         np_hist *= len(self.system.part)
         np.testing.assert_array_almost_equal(obs_data, np_hist)
         for i in range(3):
diff --git a/testsuite/python/observable_profileLB.py b/testsuite/python/observable_profileLB.py
index 4a3527035da..6770cea8e50 100644
--- a/testsuite/python/observable_profileLB.py
+++ b/testsuite/python/observable_profileLB.py
@@ -91,7 +91,7 @@ def test_velocity_profile(self):
         obs_edges = obs.call_method("edges")
         _, np_edges = tests_common.get_histogram(
             np.zeros([1, 3]), LB_VELOCITY_PROFILE_PARAMS, 'cartesian',
-            normed=True)
+            density=True)
         for i in range(3):
             np.testing.assert_array_almost_equal(obs_edges[i], np_edges[i])
         for x in range(obs_data.shape[0]):
