From 169eff68e92b94a6b238029c20a675851f28978c Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:36:41 +0000 Subject: [PATCH 1/3] Bumps python version to 3.10 and matlab engine version to 2023a --- .github/workflows/build_wheel.yml | 2 +- .github/workflows/run_tests.yml | 2 +- CONTRIBUTING.md | 2 +- setup.py | 10 ++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index 6d6c896a..7f0205b5 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -15,7 +15,7 @@ jobs: env: CIBW_SKIP: 'pp*' CIBW_ARCHS: 'auto64' - CIBW_PROJECT_REQUIRES_PYTHON: '>=3.9' + CIBW_PROJECT_REQUIRES_PYTHON: '>=3.10' CIBW_TEST_REQUIRES: 'pytest' defaults: run: diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 99582ff8..e07c6f90 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-13] - version: ["3.9", "3.13"] + version: ["3.10", "3.13"] defaults: run: shell: bash -l {0} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 157a515f..6980c2c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ issue has not been reported already) or submitting a pull request. Create Developer Environment ---------------------------- -This project targets Python 3.9 or later. Install an appropriate version of Python and other dependencies +This project targets Python 3.10 or later. Install an appropriate version of Python and other dependencies Then create a fork of the python-RAT repo, and clone the fork diff --git a/setup.py b/setup.py index 84e7c9ce..a3bb0ea4 100644 --- a/setup.py +++ b/setup.py @@ -165,7 +165,7 @@ def build_libraries(self, libraries): cmdclass={"build_clib": BuildClib, "build_ext": BuildExt}, libraries=[libevent], ext_modules=ext_modules, - python_requires=">=3.9", + python_requires=">=3.10", install_requires=[ "numpy >= 1.20", "prettytable >= 3.9.0", @@ -178,13 +178,11 @@ def build_libraries(self, libraries): ':python_version < "3.11"': ["StrEnum >= 0.4.15"], "Dev": ["pytest>=7.4.0", "pytest-cov>=4.1.0", "ruff>=0.4.10"], "Matlab_latest": ["matlabengine"], - "Matlab_2024a": ["matlabengine == 24.1.*"], + "Matlab_2025a": ["matlabengine == 25.1.*"], + "Matlab_2024b": ["matlabengine == 24.2.2"], + "Matlab_2024a": ["matlabengine == 24.1.4"], "Matlab_2023b": ["matlabengine == 23.2.3"], "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, ) From 6bfdf676cb189d6de7a528b2a988fea627e94427 Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Tue, 4 Mar 2025 12:35:51 +0000 Subject: [PATCH 2/3] Adds ability to use "set_fields" with parameter names --- RATapi/classlist.py | 6 +++++- tests/test_classlist.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RATapi/classlist.py b/RATapi/classlist.py index 23e85477..c3e1d04f 100644 --- a/RATapi/classlist.py +++ b/RATapi/classlist.py @@ -296,11 +296,15 @@ def extend(self, other: Sequence[T]) -> None: self._check_unique_name_fields(other) self.data.extend(other) - def set_fields(self, index: int, **kwargs) -> None: + def set_fields(self, index: Union[int, slice, str, T], **kwargs) -> None: """Assign the values of an existing object's attributes using keyword arguments.""" self._validate_name_field(kwargs) pydantic_object = False + # Find index if name or object is supplied + if isinstance(index, (str, self._class_handle)): + index = self.index(index) + if importlib.util.find_spec("pydantic"): # Pydantic is installed, so set up a context manager that will # suppress custom validation errors until all fields have been set. diff --git a/tests/test_classlist.py b/tests/test_classlist.py index 18b75151..6dd3e35e 100644 --- a/tests/test_classlist.py +++ b/tests/test_classlist.py @@ -729,6 +729,7 @@ def test_extend_empty_classlist(extended_list: Sequence, one_name_class_list: Cl assert isinstance(extended_list[-1], class_list._class_handle) +@pytest.mark.parametrize("index", [0, "Alice"]) @pytest.mark.parametrize( ["new_values", "expected_classlist"], [ @@ -739,10 +740,12 @@ def test_extend_empty_classlist(extended_list: Sequence, one_name_class_list: Cl ), ], ) -def test_set_fields(two_name_class_list: ClassList, new_values: dict[str, Any], expected_classlist: ClassList) -> None: +def test_set_fields( + two_name_class_list: ClassList, index: Union[int, str], new_values: dict[str, Any], expected_classlist: ClassList +) -> None: """We should be able to set field values in an element of a ClassList using keyword arguments.""" class_list = two_name_class_list - class_list.set_fields(0, **new_values) + class_list.set_fields(index, **new_values) assert class_list == expected_classlist From 67a7eaabbd2f8c353dd25e83354182ba3715115f Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:21:00 +0000 Subject: [PATCH 3/3] Addresses review comment --- tests/test_classlist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_classlist.py b/tests/test_classlist.py index 6dd3e35e..3fa874ab 100644 --- a/tests/test_classlist.py +++ b/tests/test_classlist.py @@ -729,7 +729,7 @@ def test_extend_empty_classlist(extended_list: Sequence, one_name_class_list: Cl assert isinstance(extended_list[-1], class_list._class_handle) -@pytest.mark.parametrize("index", [0, "Alice"]) +@pytest.mark.parametrize("index", [0, "Alice", InputAttributes(name="Alice")]) @pytest.mark.parametrize( ["new_values", "expected_classlist"], [