Skip to content
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
1 change: 0 additions & 1 deletion xbout/calc/turbulence.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import xarray as xr


# TODO write a decorator to add functions as accessors to dataarrays?


Expand Down
1 change: 0 additions & 1 deletion xbout/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest


configure_is_imported = False


Expand Down
8 changes: 2 additions & 6 deletions xbout/geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,9 @@ def apply_geometry(ds, geometry_name, *, coordinates=None, grid=None):
try:
add_geometry_coords = REGISTERED_GEOMETRIES[geometry_name]
except KeyError:
message = dedent(
"""{} is not a registered geometry. Inspect the global
message = dedent("""{} is not a registered geometry. Inspect the global
variable REGISTERED_GEOMETRIES to see which geometries
have been registered.""".format(
geometry_name
)
)
have been registered.""".format(geometry_name))
raise UnregisteredGeometryError(message)

# User-registered functions may accept 'coordinates' and 'grid' arguments, but
Expand Down
1 change: 0 additions & 1 deletion xbout/plotting/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
)
from matplotlib.animation import PillowWriter


if (
"pcolor.shading" in matplotlib.rcParams
and matplotlib.rcParams["pcolor.shading"] == "flat"
Expand Down
1 change: 0 additions & 1 deletion xbout/plotting/plotfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
plot_targets,
)


if (
"pcolor.shading" in matplotlib.rcParams
and matplotlib.rcParams["pcolor.shading"] == "flat"
Expand Down
72 changes: 36 additions & 36 deletions xbout/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,15 +1342,15 @@ def _concat_inner_guards(da, da_global, mxg):
new_xcoord = da_global[xcoord].isel(**{xcoord: slices[xcoord]})
new_ycoord = da_global[ycoord].isel(**{ycoord: slices[ycoord]})

# can't use commented out version, uncommented one works around xarray bug
# removing attrs
# https://github.com/pydata/xarray/issues/4415
# https://github.com/pydata/xarray/issues/4393
# da_inner = da_inner.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})
da_inner[xcoord].data[...] = new_xcoord.data
da_inner = da_inner.reset_index(xcoord).set_xindex(xcoord)
da_inner[ycoord].data[...] = new_ycoord.data
da_inner = da_inner.reset_index(ycoord).set_xindex(ycoord)
# Preserve attributes when updating coordinates
# xarray coordinates are read-only by design, must use assign_coords()
xcoord_attrs = da_inner[xcoord].attrs.copy()
ycoord_attrs = da_inner[ycoord].attrs.copy()

# Assign new coordinate values
new_xcoord.attrs = xcoord_attrs
new_ycoord.attrs = ycoord_attrs
da_inner = da_inner.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})

save_regions = da.bout._regions
da = xr.concat((da_inner, da), xcoord, join="exact")
Expand Down Expand Up @@ -1455,15 +1455,15 @@ def _concat_outer_guards(da, da_global, mxg):
new_xcoord = da_global[xcoord].isel(**{xcoord: slices[xcoord]})
new_ycoord = da_global[ycoord].isel(**{ycoord: slices[ycoord]})

# can't use commented out version, uncommented one works around xarray bug
# removing attrs
# https://github.com/pydata/xarray/issues/4415
# https://github.com/pydata/xarray/issues/4393
# da_outer = da_outer.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})
da_outer[xcoord].data[...] = new_xcoord.data
da_outer = da_outer.reset_index(xcoord).set_xindex(xcoord)
da_outer[ycoord].data[...] = new_ycoord.data
da_outer = da_outer.reset_index(ycoord).set_xindex(ycoord)
# Preserve attributes when updating coordinates
# xarray coordinates are read-only by design, must use assign_coords()
xcoord_attrs = da_outer[xcoord].attrs.copy()
ycoord_attrs = da_outer[ycoord].attrs.copy()

# Assign new coordinate values
new_xcoord.attrs = xcoord_attrs
new_ycoord.attrs = ycoord_attrs
da_outer = da_outer.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})

save_regions = da.bout._regions
da = xr.concat((da, da_outer), xcoord, join="exact")
Expand Down Expand Up @@ -1557,15 +1557,15 @@ def _concat_lower_guards(da, da_global, mxg, myg):
)
new_ycoord = new_ycoord + offset

# can't use commented out version, uncommented one works around xarray bug
# removing attrs
# https://github.com/pydata/xarray/issues/4415
# https://github.com/pydata/xarray/issues/4393
# da_lower = da_lower.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})
da_lower[xcoord].data[...] = new_xcoord.data
da_lower = da_lower.reset_index(xcoord).set_xindex(xcoord)
da_lower[ycoord].data[...] = new_ycoord.data
da_lower = da_lower.reset_index(ycoord).set_xindex(ycoord)
# Preserve attributes when updating coordinates
# xarray coordinates are read-only by design, must use assign_coords()
xcoord_attrs = da_lower[xcoord].attrs.copy()
ycoord_attrs = da_lower[ycoord].attrs.copy()

# Assign new coordinate values
new_xcoord.attrs = xcoord_attrs
new_ycoord.attrs = ycoord_attrs
da_lower = da_lower.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})

if "poloidal_distance" in da.coords and myg > 0:
# Special handling for core regions to deal with branch cut
Expand Down Expand Up @@ -1675,15 +1675,15 @@ def _concat_upper_guards(da, da_global, mxg, myg):
)
new_ycoord = new_ycoord + offset

# can't use commented out version, uncommented one works around xarray bug
# removing attrs
# https://github.com/pydata/xarray/issues/4415
# https://github.com/pydata/xarray/issues/4393
# da_upper = da_upper.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})
da_upper[xcoord].data[...] = new_xcoord.data
da_upper = da_upper.reset_index(xcoord).set_xindex(xcoord)
da_upper[ycoord].data[...] = new_ycoord.data
da_upper = da_upper.reset_index(ycoord).set_xindex(ycoord)
# Preserve attributes when updating coordinates
# xarray coordinates are read-only by design, must use assign_coords()
xcoord_attrs = da_upper[xcoord].attrs.copy()
ycoord_attrs = da_upper[ycoord].attrs.copy()

# Assign new coordinate values
new_xcoord.attrs = xcoord_attrs
new_ycoord.attrs = ycoord_attrs
da_upper = da_upper.assign_coords(**{xcoord: new_xcoord, ycoord: new_ycoord})

if "poloidal_distance" in da.coords and myg > 0:
# Special handling for core regions to deal with branch cut
Expand Down
1 change: 0 additions & 1 deletion xbout/tests/test_boutdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from xbout.utils import _set_attrs_on_all_vars, _1d_coord_from_spacing
from xbout.tests.utils_for_tests import set_geometry_from_input_file


EXAMPLE_OPTIONS_FILE_PATH = "./xbout/tests/data/options/BOUT.inp"


Expand Down
1 change: 0 additions & 1 deletion xbout/tests/test_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from xbout import open_boutdataset


params_guards = "guards"
params_guards_values = [
pytest.param({"x": 0, "y": 0}, marks=pytest.mark.long),
Expand Down
1 change: 0 additions & 1 deletion xbout/tests/utils_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pathlib import Path
from xarray import DataArray, Dataset


# Note, MYPE, PE_XIND and PE_YIND not included, since they are different for each
# processor and so are dropped when loading datasets.
METADATA_VARS = [
Expand Down