5
5
import numpy as np
6
6
import pandas as pd
7
7
8
- from . import dtypes , duck_array_ops , nputils , ops , utils
8
+ from . import dtypes , duck_array_ops , nputils , ops
9
9
from .arithmetic import SupportsArithmetic
10
- from .common import ALL_DIMS , ImplementsArrayReduce , ImplementsDatasetReduce
10
+ from .common import ImplementsArrayReduce , ImplementsDatasetReduce
11
11
from .concat import concat
12
12
from .options import _get_keep_attrs
13
13
from .pycompat import integer_types
@@ -700,19 +700,8 @@ def quantile(self, q, dim=None, interpolation="linear", keep_attrs=None):
700
700
numpy.nanpercentile, pandas.Series.quantile, Dataset.quantile,
701
701
DataArray.quantile
702
702
"""
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
716
705
717
706
out = self .apply (
718
707
self ._obj .__class__ .quantile ,
@@ -758,20 +747,6 @@ def reduce(
758
747
Array with summarized data and the indicated dimension(s)
759
748
removed.
760
749
"""
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
- )
774
-
775
750
if keep_attrs is None :
776
751
keep_attrs = _get_keep_attrs (default = False )
777
752
@@ -780,43 +755,6 @@ def reduce_array(ar):
780
755
781
756
return self .apply (reduce_array , shortcut = shortcut )
782
757
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>" )
820
758
821
759
ops .inject_reduce_methods (DataArrayGroupBy )
822
760
ops .inject_binary_ops (DataArrayGroupBy )
@@ -898,19 +836,7 @@ def reduce(self, func, dim=None, keep_attrs=None, **kwargs):
898
836
Array with summarized data and the indicated dimension(s)
899
837
removed.
900
838
"""
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 :
839
+ if dim is None :
914
840
dim = self ._group_dim
915
841
916
842
if keep_attrs is None :
@@ -921,31 +847,6 @@ def reduce_dataset(ds):
921
847
922
848
return self .apply (reduce_dataset )
923
849
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
-
949
850
def assign (self , ** kwargs ):
950
851
"""Assign data variables by group.
951
852
0 commit comments