Skip to content

Commit fb283b3

Browse files
committed
Bump version to 0.1.1
2 parents f93e917 + 8e4c7a4 commit fb283b3

File tree

14 files changed

+132
-30
lines changed

14 files changed

+132
-30
lines changed

.github/workflows/ci_cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ jobs:
337337

338338

339339
release:
340-
name: "Release project to private PyPI and GitHub"
340+
name: "Release project to public PyPI and GitHub"
341341
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
342342
needs: [package]
343343
runs-on: ubuntu-latest
344344
steps:
345345

346346
- name: "Release to the public PyPI repository"
347-
uses: pyansys/actions/release-pypi-public@v3
347+
uses: pyansys/actions/release-pypi-public@v4
348348
with:
349349
library-name: ${{ env.PACKAGE_NAME }}
350350
twine-username: "__token__"

.github/workflows/label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
needs: labeler
7373
steps:
7474
- name: Suggest to add labels
75-
uses: peter-evans/create-or-update-comment@v2
75+
uses: peter-evans/create-or-update-comment@v3
7676
# Execute only when no labels have been applied to the pull request
7777
if: toJSON(github.event.pull_request.labels.*.name) == '{}'
7878
with:

README.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
PyAnsys Math
22
============
33

4-
|pyansys| |pypi| |PyPIact| |GH-CI| |codecov| |MIT| |black|
4+
|pyansys| |pypi| |GH-CI| |codecov| |MIT| |black|
55

66
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
77
:target: https://docs.pyansys.com/
88
:alt: PyAnsys
99

10-
.. |pypi| image:: https://img.shields.io/pypi/v/pyansys-math-core.svg?logo=python&logoColor=white
11-
:target: https://pypi.org/project/ansys-math-core/
12-
13-
.. |PyPIact| image:: https://img.shields.io/pypi/dm/pyansys-math-core.svg?label=PyPI%20downloads
10+
.. |pypi| image:: https://img.shields.io/pypi/v/ansys-math-core.svg?logo=python&logoColor=white
1411
:target: https://pypi.org/project/ansys-math-core/
1512

1613
.. |codecov| image:: https://codecov.io/gh/pyansys/pyansys-math/branch/main/graph/badge.svg
@@ -43,6 +40,11 @@ For users
4340
The ``ansys.math.core`` package currently supports Python 3.7 through
4441
Python 3.10 on Windows, Mac OS, and Linux.
4542

43+
.. warning::
44+
45+
``ansys.math.core`` will no longer support Python 3.7 by June 2023.
46+
47+
4648
Install the latest package for use with this command:
4749

4850
.. code::
@@ -80,7 +82,7 @@ Verify your installation
8082

8183
Check that you can start PyAnsys Math from Python by running this code:
8284

83-
.. code:: python
85+
.. code:: python3
8486
8587
import ansys.math.core.math as pymath
8688
File renamed without changes.
File renamed without changes.

doc/source/contributing/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ templates:
3232

3333
If your issue does not fit into one of these categories, create your own issue.
3434

35-
To reach the PyAnsys support team, email `pyansys.support@ansys.com <pyansys_support_>`_.
35+
To reach the PyAnsys support team, email `pyansys.core@ansys.com <[email protected]>`_.
3636

3737

3838
Build documentation

doc/source/index.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ the NumPy and SciPy linear algebra solvers and the PyAnsys Math solver:
3333
+--------------------------------------------+-----------------------------------+
3434
| NumPy and SciPy | PyAnsys Math |
3535
+============================================+===================================+
36-
| .. code:: python | .. code:: python |
36+
| .. code:: python3 | .. code:: python3 |
3737
| | |
3838
| k_py = k + sparse.triu(k, 1).T | k = mm.matrix(k_py, triu=True) |
3939
| m_py = m + sparse.triu(m, 1).T | m = mm.matrix(m_py, triu=True) |
@@ -63,7 +63,7 @@ Quick code
6363

6464
Here is a brief example of how you use PyAnsys Math:
6565

