forked from pydata/xarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
What is your issue?
the call to self._parse_dimensions(dims)
should be avoidable for internal routines.
However, it was giving me trouble in tests.
diff --git a/xarray/core/variable.py b/xarray/core/variable.py
index 6f5826a5..311aac22 100644
--- a/xarray/core/variable.py
+++ b/xarray/core/variable.py
@@ -396,7 +396,10 @@ class Variable(NamedArray, AbstractArray, VariableArithmetic):
unrecognized encoding items.
"""
super().__init__(
- dims=dims, data=as_compatible_data(data, fastpath=fastpath), attrs=attrs
+ dims=dims,
+ data=as_compatible_data(data, fastpath=fastpath),
+ attrs=attrs,
+ fastpath=fastpath,
)
self._encoding = None
@@ -2622,6 +2625,9 @@ class IndexVariable(Variable):
def __init__(self, dims, data, attrs=None, encoding=None, fastpath=False):
super().__init__(dims, data, attrs, encoding, fastpath)
+ if fastpath:
+ return
+
if self.ndim != 1:
raise ValueError(f"{type(self).__name__} objects must be 1-dimensional")
diff --git a/xarray/namedarray/core.py b/xarray/namedarray/core.py
index 135dabc0..adceaa65 100644
--- a/xarray/namedarray/core.py
+++ b/xarray/namedarray/core.py
@@ -259,9 +259,14 @@ class NamedArray(NamedArrayAggregations, Generic[_ShapeType_co, _DType_co]):
dims: _DimsLike,
data: duckarray[Any, _DType_co],
attrs: _AttrsLike = None,
+ *,
+ fastpath=True,
):
self._data = data
- self._dims = self._parse_dimensions(dims)
+ if fastpath:
+ self._dims = dims
+ else:
+ self._dims = self._parse_dimensions(dims)
self._attrs = dict(attrs) if attrs else None
def __init_subclass__(cls, **kwargs: Any) -> None:
Metadata
Metadata
Assignees
Labels
No labels