Skip to content

Commit

Permalink
Bump version to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
clatapie committed Apr 12, 2023
2 parents f93e917 + 8e4c7a4 commit fb283b3
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ jobs:


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

- name: "Release to the public PyPI repository"
uses: pyansys/actions/release-pypi-public@v3
uses: pyansys/actions/release-pypi-public@v4
with:
library-name: ${{ env.PACKAGE_NAME }}
twine-username: "__token__"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
needs: labeler
steps:
- name: Suggest to add labels
uses: peter-evans/create-or-update-comment@v2
uses: peter-evans/create-or-update-comment@v3
# Execute only when no labels have been applied to the pull request
if: toJSON(github.event.pull_request.labels.*.name) == '{}'
with:
Expand Down
14 changes: 8 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
PyAnsys Math
============

|pyansys| |pypi| |PyPIact| |GH-CI| |codecov| |MIT| |black|
|pyansys| |pypi| |GH-CI| |codecov| |MIT| |black|

.. |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
:target: https://docs.pyansys.com/
:alt: PyAnsys

.. |pypi| image:: https://img.shields.io/pypi/v/pyansys-math-core.svg?logo=python&logoColor=white
:target: https://pypi.org/project/ansys-math-core/

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

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

.. warning::

``ansys.math.core`` will no longer support Python 3.7 by June 2023.


Install the latest package for use with this command:

.. code::
Expand Down Expand Up @@ -80,7 +82,7 @@ Verify your installation

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

.. code:: python
.. code:: python3
import ansys.math.core.math as pymath
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/source/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ templates:

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

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


Build documentation
Expand Down
11 changes: 7 additions & 4 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ the NumPy and SciPy linear algebra solvers and the PyAnsys Math solver:
+--------------------------------------------+-----------------------------------+
| NumPy and SciPy | PyAnsys Math |
+============================================+===================================+
| .. code:: python | .. code:: python |
| .. code:: python3 | .. code:: python3 |
| | |
| k_py = k + sparse.triu(k, 1).T | k = mm.matrix(k_py, triu=True) |
| m_py = m + sparse.triu(m, 1).T | m = mm.matrix(m_py, triu=True) |
Expand Down Expand Up @@ -63,7 +63,7 @@ Quick code

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

.. code:: python
.. code:: python3
import ansys.math.core.math as pymath
Expand All @@ -75,7 +75,9 @@ Here is a brief example of how you use PyAnsys Math:
print(w)
.. code:: output
.. rst-class:: sphx-glr-script-out

.. code-block:: none
UDWZKD :
Size : 5
Expand All @@ -90,6 +92,7 @@ For comprehensive PyAnsys Math examples, see :ref:`ref_pymath_examples`.
:maxdepth: 1

getting_started/index
api_ref/index
user_guide/index
api/index
examples/index
contributing/index
50 changes: 50 additions & 0 deletions doc/source/user_guide/arrays.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

Handling arrays between PyAnsys Math and Python
===============================================


Sending arrays to PyAnsys Math
------------------------------

.. code:: python3
import numpy as np
import ansys.math.core.math as pymath
# Start PyAnsys Math as a service.
mm = pymath.AnsMath()
a = np.random.random((2, 3))
a_pymath = mm.matrix(a, name="A")
print(a_pymath)
.. rst-class:: sphx-glr-script-out

.. code-block:: none
A:
[1,1]: 4.018e-01 [1,2]: 4.635e-01 [1,3]: 3.682e-01
[2,1]: 9.711e-01 [2,2]: 7.601e-02 [2,3]: 8.833e-01
Transfer a PyAnsys Math matrix to NumPy
---------------------------------------

.. code:: python3
a_python = a_pymath.asarray()
print((a == a_python).all())
.. rst-class:: sphx-glr-script-out

.. code-block:: none
True
31 changes: 31 additions & 0 deletions doc/source/user_guide/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. _ref_user_guide:

User guide
==========

Overview
--------

You can use the ``AnsMath()`` method to launch an instance of PyAnsys Math.

.. code:: python3
import ansys.math.core.math as pymath
# Start PyAnsys Math.
mm = pymath.AnsMath()
print(mm)
.. rst-class:: sphx-glr-script-out

.. code-block:: none
APDLMATH PARAMETER STATUS- ( 0 PARAMETERS DEFINED)
Name Type Mem. (MB) Dims Workspace
.. toctree::
:hidden:
:maxdepth: 1