66-
.. code:: python
66+
.. code:: python3
6767
6868
import ansys.math.core.math as pymath
6969
@@ -75,7 +75,9 @@ Here is a brief example of how you use PyAnsys Math:
7575
7676
print(w)
7777
78-
.. code:: output
78+
.. rst-class:: sphx-glr-script-out
79+
80+
.. code-block:: none
7981
8082
UDWZKD :
8183
Size : 5
@@ -90,6 +92,7 @@ For comprehensive PyAnsys Math examples, see :ref:`ref_pymath_examples`.
9092
:maxdepth: 1
9193

9294
getting_started/index
93-
api_ref/index
95+
user_guide/index
96+
api/index
9497
examples/index
9598
contributing/index

doc/source/user_guide/arrays.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Handling arrays between PyAnsys Math and Python
3+
===============================================
4+
5+
6+
Sending arrays to PyAnsys Math
7+
------------------------------
8+
9+
.. code:: python3
10+
11+
import numpy as np
12+
import ansys.math.core.math as pymath
13+
14+
# Start PyAnsys Math as a service.
15+
mm = pymath.AnsMath()
16+
17+
a = np.random.random((2, 3))
18+
a_pymath = mm.matrix(a, name="A")
19+
20+
print(a_pymath)
21+
22+
.. rst-class:: sphx-glr-script-out
23+
24+
.. code-block:: none
25+
26+
A:
27+
[1,1]: 4.018e-01 [1,2]: 4.635e-01 [1,3]: 3.682e-01
28+
[2,1]: 9.711e-01 [2,2]: 7.601e-02 [2,3]: 8.833e-01
29+
30+
31+
32+
Transfer a PyAnsys Math matrix to NumPy
33+
---------------------------------------
34+
35+
.. code:: python3
36+
37+
a_python = a_pymath.asarray()
38+
print((a == a_python).all())
39+
40+
41+
.. rst-class:: sphx-glr-script-out
42+
43+
.. code-block:: none
44+
45+
True
46+
47+
48+
49+
50+

doc/source/user_guide/index.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. _ref_user_guide:
2+
3+
User guide
4+
==========
5+
6+
Overview
7+
--------
8+
9+
You can use the ``AnsMath()`` method to launch an instance of PyAnsys Math.
10+
11+
.. code:: python3
12+
13+
import ansys.math.core.math as pymath
14+
15+
# Start PyAnsys Math.
16+
mm = pymath.AnsMath()
17+
print(mm)
18+
19+
.. rst-class:: sphx-glr-script-out
20+
21+
.. code-block:: none
22+
23+
APDLMATH PARAMETER STATUS- ( 0 PARAMETERS DEFINED)
24+
25+
Name Type Mem. (MB) Dims Workspace
26+
27+
.. toctree::
28+
:hidden:
29+
:maxdepth: 1
30+
31+
arrays.rst

examples/scipy_sparse_matrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
out = mm._mapdl.input(vmfiles["vm153"])
2929
k = mm.stiff(fname="PRSMEMB.full")
30-
k
3130

3231
################################################################################
3332
# Copy AnsMath sparse matrix to SciPy CSR matrix and plot
@@ -36,7 +35,7 @@
3635
# graph of the sparse matrix.
3736

3837
pk = k.asarray()
39-
plt.spy(pk, color="orange")
38+
plt.spy(pk, color="orange", markersize=3)
4039
plt.title("AnsMath sparse matrix")
4140
plt.show()
4241

examples/solve_dense_matrix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@
7878
# Plot the elapsed times for PyAnsys Math and Numpy to solve the dense
7979
# matrix linear system.
8080
#
81+
max_time = max(pymath_time, numpy_time)
8182
fig = plt.figure(figsize=(12, 10))
8283
ax = plt.axes()
8384
x = ["PyAnsys Math", "NumPy"]
8485
y = [pymath_time, numpy_time]
8586
plt.title("Elapsed time to solve the linear system")
86-
plt.ylim([0, numpy_time + 1])
87+
plt.ylim([0, max_time + 0.2 * max_time])
8788
plt.ylabel("Elapsed time (s)")
8889
ax.bar(x, y, color="orange")
8990
plt.show()

