Skip to content

Commit 1a50461

Browse files
authored
Drop support for NumPy 1.26 (#156)
1 parent 64e9b61 commit 1a50461

17 files changed

Lines changed: 67 additions & 64 deletions

File tree

‎.github/workflows/samples.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
run: |
4545
export NUM_PROC=$(nproc)
4646
export OMP_PROC_BIND=false OMP_NUM_THREADS=1
47+
export PRTE_MCA_hwloc_default_binding_policy=none
4748
module restore pymbe
4849
source venv/bin/activate
4950
make functional_tests -j${NUM_PROC}

‎.github/workflows/testsuite.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ jobs:
4444
modules: |-
4545
${{ matrix.software.eessi_modules }}
4646
extra-python-packages: |-
47-
pdoc==15.0.3
48-
pylint==3.0.3
49-
coverage==7.4.4
47+
pdoc==16.0.0
48+
pylint==4.0.5
49+
coverage==7.13.5
5050
- name: Run testsuite
5151
run: |
5252
export NUM_PROC=$(nproc)
5353
export OMP_PROC_BIND=false OMP_NUM_THREADS=1
54+
export PRTE_MCA_hwloc_default_binding_policy=none
5455
module restore pymbe
5556
source venv/bin/activate
5657
make pylint

‎README.md‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ git clone git@github.com:pyMBE-dev/pyMBE.git
6969
Please, be aware that pyMBE is intended to be a supporting tool to setup simulations with ESPResSo.
7070
Thus, for most of its functionalities ESPResSo must also be available.
7171
pyMBE supports ESPResSo 5.0 and ESPResSo 5.1-dev.
72-
Following the NEP29 guidelines, we recommend using Python3.11+.
73-
Both NumPy 1 and NumPy 2 are supported.
72+
Following the NEP29 guidelines, we recommend using Python3.12+.
73+
Only NumPy 2 is supported.
7474

7575
The pyMBE module needs a Python virtual environment to avoid compatibility issues with its dependencies.
7676
Any virtual environment manager should work, but this readme will use `venv`, which can be installed on Ubuntu as follows:
@@ -84,18 +84,12 @@ To set up pyMBE, users need to configure a virtual environment. This is achieved
8484
```sh
8585
python3 -m venv pymbe # create a local folder named pymbe containing the environment files
8686
source pymbe/bin/activate # activate the virtual environment
87-
python3 -m pip install -r requirements.txt "numpy<2.0" "pandas<2.0"
87+
python3 -m pip install -r requirements.txt
8888
python3 maintainer/configure_venv.py --espresso_path=/home/user/espresso/build # please adapt the espresso path accordingly
8989
python3 simulation_script.py # run a simulation script
9090
deactivate # deactivate the virtual environment
9191
```
9292

93-
NumPy 2 users should adapt the pip command as follows:
94-
95-
```sh
96-
python3 -m pip install -r requirements.txt "numpy>=2.1" "pandas>=2.0"
97-
```
98-
9993
We highlight that the path `/home/user/espresso/build` is just an example of a possible path to the ESPResSo build folder.
10094
The user should change this path to match the local absolute path where ESPResSo was built.
10195
Also, ESPResSo must be built with the same NumPy version as the one installed in the environment to avoid API version mismatch.
@@ -138,7 +132,7 @@ To use pyMBE in JupyterLab, install extra dependencies and register the virtual
138132

139133
```sh
140134
source pymbe/bin/activate
141-
python3 -m pip install ipykernel "jupyterlab>=4.0.8" "PyOpenGL>=3.1.5" "ipympl>=0.9.3"
135+
python3 -m pip install ipykernel "jupyterlab>=4.4.9" "PyOpenGL>=3.1.10" "ipympl>=0.10.0"
142136
python3 -m ipykernel install --user --name=pyMBE
143137
deactivate
144138
```

‎pyMBE/storage/base_type.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919

20-
from pydantic import BaseModel, Field
20+
from pydantic import BaseModel, Field, ConfigDict
2121

2222
class PMBBaseModel(BaseModel):
2323
"""
@@ -36,7 +36,4 @@ class PMBBaseModel(BaseModel):
3636

3737
pmb_type: str = Field(frozen=True)
3838
name: str
39-
40-
class Config:
41-
validate_assignment = True
42-
extra = "forbid"
39+
model_config = ConfigDict(validate_assignment=True, extra="forbid")

‎pyMBE/storage/instances/angle.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from typing import Literal
2121
from pyMBE.storage.base_type import PMBBaseModel
22-
from pydantic import validator
22+
from pydantic import field_validator, ValidationInfo
2323

2424
class AngleInstance(PMBBaseModel):
2525
"""
@@ -52,8 +52,9 @@ class AngleInstance(PMBBaseModel):
5252
particle_id3: int
5353
added_to_engine: bool = False
5454

55-
@validator("angle_id", "particle_id1", "particle_id2", "particle_id3")
56-
def validate_non_negative_int(cls, value, field):
55+
@field_validator("angle_id", "particle_id1", "particle_id2", "particle_id3")
56+
@classmethod
57+
def validate_non_negative_int(cls, value, info: ValidationInfo):
5758
if value < 0:
58-
raise ValueError(f"{field.name} must be a non-negative integer.")
59+
raise ValueError(f"{info.field_name} must be a non-negative integer.")
5960
return value

‎pyMBE/storage/instances/bond.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from typing import Literal
2121
from pyMBE.storage.base_type import PMBBaseModel
22-
from pydantic import validator
22+
from pydantic import field_validator, ValidationInfo
2323

2424
class BondInstance(PMBBaseModel):
2525
"""
@@ -55,9 +55,10 @@ class BondInstance(PMBBaseModel):
5555
particle_id2: int
5656
added_to_engine: bool = False
5757

58-
@validator("bond_id", "particle_id1", "particle_id2")
59-
def validate_non_negative_int(cls, value, field):
58+
@field_validator("bond_id", "particle_id1", "particle_id2")
59+
@classmethod
60+
def validate_non_negative_int(cls, value, info: ValidationInfo):
6061
if value < 0:
61-
raise ValueError(f"{field.name} must be a non-negative integer.")
62+
raise ValueError(f"{info.field_name} must be a non-negative integer.")
6263
return value
6364

‎pyMBE/storage/instances/hydrogel.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from typing import Literal
2121
from ..base_type import PMBBaseModel
22-
from pydantic import validator
22+
from pydantic import field_validator
2323

2424
class HydrogelInstance(PMBBaseModel):
2525
"""
@@ -43,7 +43,9 @@ class HydrogelInstance(PMBBaseModel):
4343
pmb_type: Literal["hydrogel"] = "hydrogel"
4444
assembly_id: int
4545
name: str
46-
@validator("assembly_id")
46+
47+
@field_validator("assembly_id")
48+
@classmethod
4749
def validate_assembly_id(cls, aid):
4850
if aid < 0:
4951
raise ValueError("assembly_id must be a non-negative integer.")

‎pyMBE/storage/instances/molecule.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
from pyMBE.storage.base_type import PMBBaseModel
21-
from pydantic import validator
21+
from pydantic import field_validator
2222
from typing import Literal, Optional
2323

2424
class MoleculeInstance(PMBBaseModel):
@@ -48,7 +48,7 @@ class MoleculeInstance(PMBBaseModel):
4848
molecule_id: int
4949
assembly_id: Optional[int] = None
5050

51-
@validator("molecule_id")
51+
@field_validator("molecule_id")
5252
def validate_residue_id(cls, mid):
5353
if mid < 0:
5454
raise ValueError("molecule_id must be a non-negative integer.")

‎pyMBE/storage/instances/particle.py‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from typing import Literal, Optional,List
2121
from numpy.typing import NDArray
22-
from pydantic import validator
22+
from pydantic import field_validator, ConfigDict
2323
from ..base_type import PMBBaseModel
2424

2525
class ParticleInstance(PMBBaseModel):
@@ -62,13 +62,10 @@ class ParticleInstance(PMBBaseModel):
6262
molecule_id: Optional[int] = None
6363
assembly_id: Optional[int] = None
6464
added_to_engine: bool = False
65-
66-
class Config:
67-
arbitrary_types_allowed=True
68-
validate_assignment = True
69-
extra = "forbid"
70-
71-
@validator("particle_id")
65+
model_config = ConfigDict(arbitrary_types_allowed=True, validate_assignment=True, extra="forbid")
66+
67+
@field_validator("particle_id")
68+
@classmethod
7269
def validate_particle_id(cls, pid):
7370
if pid < 0:
7471
raise ValueError("particle_id must be a non-negative integer.")

‎pyMBE/storage/instances/peptide.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
from pyMBE.storage.base_type import PMBBaseModel
21-
from pydantic import validator
21+
from pydantic import field_validator
2222
from typing import Literal, Optional
2323

2424

@@ -48,7 +48,8 @@ class PeptideInstance(PMBBaseModel):
4848
molecule_id: int
4949
assembly_id: Optional[int] = None
5050

51-
@validator("molecule_id")
51+
@field_validator("molecule_id")
52+
@classmethod
5253
def validate_residue_id(cls, mid):
5354
if mid < 0:
5455
raise ValueError("molecule_id must be a non-negative integer.")

0 commit comments

Comments
 (0)