Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended or did your IDE remove the spaces somehow? We need to get a linter/formatter soon to avoid unnecessary reformatting as the code grows

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as I was updating this file pydantic moaned at me about these spaces. Agreed on sorting a linter soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does pydantic have a linter? how is it concerned with the setup.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh - pyCHARM is what I meant.

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