examples/solve_sparse_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
# graph of the sparse matrix.
5858

5959
pk = k.asarray()
60-
plt.spy(pk, color="orange")
60+
plt.spy(pk, color="orange", markersize=3)
6161
plt.title("AnsMath sparse matrix")
6262
plt.show()
6363

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
55
[project]
66
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
77
name = "ansys-math-core"
8-
version = "0.1.0"
8+
version = "0.1.1"
99
description = "A Python wrapper for PyAnsys Math libraries."
1010
readme = "README.rst"
1111
requires-python = ">=3.7"
@@ -48,11 +48,11 @@ doc = [
4848
"Sphinx==5.3.0",
4949
"ansys-mapdl-core==0.64.0",
5050
"ansys-mapdl-reader==0.52.11",
51-
"ansys-sphinx-theme==0.9.5",
51+
"ansys-sphinx-theme==0.9.7",
5252
"jupyter_sphinx==0.4.0",
53-
"jupyterlab==3.6.2",
53+
"jupyterlab==3.6.3",
5454
"numpydoc==1.5.0",
55-
"pandas==1.5.3",
55+
"pandas==2.0.0",
5656
"pypandoc==1.11",
5757
"pytest-sphinx==0.5.0",
5858
"pyvista==0.38.5",

src/ansys/math/core/math.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,20 @@ def dot(self, vec) -> float:
14941494
self._mapdl.run(f"*DOT,{self.id},{vec.id},py_val")
14951495
return self._mapdl.scalar_param("py_val")
14961496

1497-
def asarray(self) -> np.ndarray:
1498-
"""Return this vector as a NumPy array.
1497+
def asarray(self, dtype=None) -> np.ndarray:
1498+
"""Return the vector as a NumPy array.
1499+
1500+
Parameters
1501+
----------
1502+
dtype : numpy.dtype, optional
1503+
NumPy data type to upload the array as. The options are `np.double <numpy.double>`_,
1504+
`np.int32 <numpy.int32>`_, and `np.int64 <numpy.int64>`_. The default is the current array
1505+
type.
1506+
1507+
Returns
1508+
-------
1509+
np.ndarray
1510+
NumPy array with the defined data type.
14991511
15001512
Examples
15011513
--------
@@ -1504,8 +1516,12 @@ def asarray(self) -> np.ndarray:
15041516
>>> v = mm.ones(10)
15051517
>>> v.asarray()
15061518
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
1519+
>>> v.asarray(dtype=np.int32)
1520+
[1 1 1 1 1 1 1 1 1 1]
1521+
15071522
"""
1508-
return self._mapdl._vec_data(self.id)
1523+
vec_data = self._mapdl._vec_data(self.id)
1524+
return vec_data.astype(dtype) if dtype else vec_data
15091525

15101526
def __array__(self):
15111527
"""Allow NumPy to access this object as if it was an array."""
@@ -1567,7 +1583,7 @@ def sym(self) -> bool:
15671583
return True
15681584

15691585
def asarray(self, dtype=None) -> np.ndarray:
1570-
"""Return the vector as a NumPy array.
1586+
"""Return the matrix as a NumPy array.
15711587
15721588
Parameters
15731589
----------
@@ -1585,11 +1601,11 @@ def asarray(self, dtype=None) -> np.ndarray:
15851601
--------
15861602
>>> import ansys.math.core.math as pymath
15871603
>>> mm = pymath.AnsMath()
1588-
>>> v = mm.ones(10)
1604+
>>> v = mm.ones(2,2)
15891605
>>> v.asarray()
1590-
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
1591-
>>> v.asarray(dtype=np.int)
1592-
[1 1 1 1 1 1 1 1 1 1]
1606+
array([[1., 1.], [1., 1.]])
1607+
>>> v.asarray(dtype=np.int32)
1608+
array([[1, 1], [1, 1]])
15931609
15941610
"""
15951611
if dtype:

0 commit comments

Comments
 (0)