Skip to content

Commit 7164a89

Browse files
authored
Merge pull request #134 from boutproject/boutoptions-repr
Add `__repr__` to `BoutOptions`
2 parents 88793c2 + bee0691 commit 7164a89

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/boutdata/collect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _convert_to_nice_slice(r, N, name="range"):
8383
temp_slice = slice(N)
8484
elif isinstance(r, slice):
8585
temp_slice = r
86-
elif isinstance(r, (int, np.integer)):
86+
elif isinstance(r, int | np.integer):
8787
if r >= N or r < -N:
8888
# raise out of bounds error as if we'd tried to index the array with r
8989
# without this, would return an empty array instead

src/boutdata/data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ def format_inline_comment(name, options):
479479

480480
return f.getvalue()
481481

482+
def __repr__(self):
483+
return self.as_dict()
484+
482485
def get_bool(self, name, default=None):
483486
"""
484487
Convert an option value to a bool, in (almost) the same way as BOUT++.

src/boututils/datafile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def read(self, name, ranges=None, asBoutArray=True):
182182
"""
183183
if ranges is not None:
184184
for x in ranges:
185-
if isinstance(x, (list, tuple)):
185+
if isinstance(x, list | tuple):
186186
x = slice(*x)
187187
return self.impl.read(name, ranges=ranges, asBoutArray=asBoutArray)
188188

src/boututils/showdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ def showdata(
423423
# Generate grids for plotting
424424
# Try to use provided grids where possible
425425
# If x and/or y are not lists, apply to all variables
426-
if not isinstance(x, (list, tuple)):
426+
if not isinstance(x, list | tuple):
427427
x = [x] * Nvar # Make list of x with length Nvar
428-
if not isinstance(y, (list, tuple)):
428+
if not isinstance(y, list | tuple):
429429
y = [y] * Nvar # Make list of x with length Nvar
430430
xnew = []
431431
ynew = []

0 commit comments

Comments
 (0)