Skip to content

Commit

Permalink
Bumps pydantic to version 2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPaulSharp committed May 30, 2024
1 parent a708a2f commit 5898ddc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = 'setuptools.build_meta'
dependencies = [
'numpy >= 1.20',
'prettytable>=3.9.0',
'pydantic>=2.4.2,<=2.6.4',
'pydantic>=2.7.2',
'StrEnum>=0.4.15; python_version<"3.11"',
]

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy >= 1.20
prettytable >= 3.9.0
pybind11 >= 2.4
pydantic >= 2.4.2, <= 2.6.4
pydantic >= 2.7.2
pytest >= 7.4.0
pytest-cov >= 4.1.0
matplotlib >= 3.8.3
Expand Down
46 changes: 23 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,28 @@ def build_libraries(self, libraries):


setup(
name = 'RAT',
version = __version__,
author = '',
author_email = '',
url = 'https://github.com/RascalSoftware/python-RAT',
description = 'Python extension for the Reflectivity Analysis Toolbox (RAT)',
packages = find_packages(),
include_package_data = True,
package_data = {'': [get_shared_object_name(libevent[0])]},
cmdclass = {'build_clib': BuildClib, 'build_ext': BuildExt},
libraries = [libevent],
ext_modules = ext_modules,
python_requires = '>=3.9',
install_requires = ['numpy >= 1.20', 'prettytable >= 3.9.0', 'pydantic >= 2.4.2, <= 2.6.4', 'matplotlib >= 3.8.3'],
extras_require = {':python_version < "3.11"': ['StrEnum >= 0.4.15'],
'Dev': ['pytest>=7.4.0', 'pytest-cov>=4.1.0'],
'Matlab_latest': ['matlabengine'],
'Matlab_2023b': ['matlabengine == 23.2.1'],
'Matlab_2023a': ['matlabengine == 9.14.3'],
'Matlab-2022b': ['matlabengine == 9.13.9'],
'Matlab_2022a': ['matlabengine == 9.12.19'],
'Matlab_2021b': ['matlabengine == 9.11.21'],
'Matlab_2021a': ['matlabengine == 9.10.3']},
name='RAT',
version=__version__,
author='',
author_email='',
url='https://github.com/RascalSoftware/python-RAT',
description='Python extension for the Reflectivity Analysis Toolbox (RAT)',
packages=find_packages(),
include_package_data=True,
package_data={'': [get_shared_object_name(libevent[0])]},
cmdclass={'build_clib': BuildClib, 'build_ext': BuildExt},
libraries=[libevent],
ext_modules=ext_modules,
python_requires='>=3.9',
install_requires=['numpy >= 1.20', 'prettytable >= 3.9.0', 'pydantic >= 2.7.2', 'matplotlib >= 3.8.3'],
extras_require={':python_version < "3.11"': ['StrEnum >= 0.4.15'],
'Dev': ['pytest>=7.4.0', 'pytest-cov>=4.1.0'],
'Matlab_latest': ['matlabengine'],
'Matlab_2023b': ['matlabengine == 23.2.1'],
'Matlab_2023a': ['matlabengine == 9.14.3'],
'Matlab-2022b': ['matlabengine == 9.13.9'],
'Matlab_2022a': ['matlabengine == 9.12.19'],
'Matlab_2021b': ['matlabengine == 9.11.21'],
'Matlab_2021a': ['matlabengine == 9.10.3']},
zip_safe=False,
)
18 changes: 6 additions & 12 deletions tests/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ def test_calculate_property_setters(self, control_property: str, value: Any) ->
setattr(self.calculate, control_property, value)
assert getattr(self.calculate, control_property) == value

@pytest.mark.parametrize("var1, var2", [('test', True), ('ALL', 1), ("Contrast", 3.0)])
def test_calculate_parallel_validation(self, var1: str, var2: Any) -> None:
@pytest.mark.parametrize("value", ['test', 'ALL', 'Contrast', True, 1, 3.0])
def test_calculate_parallel_validation(self, value: Any) -> None:
"""Tests the parallel setter validation in Calculate class."""
with pytest.raises(pydantic.ValidationError) as exp:
setattr(self.calculate, 'parallel', var1)
setattr(self.calculate, 'parallel', value)
assert exp.value.errors()[0]['msg'] == "Input should be 'single', 'points' or 'contrasts'"
with pytest.raises(pydantic.ValidationError) as exp:
setattr(self.calculate, 'parallel', var2)
assert exp.value.errors()[0]['msg'] == "Input should be a valid string"

@pytest.mark.parametrize("value", [5.0, 12])
def test_calculate_calcSldDuringFit_validation(self, value: Union[int, float]) -> None:
Expand All @@ -54,15 +51,12 @@ def test_calculate_calcSldDuringFit_validation(self, value: Union[int, float]) -
setattr(self.calculate, 'calcSldDuringFit', value)
assert exp.value.errors()[0]['msg'] == "Input should be a valid boolean, unable to interpret input"

@pytest.mark.parametrize("var1, var2", [('test', True), ('iterate', 1), ("FINAL", 3.0)])
def test_calculate_display_validation(self, var1: str, var2: Any) -> None:
@pytest.mark.parametrize("value", ['test', 'iterate', "FINAL", True, 1, 3.0])
def test_calculate_display_validation(self, value: Any) -> None:
"""Tests the display setter validation in Calculate class."""
with pytest.raises(pydantic.ValidationError) as exp:
setattr(self.calculate, 'display', var1)
setattr(self.calculate, 'display', value)
assert exp.value.errors()[0]['msg'] == "Input should be 'off', 'iter', 'notify' or 'final'"
with pytest.raises(pydantic.ValidationError) as exp:
setattr(self.calculate, 'display', var2)
assert exp.value.errors()[0]['msg'] == "Input should be a valid string"

@pytest.mark.parametrize("value, msg", [
([5.0], "List should have at least 2 items after validation, not 1"),
Expand Down

0 comments on commit 5898ddc

Please sign in to comment.