Skip to content

Commit

Permalink
Run "black" python formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiesenberger committed Feb 13, 2023
1 parent 6607b90 commit 62d6043
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 0 additions & 3 deletions tests/test_animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class TestAnimate:
"""

def test_animate2D(self, create_single_test_dataset):

ds = create_single_test_dataset
save_dir = "."
animation = ds["electrons"].feltor.animate2D(save_as="%s/testxy" % save_dir)
Expand All @@ -52,7 +51,6 @@ def test_animate2D(self, create_single_test_dataset):
os.system("rm testxy.gif")

def test_animate1D(self, create_single_test_dataset):

ds = create_single_test_dataset

save_dir = "."
Expand All @@ -68,7 +66,6 @@ def test_animate1D(self, create_single_test_dataset):
os.system("rm test.gif")

def test_animate_list(self, create_single_test_dataset):

ds = create_single_test_dataset

animation = ds.feltor.animate_list([ds["electrons"], ds["electrons"].isel(y=1)])
Expand Down
3 changes: 2 additions & 1 deletion xfeltor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
from .load import open_feltordataset
from .feltordataarray import FeltorDataArrayAccessor
from .feltordataset import FeltorDatasetAccessor
#Why is plotting not loaded? Should it be hidden from help(xfeltor)?

# Why is plotting not loaded? Should it be hidden from help(xfeltor)?
1 change: 1 addition & 0 deletions xfeltor/feltordataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# The README says the plotting routines are from xBOUT. How far is that copy verbose and do we have to mention them here (License)?
# Or are the methods just named like in the xBOUT library?


# A mechanism to extend the xarray.DataArray class by registering a custom property
# https://docs.xarray.dev/en/stable/generated/xarray.register_dataarray_accessor.html
@register_dataarray_accessor("feltor")
Expand Down
6 changes: 4 additions & 2 deletions xfeltor/feltordataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import numpy as np
from .plotting import _add_controls


# A mechanism to extend the xarray.Dataset class by registering a custom property
#https://docs.xarray.dev/en/stable/internals/extending-xarray.html
# https://docs.xarray.dev/en/stable/internals/extending-xarray.html
@xr.register_dataset_accessor("feltor")
class FeltorDatasetAccessor:
"""Contains FELTOR-specific methods to use on FELTOR datasets opened using
Expand All @@ -28,6 +29,7 @@ class FeltorDatasetAccessor:
) # use its methods
"""

def __init__(self, ds):
self.data = ds

Expand All @@ -44,7 +46,7 @@ def __str__(self):
print(ds.feltor)
# same as above but will not print the "inputfile" attribute
"""
ds = self.data.copy() # a shallow copy ...
ds = self.data.copy() # a shallow copy ...
del ds.attrs["inputfile"]
styled = partial(prettyformat, indent=4, compact=False)
return "<xfeltor.FeltorDataset>" + "\n{}\n".format(styled(ds))
Expand Down
10 changes: 7 additions & 3 deletions xfeltor/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _normalise_time_coord(time_values):
tmax = time_values.max()
if tmax < 1.0e-2 or tmax > 1.0e6:
scale_pow = int(np.floor(np.log10(tmax)))
scale_factor = 10 ** scale_pow
scale_factor = 10**scale_pow
time_values = time_values / scale_factor
suffix = f"e{scale_pow}"
else:
Expand Down Expand Up @@ -249,8 +249,12 @@ def animate_pcolormesh(
UserWarning,
)
pcolormesh_block = amp.blocks.Pcolormesh(
x_values, y_values, image_data, ax=ax, **kwargs
# shading parameter triggers error when trying to set manually
x_values,
y_values,
image_data,
ax=ax,
**kwargs
# shading parameter triggers error when trying to set manually
)

if animate:
Expand Down

0 comments on commit 62d6043

Please sign in to comment.