Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _check_dimensions(self):
"""
This function validates that the dimensions 2D/3D and
they are are in the proper order.
Returns
-------
str or None: Name extra dimension.
"""
extra_dims = list(set(list(self._obj.dims)) - set([self.x_dim, self.y_dim]))
if len(extra_dims) > 1:
raise TooManyDimensions(
"Only 2D and 3D data arrays supported."
f"{_get_data_var_message(self._obj)}"
)
elif extra_dims and self._obj.dims != (extra_dims[0], self.y_dim, self.x_dim):
raise InvalidDimensionOrder(
"Invalid dimension order. Expected order: {0}. "
"You can use `DataArray.transpose{0}`"
" to reorder your dimensions.".format(
(extra_dims[0], self.y_dim, self.x_dim)
)
+ f"{_get_data_var_message(self._obj)}"
)
elif not extra_dims and self._obj.dims != (self.y_dim, self.x_dim):
raise InvalidDimensionOrder(
"Invalid dimension order. Expected order: {0}"
"You can use `DataArray.transpose{0}` "