Skip to content

Commit 5b47395

Browse files
authored
Merge pull request #202 from tataratat/ft-add-update
Ft add update + v0.0.25
2 parents 04a24b7 + a5b39b6 commit 5b47395

File tree

10 files changed

+345
-16
lines changed

10 files changed

+345
-16
lines changed
File renamed without changes.

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
14-
os: [ubuntu-20.04, macos-latest]
13+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
14+
os: [ubuntu-20.04, macos-13, macos-14, windows-latest]
1515

1616
steps:
1717
- uses: actions/checkout@v3

gustaf/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
Current version.
44
"""
55

6-
version = "0.0.24"
6+
version = "0.0.25"

gustaf/helpers/data.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,20 @@ def __contains__(self, key):
251251
"""
252252
return key in self._saved
253253

254+
def __len__(self):
255+
"""
256+
Returns number of items.
257+
258+
Parameters
259+
----------
260+
None
261+
262+
Returns
263+
-------
264+
len: int
265+
"""
266+
return len(self._saved)
267+
254268
def pop(self, key, default=None):
255269
"""
256270
Applied pop() to saved data
@@ -318,6 +332,20 @@ def items(self):
318332
"""
319333
return self._saved.items()
320334

335+
def update(self, **kwargs):
336+
"""
337+
Updates given kwargs using __setitem__.
338+
339+
Parameters
340+
----------
341+
**kwargs: kwargs
342+
343+
Returns
344+
-------
345+
None
346+
"""
347+
self._saved.update(**kwargs)
348+
321349

322350
class ComputedData(DataHolder):
323351
_depends = None

gustaf/io/meshio.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def load(fname):
8484
return meshes[0] if len(meshes) == 1 else meshes
8585

8686

87-
def export(mesh, fname, submeshes=None, **kwargs):
87+
def export(fname, mesh, submeshes=None, **kwargs):
8888
"""Export mesh elements and vertex data into meshio and use its write
8989
function. The definition of submeshes with identical vertex coordinates
9090
is possible. In that case vertex numbering and data from the main mesh
@@ -132,10 +132,10 @@ def export(mesh, fname, submeshes=None, **kwargs):
132132
133133
Parameters
134134
------------
135-
mesh: Edges, Faces or Volumes
136-
Input mesh
137135
fname: Union[str, pathlib.Path]
138136
File to save the mesh in.
137+
mesh: Edges, Faces or Volumes
138+
Input mesh
139139
submeshes: Iterable
140140
Submeshes where the vertices are identical to the main mesh. The element
141141
type can be identical to mesh.elements or lower-dimensional (e.g.
@@ -164,7 +164,8 @@ def export(mesh, fname, submeshes=None, **kwargs):
164164

165165
cells = []
166166
# Merge main mesh and submeshes in one list
167-
meshes = [mesh]
167+
meshes = mesh if isinstance(mesh, list) else [mesh]
168+
168169
if submeshes is not None:
169170
meshes.extend(submeshes)
170171

gustaf/io/mfem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ def extract_values(fname, start_index, n_lines, total_lines, dtype):
107107
return mesh
108108

109109

110-
def export(mesh, fname):
110+
def export(fname, mesh):
111111
"""Export mesh in MFEM format. Supports 2D triangle and quadrilateral
112112
meshes. Does not support different element attributes or difference in
113113
vertex dimension and mesh dimension.
114114
115115
Parameters
116116
------------
117-
mesh: Faces
118117
fname: str
118+
mesh: Faces
119119
120120
Returns
121121
------------

gustaf/io/mixd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def load(
116116

117117

118118
def export(
119-
mesh,
120119
fname,
120+
mesh,
121121
space_time=False,
122122
dual=False,
123123
):

gustaf/io/nutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def load(fname):
6161
return mesh
6262

6363

64-
def export(mesh, fname):
64+
def export(fname, mesh):
6565
"""Export in Nutils format. Files are saved as np.savez().
6666
Supports triangle,and tetrahedron Meshes.
6767
6868
Parameters
6969
-----------
70-
mesh: Faces or Volumes
7170
fname: str
71+
mesh: Faces or Volumes
7272
7373
Returns
7474
--------

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ keywords = [
1010
"visualization",
1111
"mesh",
1212
]
13-
requires-python = ">=3.7"
13+
requires-python = ">=3.8"
1414
license = {file = "LICENSE.txt"}
1515
classifiers = [
1616
"Development Status :: 3 - Alpha",
1717
"License :: OSI Approved :: MIT License",
1818
"Programming Language :: Python",
19-
"Programming Language :: Python :: 3.7",
2019
"Programming Language :: Python :: 3.8",
2120
"Programming Language :: Python :: 3.9",
2221
"Programming Language :: Python :: 3.10",
@@ -81,7 +80,7 @@ version = {attr = "gustaf._version.version"}
8180

8281
[tool.ruff]
8382
line-length = 79
84-
target-version = "py37"
83+
target-version = "py38"
8584

8685
[tool.ruff.lint]
8786
select = [
@@ -107,7 +106,6 @@ ignore = [
107106
"PLR0913", # Too many arguments to function call
108107
"PLR0915", # Too many statements
109108
"B904", # Within an `except` clause, raise exceptions with ...
110-
# "PLR0911", # Too many return statements
111109
]
112110

113111
[tool.ruff.lint.per-file-ignores]

0 commit comments

Comments
 (0)