diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index c5e55a73..595b02e8 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -164,7 +164,7 @@ jobs: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.11.1 + uses: pypa/cibuildwheel@v2.11.2 - name: List generated wheels run: | @@ -274,6 +274,7 @@ jobs: run: | pip install twine twine upload --skip-existing ./**/*.whl + twine upload --skip-existing ./**/*.tar.gz env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} @@ -282,6 +283,7 @@ jobs: uses: softprops/action-gh-release@v1 with: files: | + ./**/*.tar.gz ./**/*.whl ./**/*.zip ./**/*.pdf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8f072f9..7a7ce16c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,13 +13,14 @@ repos: "--force-sort-within-sections", "--skip-glob", "*__init__.py", ] -- repo: https://gitlab.com/PyCQA/flake8 - rev: 3.9.2 + +- repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 hooks: - id: flake8 - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.2 hooks: - id: codespell diff --git a/ansys/mapdl/reader/common.py b/ansys/mapdl/reader/common.py index 23549293..1dc867e9 100644 --- a/ansys/mapdl/reader/common.py +++ b/ansys/mapdl/reader/common.py @@ -301,7 +301,7 @@ def parse_header(table, keys): def two_ints_to_long(intl, inth): - """Interpert two ints as one long""" + """Interpret two ints as one long""" longint = struct.pack(">I", inth) + struct.pack(">I", intl) return struct.unpack(">q", longint)[0] diff --git a/ansys/mapdl/reader/cyclic_reader.py b/ansys/mapdl/reader/cyclic_reader.py index 29495f61..c1d89159 100644 --- a/ansys/mapdl/reader/cyclic_reader.py +++ b/ansys/mapdl/reader/cyclic_reader.py @@ -278,8 +278,7 @@ def _expand_cyclic_modal( result_expanded *= cjang.reshape(-1, 1, 1) if as_complex: return result_expanded - else: - return np.real(result_expanded) + return np.real(result_expanded) def _expand_cyclic_modal_tensor( self, result, result_r, hindex, phase, as_complex, full_rotor, stress=True @@ -1083,7 +1082,7 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal equivalent stress. """ if as_complex and full_rotor: - raise ValueError("complex and full_rotor cannot both be True") + raise ValueError("`complex` and `full_rotor` cannot both be True") # get component stress nnum, stress = self.nodal_stress(rnum, phase, as_complex, full_rotor) @@ -1093,6 +1092,11 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal stress_r = np.imag(stress) stress = np.real(stress) + if not stress.flags["C_CONTIGUOUS"]: + stress = np.ascontiguousarray(stress) + if not stress_r.flags["C_CONTIGUOUS"]: + stress_r = np.ascontiguousarray(stress_r) + pstress, isnan = _binary_reader.compute_principal_stress(stress) pstress[isnan] = np.nan pstress_r, isnan = _binary_reader.compute_principal_stress(stress_r) @@ -1100,7 +1104,7 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal return nnum, pstress + 1j * pstress_r - elif full_rotor: + if full_rotor: # compute principle stress for each sector pstress = np.empty((self.n_sector, stress.shape[1], 5), np.float64) for i in range(stress.shape[0]): @@ -1108,10 +1112,9 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal pstress[i, isnan] = np.nan return nnum, pstress - else: - pstress, isnan = _binary_reader.compute_principal_stress(stress) - pstress[isnan] = np.nan - return nnum, pstress + pstress, isnan = _binary_reader.compute_principal_stress(stress) + pstress[isnan] = np.nan + return nnum, pstress def plot_nodal_solution( self, @@ -1139,7 +1142,7 @@ def plot_nodal_solution( comp : str, optional Display component to display. Options are 'x', 'y', 'z', - and 'norm', corresponding to the x directin, y direction, + and 'norm', corresponding to the x direction, y direction, z direction, and the normalized direction: ``(x**2 + y**2 + z**2)**0.5`` diff --git a/ansys/mapdl/reader/rst.py b/ansys/mapdl/reader/rst.py index 1d16db82..e3777a47 100644 --- a/ansys/mapdl/reader/rst.py +++ b/ansys/mapdl/reader/rst.py @@ -609,7 +609,7 @@ def _load_section_data(self): table = self.read_record(ptr_sec + offset) self._section_data[int(table[0])] = table[1:] - # it might be possible to interpert the section data... + # it might be possible to interpret the section data... # sec[3] # total thickness # sec[4] # number of layers (?) # sec[5] # total integration points (?) @@ -1358,8 +1358,8 @@ def nodal_solution(self, rnum, in_nodal_coord_sys=False, nodes=None): Examples -------- - Return the nodal soltuion (in this case, displacement) for the - first result of ``"file.rst"`` + Return the nodal solution (in this case, displacement) for the + first result of ``"file.rst"``. >>> from ansys.mapdl import reader as pymapdl_reader >>> rst = pymapdl_reader.read_binary('file.rst') diff --git a/doc/source/conf.py b/doc/source/conf.py index 7a350708..58555d6b 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -120,7 +120,7 @@ ], # path where to save gallery generated examples "gallery_dirs": ["examples"], - # Patter to search for example files + # Pattern to search for example files "filename_pattern": r"\.py", # Remove the "Download all examples" button from the top level gallery # "download_all_examples": False, diff --git a/doc/source/user_guide/loading_results.rst b/doc/source/user_guide/loading_results.rst index 8028291d..1b7c5630 100644 --- a/doc/source/user_guide/loading_results.rst +++ b/doc/source/user_guide/loading_results.rst @@ -559,7 +559,7 @@ will return which modes are available: Available modes: [0 1 2 3 4 5 6 7 8 9] Results from a cyclic analysis require additional post processing to -be interperted correctly. Mode shapes are stored within the result +be interpreted correctly. Mode shapes are stored within the result file as unprocessed parts of the real and imaginary parts of a modal solution. ``ansys-mapdl-reader`` combines these values into a single complex array and then returns the real result of that array. diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index d7b7b88b..8e7988ec 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -1,9 +1,9 @@ Sphinx==5.3.0 -ansys-sphinx-theme==0.6.1 +ansys-sphinx-theme==0.7.1 notfound==1.0.2 -pypandoc==1.9 -pyvista==0.36.1 -sphinx-copybutton==0.5.0 +pypandoc==1.10 +pyvista==0.37.0 +sphinx-copybutton==0.5.1 sphinx-gallery==0.11.1 sphinx-notfound-page==0.8.3 vtk==9.2.2 diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index d4dbf7e6..b309614c 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -106,10 +106,25 @@ def test_nodal_cyclic_modal(academic_rotor, load_step, sub_step, rtype): # np.abs(pdiff).max() # this number is small (aprox 0.0002%) + # verify we can get complex results + nnum, stress = academic_rotor.principal_nodal_stress( + rnum, + as_complex=False, + ) + nnum_com, stress_com = academic_rotor.principal_nodal_stress( + rnum, + as_complex=True, + ) + assert np.allclose(np.real(stress_com), stress) + assert np.allclose(nnum, nnum_com) + + with pytest.raises(ValueError, match="cannot both be True"): + academic_rotor.principal_nodal_stress(rnum, as_complex=True, full_rotor=True) + def test_non_cyclic(): with pytest.raises(TypeError): - rst = CyclicResult(examples.rstfile) + CyclicResult(examples.rstfile) @skip_windows