arrays.rst
3 changes: 1 addition & 2 deletions examples/scipy_sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

out = mm._mapdl.input(vmfiles["vm153"])
k = mm.stiff(fname="PRSMEMB.full")
k

################################################################################
# Copy AnsMath sparse matrix to SciPy CSR matrix and plot
Expand All @@ -36,7 +35,7 @@
# graph of the sparse matrix.

pk = k.asarray()
plt.spy(pk, color="orange")
plt.spy(pk, color="orange", markersize=3)
plt.title("AnsMath sparse matrix")
plt.show()

Expand Down
3 changes: 2 additions & 1 deletion examples/solve_dense_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@
# Plot the elapsed times for PyAnsys Math and Numpy to solve the dense
# matrix linear system.
#
max_time = max(pymath_time, numpy_time)
fig = plt.figure(figsize=(12, 10))
ax = plt.axes()
x = ["PyAnsys Math", "NumPy"]
y = [pymath_time, numpy_time]
plt.title("Elapsed time to solve the linear system")
plt.ylim([0, numpy_time + 1])
plt.ylim([0, max_time + 0.2 * max_time])
plt.ylabel("Elapsed time (s)")
ax.bar(x, y, color="orange")
plt.show()
Expand Down
2 changes: 1 addition & 1 deletion examples/solve_sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# graph of the sparse matrix.

pk = k.asarray()
plt.spy(pk, color="orange")
plt.spy(pk, color="orange", markersize=3)
plt.title("AnsMath sparse matrix")
plt.show()

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
[project]
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
name = "ansys-math-core"
version = "0.1.0"
version = "0.1.1"
description = "A Python wrapper for PyAnsys Math libraries."
readme = "README.rst"
requires-python = ">=3.7"
Expand Down Expand Up @@ -48,11 +48,11 @@ doc = [
"Sphinx==5.3.0",
"ansys-mapdl-core==0.64.0",
"ansys-mapdl-reader==0.52.11",
"ansys-sphinx-theme==0.9.5",
"ansys-sphinx-theme==0.9.7",
"jupyter_sphinx==0.4.0",
"jupyterlab==3.6.2",
"jupyterlab==3.6.3",
"numpydoc==1.5.0",
"pandas==1.5.3",
"pandas==2.0.0",
"pypandoc==1.11",
"pytest-sphinx==0.5.0",
"pyvista==0.38.5",
Expand Down
32 changes: 24 additions & 8 deletions src/ansys/math/core/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,8 +1494,20 @@ def dot(self, vec) -> float:
self._mapdl.run(f"*DOT,{self.id},{vec.id},py_val")
return self._mapdl.scalar_param("py_val")

def asarray(self) -> np.ndarray:
"""Return this vector as a NumPy array.
def asarray(self, dtype=None) -> np.ndarray:
"""Return the vector as a NumPy array.
Parameters
----------
dtype : numpy.dtype, optional
NumPy data type to upload the array as. The options are `np.double <numpy.double>`_,
`np.int32 <numpy.int32>`_, and `np.int64 <numpy.int64>`_. The default is the current array
type.
Returns
-------
np.ndarray
NumPy array with the defined data type.
Examples
--------
Expand All @@ -1504,8 +1516,12 @@ def asarray(self) -> np.ndarray:
>>> v = mm.ones(10)
>>> v.asarray()
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
>>> v.asarray(dtype=np.int32)
[1 1 1 1 1 1 1 1 1 1]
"""
return self._mapdl._vec_data(self.id)
vec_data = self._mapdl._vec_data(self.id)
return vec_data.astype(dtype) if dtype else vec_data

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

def asarray(self, dtype=None) -> np.ndarray:
"""Return the vector as a NumPy array.
"""Return the matrix as a NumPy array.
Parameters
----------
Expand All @@ -1585,11 +1601,11 @@ def asarray(self, dtype=None) -> np.ndarray:
--------
>>> import ansys.math.core.math as pymath
>>> mm = pymath.AnsMath()
>>> v = mm.ones(10)
>>> v = mm.ones(2,2)
>>> v.asarray()
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
>>> v.asarray(dtype=np.int)
[1 1 1 1 1 1 1 1 1 1]
array([[1., 1.], [1., 1.]])
>>> v.asarray(dtype=np.int32)
array([[1, 1], [1, 1]])
"""
if dtype:
Expand Down

0 comments on commit fb283b3

Please sign in to comment.