From 7b38ba7e90e506e71cbbb9d9f2a6266ee30e68f4 Mon Sep 17 00:00:00 2001 From: osinjoku <49887472+osinjoku@users.noreply.github.com> Date: Fri, 12 Sep 2025 23:49:18 +1000 Subject: [PATCH 1/2] Fix return types and color band range (#5) * fix types and remove non-existing function * fix tests * fix color band range * increment patch number * fix range and tests * changelog * bring back function * more tests * missing include * typo * better docstrings * correctness * ws --- CHANGELOG.md | 36 +++++++++++++------ src/moldflow/constants.py | 2 +- src/moldflow/double_array.py | 7 ++-- src/moldflow/integer_array.py | 7 ++-- src/moldflow/plot.py | 15 ++++---- src/moldflow/string_array.py | 8 +++-- .../api/unit_tests/test_unit_double_array.py | 6 +++- .../api/unit_tests/test_unit_integer_array.py | 5 ++- tests/api/unit_tests/test_unit_plot.py | 2 +- .../api/unit_tests/test_unit_string_array.py | 5 ++- version.json | 2 +- 11 files changed, 63 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8cb0c1..fcf9136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- Initial public release -- Python API wrapper for Moldflow Synergy -- Comprehensive test suite -- Documentation with examples -- CI/CD pipeline for automated testing and publishing +- N/A ### Changed - N/A @@ -29,13 +25,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security - N/A -## [26.0.0] - 2025-XX-XX +## [26.0.1] - 2025-09-12 + +### Added +- N/A + +### Changed +- N/A + +### Deprecated +- N/A + +### Removed +- N/A + +### Fixed +- Fix return types for `from_list` functions in data classes +- Fix color band range options to 1 to 256 + +### Security +- N/A + +## [26.0.0] - 2025-09-01 ### Added -- Initial version aligned with Moldflow Synergy 2026 -- Basic API functionality -- Windows support +- Initial version aligned with Moldflow Synergy 2026.0.1 - Python 3.10-3.13 compatibility -[Unreleased]: https://github.com/Autodesk/moldflow-api/compare/v26.0.0...HEAD +[Unreleased]: https://github.com/Autodesk/moldflow-api/compare/v26.0.1...HEAD +[26.0.1]: https://github.com/Autodesk/moldflow-api/releases/tag/v26.0.1 [26.0.0]: https://github.com/Autodesk/moldflow-api/releases/tag/v26.0.0 diff --git a/src/moldflow/constants.py b/src/moldflow/constants.py index c785166..4851f3a 100644 --- a/src/moldflow/constants.py +++ b/src/moldflow/constants.py @@ -7,7 +7,7 @@ import os # Constants for color bands -COLOR_BAND_RANGE = tuple(list(range(2, 65)) + [256]) +COLOR_BAND_RANGE = tuple(range(1, 257)) # Localization constants DEFAULT_THREE_LETTER_CODE = "enu" diff --git a/src/moldflow/double_array.py b/src/moldflow/double_array.py index e2d16c5..be3cd28 100644 --- a/src/moldflow/double_array.py +++ b/src/moldflow/double_array.py @@ -67,12 +67,15 @@ def to_list(self) -> list[float]: vb_array = self.double_array.ToVBSArray() return list(vb_array) - def from_list(self, values: list[float]) -> None: + def from_list(self, values: list[float]) -> int: """ Convert a list of floats to a double array. Args: values (list[float]): The list of floats to convert. + + Returns: + int: The number of elements added to the array. """ process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list") @@ -80,7 +83,7 @@ def from_list(self, values: list[float]) -> None: for value in values: check_type(value, (int, float)) - self.double_array.FromVBSArray(list(values)) + return self.double_array.FromVBSArray(list(values)) @property def size(self) -> int: diff --git a/src/moldflow/integer_array.py b/src/moldflow/integer_array.py index f28221c..ab4c4a4 100644 --- a/src/moldflow/integer_array.py +++ b/src/moldflow/integer_array.py @@ -67,12 +67,15 @@ def to_list(self) -> list[int]: vb_array = self.integer_array.ToVBSArray() return list(vb_array) - def from_list(self, values: list[int]) -> None: + def from_list(self, values: list[int]) -> int: """ Convert a list of integers to an integer array. Args: values (list[int]): The list of integers to convert. + + Returns: + int: The number of elements added to the array. """ process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list") @@ -80,7 +83,7 @@ def from_list(self, values: list[int]) -> None: for value in values: check_type(value, int) - self.integer_array.FromVBSArray(list(values)) + return self.integer_array.FromVBSArray(list(values)) @property def size(self) -> int: diff --git a/src/moldflow/plot.py b/src/moldflow/plot.py index 1baeb13..0cdbf24 100644 --- a/src/moldflow/plot.py +++ b/src/moldflow/plot.py @@ -456,13 +456,11 @@ def extended_color(self, value: bool) -> None: @property def color_bands(self) -> int: """ - The number of color bands or smooth coloring. - - values between 2 through 64: banded coloring with this number of colors - - 256: smooth coloring + The number of color bands. + - values between 1 through 256: banded coloring with this number of colors - - :getter: Get the number of color bands or smooth coloring. - :setter: Set the number of color bands or smooth coloring. + :getter: Get the number of color bands. + :setter: Set the number of color bands. :type: int """ process_log(__name__, LogMessage.PROPERTY_GET, locals(), name="color_bands") @@ -471,9 +469,8 @@ def color_bands(self) -> int: @color_bands.setter def color_bands(self, value: int) -> None: """ - The number of color bands or smooth coloring. - - values between 2 through 64: banded coloring with this number of colors - - 256: smooth coloring + The number of color bands. + - values between 1 through 256: banded coloring with this number of colors Args: value (int): number of color bands or smooth coloring to set. diff --git a/src/moldflow/string_array.py b/src/moldflow/string_array.py index ca18c30..dcb953d 100644 --- a/src/moldflow/string_array.py +++ b/src/moldflow/string_array.py @@ -57,19 +57,21 @@ def add_string(self, value: str) -> None: def to_list(self) -> list[str]: """ Convert the string array to a list of strings. - Returns: list[str]: The list of strings. """ process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="to_list") return _mf_array_to_list(self) - def from_list(self, values: list[str]) -> None: + def from_list(self, values: list[str]) -> int: """ Convert a list of strings to a string array. Args: values (list[str]): The list of strings to convert. + + Returns: + int: The number of elements added to the array. """ process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list") check_type(values, (list, tuple)) @@ -77,7 +79,7 @@ def from_list(self, values: list[str]) -> None: for value in values: check_type(value, str) - self.string_array.FromVBSArray(list(values)) + return self.string_array.FromVBSArray(list(values)) @property def size(self) -> int: diff --git a/tests/api/unit_tests/test_unit_double_array.py b/tests/api/unit_tests/test_unit_double_array.py index d19a2e6..37d913b 100644 --- a/tests/api/unit_tests/test_unit_double_array.py +++ b/tests/api/unit_tests/test_unit_double_array.py @@ -72,7 +72,11 @@ def test_to_list(self, mock_double_array, mock_object, values): # pylint: disable=R0801 def test_from_list(self, mock_double_array, mock_object, values): """Test the from_list method of the DoubleArray class.""" - mock_double_array.from_list(values) + mock_object.FromVBSArray.return_value = len(values) + result = mock_double_array.from_list(values) + + assert isinstance(result, int) + assert result == len(values) mock_object.FromVBSArray.assert_called_once_with(list(values)) @pytest.mark.parametrize("invalid_values", INVALID_MOCK_WITH_NONE) diff --git a/tests/api/unit_tests/test_unit_integer_array.py b/tests/api/unit_tests/test_unit_integer_array.py index a6b838a..05a8aa8 100644 --- a/tests/api/unit_tests/test_unit_integer_array.py +++ b/tests/api/unit_tests/test_unit_integer_array.py @@ -65,8 +65,11 @@ def test_to_list(self, mock_integer_array, mock_object, values): # pylint: disable=R0801 def test_from_list(self, mock_integer_array, mock_object, values): """Test the from_list method of the IntegerArray class.""" - mock_integer_array.from_list(values) + mock_object.FromVBSArray.return_value = len(values) + result = mock_integer_array.from_list(values) + assert isinstance(result, int) + assert result == len(values) mock_object.FromVBSArray.assert_called_once_with(list(values)) @pytest.mark.parametrize("invalid_values", INVALID_MOCK_WITH_NONE) diff --git a/tests/api/unit_tests/test_unit_plot.py b/tests/api/unit_tests/test_unit_plot.py index 81870c1..1ffe6c1 100644 --- a/tests/api/unit_tests/test_unit_plot.py +++ b/tests/api/unit_tests/test_unit_plot.py @@ -441,7 +441,7 @@ def test_invalid_properties( @pytest.mark.parametrize( "pascal_name, property_name, value", [("SetMeshFill", "mesh_fill", x) for x in [-1.0, 2.0, 3.0]] - + [("SetColorBands", "color_bands", x) for x in [1, 65, 128]] + + [("SetColorBands", "color_bands", x) for x in [-1, 0, 257, 300]] + [("SetHistogramNumberOfBars", "histogram_number_of_bars", x) for x in [-1, -2, -3, -4]], ) # pylint: disable-next=R0913, R0917 diff --git a/tests/api/unit_tests/test_unit_string_array.py b/tests/api/unit_tests/test_unit_string_array.py index 05fe8de..fca95fa 100644 --- a/tests/api/unit_tests/test_unit_string_array.py +++ b/tests/api/unit_tests/test_unit_string_array.py @@ -82,8 +82,11 @@ def test_to_list(self, mock_string_array, mock_object, size, values): # pylint: disable=R0801 def test_from_list(self, mock_string_array, mock_object, values): """Test the from_list method of the StringArray class.""" - mock_string_array.from_list(values) + mock_object.FromVBSArray.return_value = len(values) + result = mock_string_array.from_list(values) + assert isinstance(result, int) + assert result == len(values) mock_object.FromVBSArray.assert_called_once() @pytest.mark.parametrize("invalid_values", INVALID_MOCK_WITH_NONE) diff --git a/version.json b/version.json index 38caf99..9e2172b 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "major": "26", "minor": "0", - "patch": "0" + "patch": "1" } From cb5f8d19dbff42497511e8d9627927507bb53355 Mon Sep 17 00:00:00 2001 From: osinjoku <49887472+osinjoku@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:41:46 +1000 Subject: [PATCH 2/2] point to pypi (#3) --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c07ad12..ad6cd11 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -84,7 +84,7 @@ jobs: $packageName = 'moldflow' try { - $resp = Invoke-WebRequest -Uri "https://test.pypi.org/pypi/$packageName/json" -UseBasicParsing -ErrorAction Stop + $resp = Invoke-WebRequest -Uri "https://pypi.org/pypi/$packageName/json" -UseBasicParsing -ErrorAction Stop $data = $resp.Content | ConvertFrom-Json $versions = @($data.releases.PSObject.Properties.Name) } catch { @@ -118,9 +118,9 @@ jobs: if: steps.pypi_check.outputs.exists == 'false' env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | - python run.py publish --skip-build --testpypi + python run.py publish --skip-build - name: Create GitHub Release if: steps.pypi_check.outputs.exists == 'false'