55import numpy as np
66import pandas as pd
77
8- from . import dtypes , duck_array_ops , nputils , ops , utils
8+ from . import dtypes , duck_array_ops , nputils , ops
99from .arithmetic import SupportsArithmetic
10- from .common import ALL_DIMS , ImplementsArrayReduce , ImplementsDatasetReduce
10+ from .common import ImplementsArrayReduce , ImplementsDatasetReduce
1111from .concat import concat
1212from .options import _get_keep_attrs
1313from .pycompat import integer_types
@@ -700,19 +700,8 @@ def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None):
700700 numpy.nanpercentile, pandas.Series.quantile, Dataset.quantile,
701701 DataArray.quantile
702702 """
703- if dim == DEFAULT_DIMS :
704- dim = ALL_DIMS
705- # TODO change this to dim = self._group_dim after
706- # the deprecation process
707- if self ._obj .ndim > 1 :
708- warnings .warn (
709- "Default reduction dimension will be changed to the "
710- "grouped dimension in a future version of xarray. To "
711- "silence this warning, pass dim=xarray.ALL_DIMS "
712- "explicitly." ,
713- FutureWarning ,
714- stacklevel = 2 ,
715- )
703+ if dim is None :
704+ dim = self ._group_dim
716705
717706 out = self .apply (
718707 self ._obj .__class__ .quantile ,
@@ -758,19 +747,8 @@ def reduce(
758747 Array with summarized data and the indicated dimension(s)
759748 removed.
760749 """
761- if dim == DEFAULT_DIMS :
762- dim = ALL_DIMS
763- # TODO change this to dim = self._group_dim after
764- # the deprecation process
765- if self ._obj .ndim > 1 :
766- warnings .warn (
767- "Default reduction dimension will be changed to the "
768- "grouped dimension in a future version of xarray. To "
769- "silence this warning, pass dim=xarray.ALL_DIMS "
770- "explicitly." ,
771- FutureWarning ,
772- stacklevel = 2 ,
773- )
750+ if dim is None :
751+ dim = self ._group_dim
774752
775753 if keep_attrs is None :
776754 keep_attrs = _get_keep_attrs (default = False )
@@ -780,43 +758,6 @@ def reduce_array(ar):
780758
781759 return self .apply (reduce_array , shortcut = shortcut )
782760
783- # TODO remove the following class method and DEFAULT_DIMS after the
784- # deprecation cycle
785- @classmethod
786- def _reduce_method (cls , func , include_skipna , numeric_only ):
787- if include_skipna :
788-
789- def wrapped_func (
790- self ,
791- dim = DEFAULT_DIMS ,
792- axis = None ,
793- skipna = None ,
794- keep_attrs = None ,
795- ** kwargs
796- ):
797- return self .reduce (
798- func ,
799- dim ,
800- axis ,
801- keep_attrs = keep_attrs ,
802- skipna = skipna ,
803- allow_lazy = True ,
804- ** kwargs
805- )
806-
807- else :
808-
809- def wrapped_func ( # type: ignore
810- self , dim = DEFAULT_DIMS , axis = None , keep_attrs = None , ** kwargs
811- ):
812- return self .reduce (
813- func , dim , axis , keep_attrs = keep_attrs , allow_lazy = True , ** kwargs
814- )
815-
816- return wrapped_func
817-
818-
819- DEFAULT_DIMS = utils .ReprObject ("<default-dims>" )
820761
821762ops .inject_reduce_methods (DataArrayGroupBy )
822763ops .inject_binary_ops (DataArrayGroupBy )
@@ -898,19 +839,7 @@ def reduce(self, func, dim=None, keep_attrs=None, **kwargs):
898839 Array with summarized data and the indicated dimension(s)
899840 removed.
900841 """
901- if dim == DEFAULT_DIMS :
902- dim = ALL_DIMS
903- # TODO change this to dim = self._group_dim after
904- # the deprecation process. Do not forget to remove _reduce_method
905- warnings .warn (
906- "Default reduction dimension will be changed to the "
907- "grouped dimension in a future version of xarray. To "
908- "silence this warning, pass dim=xarray.ALL_DIMS "
909- "explicitly." ,
910- FutureWarning ,
911- stacklevel = 2 ,
912- )
913- elif dim is None :
842+ if dim is None :
914843 dim = self ._group_dim
915844
916845 if keep_attrs is None :
@@ -921,31 +850,6 @@ def reduce_dataset(ds):
921850
922851 return self .apply (reduce_dataset )
923852
924- # TODO remove the following class method and DEFAULT_DIMS after the
925- # deprecation cycle
926- @classmethod
927- def _reduce_method (cls , func , include_skipna , numeric_only ):
928- if include_skipna :
929-
930- def wrapped_func (self , dim = DEFAULT_DIMS , skipna = None , ** kwargs ):
931- return self .reduce (
932- func ,
933- dim ,
934- skipna = skipna ,
935- numeric_only = numeric_only ,
936- allow_lazy = True ,
937- ** kwargs
938- )
939-
940- else :
941-
942- def wrapped_func (self , dim = DEFAULT_DIMS , ** kwargs ): # type: ignore
943- return self .reduce (
944- func , dim , numeric_only = numeric_only , allow_lazy = True , ** kwargs
945- )
946-
947- return wrapped_func
948-
949853 def assign (self , ** kwargs ):
950854 """Assign data variables by group.
951855
0 commit comments