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

Update supported python versions #360

Merged
merged 3 commits into from
Oct 10, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# docker images on the windows agents. See the issue
# https://github.com/actions/runner-images/issues/1143
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']
fail-fast: false
steps:
- name: "Login in Github Container registry"
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox tox-gh-actions
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: "Build a wheelhouse of the Python library"
uses: ansys/actions/build-wheelhouse@v4
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py39-plus]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PyDPF Composites
:target: https://docs.pyansys.com/
:alt: PyAnsys

.. |python| image:: https://img.shields.io/badge/Python-%3E%3D3.8-blue
.. |python| image:: https://img.shields.io/badge/Python-%3E%3D3.9-blue
:target: https://pypi.org/project/ansys-dpf-composites/
:alt: Python

Expand Down Expand Up @@ -197,4 +197,4 @@ released versions.
.. _tox: https://tox.wiki/
.. _Examples: https://composites.dpf.docs.pyansys.com/version/stable/examples/index.html
.. _Getting The DPF Server Docker Image: https://composites.dpf.docs.pyansys.com/version/stable/intro.html#getting-the-dpf-server-docker-image
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/
.. _Ansys DPF: https://dpf.docs.pyansys.com/version/stable/
2,696 changes: 1,280 additions & 1,416 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
python = ">=3.9,<3.13"
packaging = "*"
numpy = "^1.22"
build = {version = "^0.8.0", optional = true}
Expand Down Expand Up @@ -119,6 +119,6 @@ ignored-classes = [
]

[tool.mypy]
python_version = 3.8
python_version = 3.9
mypy_path = "$MYPY_CONFIG_FILE_DIR/src:$MYPY_CONFIG_FILE_DIR/tests"
ignore_missing_imports = true
9 changes: 5 additions & 4 deletions src/ansys/dpf/composites/_composite_model_impl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Composite Model Interface."""
# New interface after 2023 R2
from typing import Any, Callable, Collection, Dict, List, Optional, Sequence, cast
from collections.abc import Collection, Sequence
from typing import Any, Callable, Optional, cast
from warnings import warn

import ansys.dpf.core as dpf
Expand Down Expand Up @@ -145,7 +146,7 @@ def material_operators(self) -> MaterialOperators:
return self._material_operators

@property
def material_names(self) -> Dict[str, int]:
def material_names(self) -> dict[str, int]:
"""
Material name to DPF material ID map.

Expand Down Expand Up @@ -524,7 +525,7 @@ def get_constant_property_dict(
self,
material_properties: Collection[MaterialProperty],
composite_definition_label: Optional[str] = None,
) -> Dict[np.int64, Dict[MaterialProperty, float]]:
) -> dict[np.int64, dict[MaterialProperty, float]]:
"""Get a dictionary with constant properties.

This method returns a dictionary with ``dpf_material_id`` as the key and
Expand Down Expand Up @@ -606,7 +607,7 @@ def add_interlaminar_normal_stresses(
def get_all_layered_element_ids(self) -> Sequence[int]:
"""Get all layered element IDs."""
return cast(
List[int],
list[int],
self.get_mesh().property_field("element_layer_indices").scoping.ids,
)

Expand Down
11 changes: 6 additions & 5 deletions src/ansys/dpf/composites/_composite_model_impl_2023r2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Composite Model Interface 2023R2."""
from typing import Collection, Dict, List, Optional, Sequence, cast
from collections.abc import Collection, Sequence
from typing import Optional, cast
from warnings import warn

import ansys.dpf.core as dpf
Expand Down Expand Up @@ -129,7 +130,7 @@ def __init__(
engineering_data_source=self._data_sources.engineering_data,
)

