Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rolling back static python and scipy for python3.8 support #2163

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ tests = [
"ansys-dpf-core==0.8.1",
"autopep8==2.0.2",
"matplotlib==3.7.1",
"scipy==1.11.1",
"scipy==1.10.1; python_version < '3.9'", # to support python 3.8
"scipy==1.11.1; python_version > '3.8'",
"pandas==2.0.3",
"pytest==7.4.0",
"pytest-cov==4.1.0",
Expand Down
22 changes: 16 additions & 6 deletions src/ansys/mapdl/core/component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
"""Component related module"""

from typing import TYPE_CHECKING, Any, Literal, Optional, Union, get_args
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
Literal,
Optional,
Tuple,
Union,
get_args,
)
import warnings
import weakref

Expand Down Expand Up @@ -36,8 +46,8 @@
}


ITEMS_VALUES = Optional[Union[str, int, list[int], NDArray[Any]]]
UNDERLYING_DICT = dict[str, ITEMS_VALUES]
ITEMS_VALUES = Optional[Union[str, int, List[int], NDArray[Any]]]
UNDERLYING_DICT = Dict[str, ITEMS_VALUES]

warning_entity = (
"Assuming a {default_entity} selection.\n"
Expand All @@ -49,7 +59,7 @@


def _check_valid_pyobj_to_entities(
items: Union[tuple[int, ...], list[int], NDArray[Any]]
items: Union[Tuple[int, ...], List[int], NDArray[Any]]
):
"""Check whether the python objects can be converted to entities.
At the moment, only list and numpy arrays of ints are allowed.
Expand All @@ -69,7 +79,7 @@ class Component(tuple):
type_ : str
The entity type. For instance "NODES", "KP", "VOLU", etc

items_ : None, str, int, list[int], np.array[int]]
items_ : None, str, int, List[int], np.array[int]]
Item ids contained in the component.

Examples
Expand Down Expand Up @@ -101,7 +111,7 @@ class Component(tuple):
def __new__(
cls,
type_: ENTITIES_TYP,
items_: tuple[str, Union[tuple[int], list[int], NDArray[np.int_]]],
items_: Tuple[str, Union[Tuple[int], List[int], NDArray[np.int_]]],
):
if not isinstance(type_, str) or type_.upper() not in VALID_ENTITIES:
raise ValueError(
Expand Down
26 changes: 13 additions & 13 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from subprocess import DEVNULL, call
import tempfile
import time
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union
import warnings
from warnings import warn
import weakref
Expand Down Expand Up @@ -245,7 +245,7 @@ def __init__(
self._platform = None

_sanitize_start_parm(start_parm)
self._start_parm: dict[str, Any] = start_parm
self._start_parm: Dict[str, Any] = start_parm
self._jobname: str = start_parm.get("jobname", "file")
self._path: Union[str, pathlib.Path] = start_parm.get("run_location", None)
self._print_com: bool = print_com # print the command /COM input.
Expand Down Expand Up @@ -1298,7 +1298,7 @@ def nplot(self, nnum="", vtk=None, **kwargs):
Shows the boundary conditions label per node.
Defaults to ``False``.

bc_labels : list[str], Tuple(str), optional
bc_labels : List[str], Tuple(str), optional
List or tuple of strings with the boundary conditions
to plot, i.e. ``["UX", "UZ"]``.
You can obtain the allowed boundary conditions by
Expand All @@ -1322,7 +1322,7 @@ def nplot(self, nnum="", vtk=None, **kwargs):
in the responses of :func:`ansys.mapdl.core.Mapdl.dlist`
and :func:`ansys.mapdl.core.Mapdl.flist()`.

bc_target : list[str], Tuple(str), optional
bc_target : List[str], Tuple(str), optional
Specify the boundary conditions target
to plot, i.e. "Nodes", "Elements".
You can obtain the allowed boundary conditions target by
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs):
Shows the boundary conditions label per node.
Defaults to ``False``.

bc_labels : list[str], Tuple(str), optional
bc_labels : List[str], Tuple(str), optional
List or tuple of strings with the boundary conditions
to plot, i.e. ``["UX", "UZ"]``.
You can obtain the allowed boundary conditions by
Expand All @@ -1466,7 +1466,7 @@ def eplot(self, show_node_numbering=False, vtk=None, **kwargs):
in the responses of :func:`ansys.mapdl.core.Mapdl.dlist`
and :func:`ansys.mapdl.core.Mapdl.flist()`.

bc_target : list[str], Tuple(str), optional
bc_target : List[str], Tuple(str), optional
Specify the boundary conditions target
to plot, i.e. "Nodes", "Elements".
You can obtain the allowed boundary conditions target by
Expand Down Expand Up @@ -2348,7 +2348,7 @@ def get_value(
it3num: Union[str, int, float] = "",
item4: Union[str, int, float] = "",
it4num: Union[str, int, float] = "",
**kwargs: dict[Any, Any],
**kwargs: Dict[Any, Any],
):
"""Runs the MAPDL GET command and returns a Python value.

Expand Down Expand Up @@ -2456,7 +2456,7 @@ def get(
it3num: Union[str, int, float] = "",
item4: Union[str, int, float] = "",
it4num: Union[str, int, float] = "",
**kwargs: dict[Any, Any],
**kwargs: Dict[Any, Any],
) -> Union[float, str]:
"""Retrieves a value and stores it as a scalar parameter or part of an array parameter.

Expand Down Expand Up @@ -3430,7 +3430,7 @@ def get_array(
item2: str = "",
it2num: Union[str, int, float] = "",
kloop: Union[str, int, float] = "",
**kwargs: dict[Any, Any],
**kwargs: Dict[Any, Any],
) -> NDArray:
"""Uses the ``*VGET`` command to Return an array from ANSYS as a
Python array.
Expand Down Expand Up @@ -3698,7 +3698,7 @@ def get_nodal_loads(self, label=None):

Returns
-------
list[list[Str]] or numpy.array
List[List[Str]] or numpy.array
If parameter ``label`` is give, the output is converted to a
numpy array instead of a list of list of strings.
"""
Expand All @@ -3723,7 +3723,7 @@ def get_nodal_constrains(self, label=None):

Returns
-------
list[list[Str]] or numpy.array
List[List[Str]] or numpy.array
If parameter ``label`` is give, the output is converted to a
numpy array instead of a list of list of strings.
"""
Expand Down Expand Up @@ -4450,7 +4450,7 @@ def __exit__(self, *args):
self._parent()._run("/nopr")
self._parent()._mute = self._previous_mute

def _parse_rlist(self) -> dict[int, float]:
def _parse_rlist(self) -> Dict[int, float]:
# mapdl.rmore(*list)
with self.force_output:
rlist = self.rlist()
Expand Down Expand Up @@ -4484,7 +4484,7 @@ def _parse_rlist(self) -> dict[int, float]:

return const_

def _parse_cmlist(self, cmlist: Optional[str] = None) -> dict[str, Any]:
def _parse_cmlist(self, cmlist: Optional[str] = None) -> Dict[str, Any]:
if not cmlist:
cmlist = self.cmlist()

Expand Down
32 changes: 16 additions & 16 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import tempfile
import threading
import time
from typing import TYPE_CHECKING, Literal, Optional, Union
from typing import TYPE_CHECKING, List, Literal, Optional, Tuple, Union
from warnings import warn
import weakref

Expand Down Expand Up @@ -361,7 +361,7 @@ def __init__(
self.__server_version: Optional[str] = None
self._state: Optional[grpc.Future] = None
self._timeout: int = timeout
self._pids: list[Union[int, None]] = []
self._pids: List[Union[int, None]] = []

if channel is None:
self._log.debug("Creating channel to %s:%s", ip, port)
Expand Down Expand Up @@ -1195,7 +1195,7 @@ def _remove_lock_file(self, mapdl_path=None):
except OSError:
pass

def list_files(self, refresh_cache: bool = True) -> list[str]:
def list_files(self, refresh_cache: bool = True) -> List[str]:
"""List the files in the working directory of MAPDL.

Parameters
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def download_result(
if path is None: # if not path seems to not work in same cases.
path = os.getcwd()

def _download(targets: list[str]) -> None:
def _download(targets: List[str]) -> None:
for target in targets:
save_name = os.path.join(path, target)
self._download(target, save_name, progress_bar=progress_bar)
Expand Down Expand Up @@ -2015,15 +2015,15 @@ def _get(

def download_project(
self,
extensions: Optional[Union[str, list[str], tuple[str]]] = None,
extensions: Optional[Union[str, List[str], Tuple[str]]] = None,
target_dir: Optional[str] = None,
progress_bar: bool = False,
) -> list[str]:
) -> List[str]:
"""Download all the project files located in the MAPDL working directory.

Parameters
----------
extensions : list[str], tuple[str], optional
extensions : List[str], Tuple[str], optional
List of extensions to filter the files before downloading,
by default None.

Expand All @@ -2037,7 +2037,7 @@ def download_project(

Returns
-------
list[Str]
List[Str]
List of downloaded files.
"""
if not extensions:
Expand All @@ -2061,20 +2061,20 @@ def download_project(

def download(
self,
files: Union[str, list[str], tuple[str, ...]],
files: Union[str, List[str], Tuple[str, ...]],
target_dir: Optional[str] = None,
extension: Optional[str] = None,
chunk_size: Optional[int] = None,
progress_bar: Optional[bool] = None,
recursive: bool = False,
) -> list[str]:
) -> List[str]:
"""Download files from the gRPC instance working directory

.. warning:: This feature is only available for MAPDL 2021R1 or newer.

Parameters
----------
files : str or list[str] or tuple(str)
files : str or List[str] or tuple(str)
Name of the file on the server. File must be in the same
directory as the mapdl instance. A list of string names or
tuples of string names can also be used.
Expand Down Expand Up @@ -2169,11 +2169,11 @@ def download(

def _download_on_local(
self,
files: Union[str, list[str], tuple[str, ...]],
files: Union[str, List[str], Tuple[str, ...]],
target_dir: str,
extension: Optional[str] = None,
recursive: bool = False,
) -> list[str]:
) -> List[str]:
"""Download files when we are on a local session."""

if isinstance(files, str):
Expand Down Expand Up @@ -2235,12 +2235,12 @@ def _download_on_local(

def _download_from_remote(
self,
files: Union[str, list[str], tuple[str, ...]],
files: Union[str, List[str], Tuple[str, ...]],
target_dir: str,
extension: Optional[str] = None,
chunk_size: Optional[str] = None,
progress_bar: Optional[str] = None,
) -> list[str]:
) -> List[str]:
"""Download files when we are connected to a remote session."""

if isinstance(files, str):
Expand Down Expand Up @@ -2273,7 +2273,7 @@ def _download_from_remote(

def _validate_files(
self, file: str, extension: Optional[str] = None, recursive: bool = True
) -> list[str]:
) -> List[str]:
if extension is not None:
if not isinstance(extension, str):
raise TypeError(f"The extension {extension} must be a string.")
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/mapdl/core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,21 @@ def general_plotter(
since they should be set when instantiated the provided plotter.
Defaults to ``None`` (create the Plotter object).

add_points_kwargs : list[dict]
add_points_kwargs : List[dict]
This is a dict or list of dicts to be passed to all or just the
correspondent :class:`pyvista.Plotter.add_points` call in
:func:`ansys.mapdl.core.plotting.general_plotter`.
This pyvista method is used to plot nodes for example.
See examples section to learn more about its usage.

add_mesh_kwargs : list[dict]
add_mesh_kwargs : List[dict]
This is a dict or list of dicts to be passed to all or just the
correspondent :class:`pyvista.Plotter.add_mesh` call in
:func:`ansys.mapdl.core.plotting.general_plotter`.
This pyvista method is used to plot elements for example.
See examples section to learn more about its usage.

add_point_labels_kwargs : list[dict]
add_point_labels_kwargs : List[dict]
This is a dict or list of dicts to be passed to all or just the
correspondent :class:`pyvista.Plotter.add_point_labels` call in
:func:`ansys.mapdl.core.plotting.general_plotter`.
Expand Down