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

Ft add update + v0.0.25 #202

Merged
merged 12 commits into from
May 6, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-20.04, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-20.04, macos-13, macos-14, windows-latest]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion gustaf/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Current version.
"""

version = "0.0.24"
version = "0.0.25"
28 changes: 28 additions & 0 deletions gustaf/helpers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ def __contains__(self, key):
"""
return key in self._saved

def __len__(self):
"""
Returns number of items.

Parameters
----------
None

Returns
-------
len: int
"""
return len(self._saved)

def pop(self, key, default=None):
"""
Applied pop() to saved data
Expand Down Expand Up @@ -318,6 +332,20 @@ def items(self):
"""
return self._saved.items()

def update(self, **kwargs):
"""
Updates given kwargs using __setitem__.

Parameters
----------
**kwargs: kwargs

Returns
-------
None
"""
self._saved.update(**kwargs)


class ComputedData(DataHolder):
_depends = None
Expand Down
9 changes: 5 additions & 4 deletions gustaf/io/meshio.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def load(fname):
return meshes[0] if len(meshes) == 1 else meshes


def export(mesh, fname, submeshes=None, **kwargs):
def export(fname, mesh, submeshes=None, **kwargs):
"""Export mesh elements and vertex data into meshio and use its write
function. The definition of submeshes with identical vertex coordinates
is possible. In that case vertex numbering and data from the main mesh
Expand Down Expand Up @@ -132,10 +132,10 @@ def export(mesh, fname, submeshes=None, **kwargs):

Parameters
------------
mesh: Edges, Faces or Volumes
Input mesh
fname: Union[str, pathlib.Path]
File to save the mesh in.
mesh: Edges, Faces or Volumes
Input mesh
submeshes: Iterable
Submeshes where the vertices are identical to the main mesh. The element
type can be identical to mesh.elements or lower-dimensional (e.g.
Expand Down Expand Up @@ -164,7 +164,8 @@ def export(mesh, fname, submeshes=None, **kwargs):

cells = []
# Merge main mesh and submeshes in one list
meshes = [mesh]
meshes = mesh if isinstance(mesh, list) else [mesh]

if submeshes is not None:
meshes.extend(submeshes)

Expand Down
4 changes: 2 additions & 2 deletions gustaf/io/mfem.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ def extract_values(fname, start_index, n_lines, total_lines, dtype):
return mesh


def export(mesh, fname):
def export(fname, mesh):
"""Export mesh in MFEM format. Supports 2D triangle and quadrilateral
meshes. Does not support different element attributes or difference in
vertex dimension and mesh dimension.

Parameters
------------
mesh: Faces
fname: str
mesh: Faces

Returns
------------
Expand Down
2 changes: 1 addition & 1 deletion gustaf/io/mixd.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def load(


def export(
mesh,
fname,
mesh,
space_time=False,
dual=False,
):
Expand Down
4 changes: 2 additions & 2 deletions gustaf/io/nutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def load(fname):
return mesh


def export(mesh, fname):
def export(fname, mesh):
"""Export in Nutils format. Files are saved as np.savez().
Supports triangle,and tetrahedron Meshes.

Parameters
-----------
mesh: Faces or Volumes
fname: str
mesh: Faces or Volumes

Returns
--------
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ keywords = [
"visualization",
"mesh",
]
requires-python = ">=3.7"
requires-python = ">=3.8"
license = {file = "LICENSE.txt"}
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -81,7 +80,7 @@ version = {attr = "gustaf._version.version"}

[tool.ruff]
line-length = 79
target-version = "py37"
target-version = "py38"

[tool.ruff.lint]
select = [
Expand All @@ -107,7 +106,6 @@ ignore = [
"PLR0913", # Too many arguments to function call
"PLR0915", # Too many statements
"B904", # Within an `except` clause, raise exceptions with ...
# "PLR0911", # Too many return statements
]

[tool.ruff.lint.per-file-ignores]
Expand Down
Loading
Loading