self._composite_infos: Dict[str, CompositeInfo] = {}
self._composite_infos: dict[str, CompositeInfo] = {}
for composite_definition_label in self._data_sources.old_composite_sources:
self._composite_infos[composite_definition_label] = CompositeInfo(
data_sources=self._data_sources,
Expand Down Expand Up @@ -194,7 +195,7 @@ def material_operators(self) -> MaterialOperators:
return self._material_operators

@property
def material_names(self) -> Dict[str, int]:
def material_names(self) -> dict[str, int]:
"""Get material name to DPF material ID map."""
raise NotImplementedError(
"material_names is not implemented"
Expand Down Expand Up @@ -476,7 +477,7 @@ def get_constant_property_dict(
self,
material_properties: Collection[MaterialProperty],
composite_definition_label: Optional[str] = None,
) -> Dict[np.int64, Dict[MaterialProperty, float]]:
) -> dict[np.int64, dict[MaterialProperty, float]]:
"""Get a dictionary with constant properties.

Returns a dictionary with ``dpf_material_id`` as the key and
Expand Down Expand Up @@ -584,7 +585,7 @@ def get_all_layered_element_ids_for_composite_definition_label(
" Or update the the latest version."
)
return cast(
List[int],
list[int],
self.get_mesh(composite_definition_label)
.property_field("element_layer_indices")
.scoping.ids,
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/dpf/composites/_sampling_point_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Wrapper for the sampling point operator."""
from typing import Any, Collection, Dict, List, Sequence, cast
from collections.abc import Collection, Sequence
from typing import Any, cast

from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -70,7 +71,7 @@ def _next(outer_data: Any, comp: str) -> Any:


def get_indices_from_sp(
interface_indices: Dict[Spot, int],
interface_indices: dict[Spot, int],
number_of_plies: int,
spots_per_ply: int,
spots: Collection[Spot] = (Spot.BOTTOM, Spot.MIDDLE, Spot.TOP),
Expand Down Expand Up @@ -124,7 +125,7 @@ def get_offsets_by_spots_from_sp(

def get_ply_wise_critical_failures_from_sp(
sampling_point: SamplingPoint,
) -> List[FailureResult]:
) -> list[FailureResult]:
"""Get the critical failure value and modes per ply."""
num_plies = sampling_point.number_of_plies

Expand Down
7 changes: 4 additions & 3 deletions src/ansys/dpf/composites/composite_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Composite Model."""
from typing import Collection, Dict, Optional, Sequence
from collections.abc import Collection, Sequence
from typing import Optional

import ansys.dpf.core as dpf
from ansys.dpf.core import FieldsContainer, MeshedRegion, Operator, UnitSystem
Expand Down Expand Up @@ -107,7 +108,7 @@ def material_operators(self) -> MaterialOperators:
return self._implementation.material_operators

@property
def material_names(self) -> Dict[str, int]:
def material_names(self) -> dict[str, int]:
"""Get material name to DPF material ID map."""
return self._implementation.material_names

Expand Down Expand Up @@ -303,7 +304,7 @@ def get_constant_property_dict(
self,
material_properties: Collection[MaterialProperty],
composite_definition_label: Optional[str] = None,
) -> Dict[np.int64, Dict[MaterialProperty, float]]:
) -> dict[np.int64, dict[MaterialProperty, float]]:
"""Get a dictionary with constant properties.

Returns a dictionary with ``dpf_material_id`` as the key and
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/dpf/composites/composite_scope.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Composite Scope."""
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Optional, Sequence
from typing import Optional


@dataclass(frozen=True)
Expand Down
23 changes: 12 additions & 11 deletions src/ansys/dpf/composites/data_sources.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Composite data sources."""
from collections.abc import Sequence
from dataclasses import dataclass
import os
import pathlib
from typing import Callable, Dict, List, Optional, Sequence, Union, cast
from typing import Callable, Optional, Union, cast

from ansys.dpf.core import DataSources

Expand Down Expand Up @@ -45,17 +46,17 @@ class CompositeDefinitionFiles:
class ContinuousFiberCompositesFiles:
"""Provides the container for continuous fiber composite file paths."""

rst: List[_PATH]
composite: Dict[str, CompositeDefinitionFiles]
rst: list[_PATH]
composite: dict[str, CompositeDefinitionFiles]
engineering_data: _PATH
# True if files are local and false if files
# have already been uploaded to the server
files_are_local: bool = True

def __init__(
self,
rst: Union[List[_PATH], _PATH],
composite: Dict[str, CompositeDefinitionFiles],
rst: Union[list[_PATH], _PATH],
composite: dict[str, CompositeDefinitionFiles],
engineering_data: _PATH,
files_are_local: bool = True,
) -> None:
Expand Down Expand Up @@ -89,7 +90,7 @@ def __setattr__(self, prop, val): # type: ignore
super().__setattr__(prop, val)

@staticmethod
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
def _get_rst_list(value: Union[list[_PATH], _PATH]) -> list[_PATH]:
if isinstance(value, (str, pathlib.Path)):
value = [value]
return value # type: ignore
Expand All @@ -99,7 +100,7 @@ def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
class ShortFiberCompositesFiles:
"""Provides the container for short fiber composite file paths."""

rst: List[_PATH]
rst: list[_PATH]
dsdat: _PATH
engineering_data: _PATH
# True if files are local and false if files
Expand All @@ -108,7 +109,7 @@ class ShortFiberCompositesFiles:

def __init__(
self,
rst: Union[List[_PATH], _PATH],
rst: Union[list[_PATH], _PATH],
dsdat: _PATH,
engineering_data: _PATH,
files_are_local: bool = True,
Expand Down Expand Up @@ -142,7 +143,7 @@ def __setattr__(self, prop, val): # type: ignore
super().__setattr__(prop, val)

@staticmethod
def _get_rst_list(value: Union[List[_PATH], _PATH]) -> List[_PATH]:
def _get_rst_list(value: Union[list[_PATH], _PATH]) -> list[_PATH]:
if isinstance(value, (str, pathlib.Path)):
value = [value]
return value # type: ignore
Expand Down Expand Up @@ -177,7 +178,7 @@ class CompositeDataSources:
composite: DataSources
engineering_data: DataSources

old_composite_sources: Dict[str, DataSources]
old_composite_sources: dict[str, DataSources]


def _get_mapping_path_file_from_definitions_path_if_exists(
Expand Down Expand Up @@ -489,7 +490,7 @@ def get_composite_files_from_workbench_result_folder(


def _get_data_sources_from_rst_files(
rst_files: List[_PATH],
rst_files: list[_PATH],
) -> DataSources:
"""Get a DPF data sources object from a list of RST files.

Expand Down
12 changes: 6 additions & 6 deletions src/ansys/dpf/composites/example_helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
import os
import tempfile
from typing import Dict, List, Optional, cast
from typing import Optional, cast
import urllib.request

import ansys.dpf.core as dpf
Expand All @@ -25,14 +25,14 @@ class _ContinuousFiberCompositeFiles:

@dataclass
class _ContinuousFiberCompositesExampleFilenames:
rst: List[str]
composite: Dict[str, _ContinuousFiberCompositeFiles]
rst: list[str]
composite: dict[str, _ContinuousFiberCompositeFiles]
engineering_data: str


@dataclass
class _ShortFiberCompositesExampleFilenames:
rst: List[str]
rst: list[str]
dsdat: str
engineering_data: str

Expand Down Expand Up @@ -69,7 +69,7 @@ class _ShortFiberExampleLocation:
files: _ShortFiberCompositesExampleFilenames


_continuous_fiber_examples: Dict[str, _ContinuousFiberExampleLocation] = {
_continuous_fiber_examples: dict[str, _ContinuousFiberExampleLocation] = {
"shell": _ContinuousFiberExampleLocation(
directory="shell",
files=_ContinuousFiberCompositesExampleFilenames(
Expand Down Expand Up @@ -120,7 +120,7 @@ class _ShortFiberExampleLocation:
),
}

_short_fiber_examples: Dict[str, _ShortFiberExampleLocation] = {
_short_fiber_examples: dict[str, _ShortFiberExampleLocation] = {
"short_fiber": _ShortFiberExampleLocation(
directory="short_fiber",
files=_ShortFiberCompositesExampleFilenames(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Combined Failure Criterion."""

from collections.abc import Sequence
import json
from typing import Any, Dict, Sequence
from typing import Any

from ._failure_criterion_base import FailureCriterionBase

Expand Down Expand Up @@ -36,7 +37,7 @@ def __init__(
failure_criteria:
List of failure criteria.
"""
self._failure_criteria: Dict[str, FailureCriterionBase] = {}
self._failure_criteria: dict[str, FailureCriterionBase] = {}
for fc in failure_criteria:
self.insert(fc)

Expand All @@ -48,7 +49,7 @@ def _get_name(self) -> str:
def _set_name(self, value: str) -> None:
self._name = value

def _get_failure_criteria(self) -> Dict[str, FailureCriterionBase]:
def _get_failure_criteria(self) -> dict[str, FailureCriterionBase]:
return self._failure_criteria

name = property(_get_name, _set_name, doc="Name of the combined failure criterion.")
Expand Down Expand Up @@ -100,7 +101,7 @@ def remove(self, key: str) -> FailureCriterionBase:

return self._failure_criteria.pop(key)

def to_dict(self) -> Dict[str, Any]:
def to_dict(self) -> dict[str, Any]:
"""Return the combined failure criterion as a dictionary.

Returns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Defines the base class of composite failure criterion."""

from collections.abc import Sequence
import json
from typing import Any, Dict, Sequence
from typing import Any


class FailureCriterionBase:
Expand All @@ -26,7 +27,7 @@ def _get_name(self) -> str:
)
name = property(_get_name, doc="Name of the failure criterion. Read only.")

def to_dict(self) -> Dict[str, Any]:
def to_dict(self) -> dict[str, Any]:
""":return: a dict with all properties."""
properties = self._get_properties(exclude=["name"])

Expand Down
Loading
Loading