@@ -48,10 +48,10 @@ class Rolling:
4848 xarray.DataArray.rolling
4949 """
5050
51- __slots__ = ("obj" , "window" , "min_periods" , "center" , "dim" , "keep_attrs" )
52- _attributes = ("window" , "min_periods" , "center" , "dim" , "keep_attrs" )
51+ __slots__ = ("obj" , "window" , "min_periods" , "center" , "dim" )
52+ _attributes = ("window" , "min_periods" , "center" , "dim" )
5353
54- def __init__ (self , obj , windows , min_periods = None , center = False , keep_attrs = None ):
54+ def __init__ (self , obj , windows , min_periods = None , center = False ):
5555 """
5656 Moving window object.
5757
@@ -89,15 +89,6 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None
8989
9090 self .min_periods = np .prod (self .window ) if min_periods is None else min_periods
9191
92- if keep_attrs is not None :
93- warnings .warn (
94- "Passing ``keep_attrs`` to ``rolling`` is deprecated and will raise an"
95- " error in xarray 0.18. Please pass ``keep_attrs`` directly to the"
96- " applied function. Note that keep_attrs is now True per default." ,
97- FutureWarning ,
98- )
99- self .keep_attrs = keep_attrs
100-
10192 def __repr__ (self ):
10293 """provide a nice str repr of our rolling object"""
10394
@@ -188,23 +179,16 @@ def _mapping_to_list(
188179 )
189180
190181 def _get_keep_attrs (self , keep_attrs ):
191-
192182 if keep_attrs is None :
193- # TODO: uncomment the next line and remove the others after the deprecation
194- # keep_attrs = _get_keep_attrs(default=True)
195-
196- if self .keep_attrs is None :
197- keep_attrs = _get_keep_attrs (default = True )
198- else :
199- keep_attrs = self .keep_attrs
183+ keep_attrs = _get_keep_attrs (default = True )
200184
201185 return keep_attrs
202186
203187
204188class DataArrayRolling (Rolling ):
205189 __slots__ = ("window_labels" ,)
206190
207- def __init__ (self , obj , windows , min_periods = None , center = False , keep_attrs = None ):
191+ def __init__ (self , obj , windows , min_periods = None , center = False ):
208192 """
209193 Moving window object for DataArray.
210194 You should use DataArray.rolling() method to construct this object
@@ -235,9 +219,7 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None
235219 xarray.Dataset.rolling
236220 xarray.Dataset.groupby
237221 """
238- super ().__init__ (
239- obj , windows , min_periods = min_periods , center = center , keep_attrs = keep_attrs
240- )
222+ super ().__init__ (obj , windows , min_periods = min_periods , center = center )
241223
242224 # TODO legacy attribute
243225 self .window_labels = self .obj [self .dim [0 ]]
@@ -561,7 +543,7 @@ def _numpy_or_bottleneck_reduce(
561543class DatasetRolling (Rolling ):
562544 __slots__ = ("rollings" ,)
563545
564- def __init__ (self , obj , windows , min_periods = None , center = False , keep_attrs = None ):
546+ def __init__ (self , obj , windows , min_periods = None , center = False ):
565547 """
566548 Moving window object for Dataset.
567549 You should use Dataset.rolling() method to construct this object
@@ -592,7 +574,7 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None
592574 xarray.Dataset.groupby
593575 xarray.DataArray.groupby
594576 """
595- super ().__init__ (obj , windows , min_periods , center , keep_attrs )
577+ super ().__init__ (obj , windows , min_periods , center )
596578 if any (d not in self .obj .dims for d in self .dim ):
597579 raise KeyError (self .dim )
598580 # Keep each Rolling object as a dictionary
@@ -768,11 +750,10 @@ class Coarsen(CoarsenArithmetic):
768750 "windows" ,
769751 "side" ,
770752 "trim_excess" ,
771- "keep_attrs" ,
772753 )
773754 _attributes = ("windows" , "side" , "trim_excess" )
774755
775- def __init__ (self , obj , windows , boundary , side , coord_func , keep_attrs ):
756+ def __init__ (self , obj , windows , boundary , side , coord_func ):
776757 """
777758 Moving window object.
778759
@@ -799,17 +780,6 @@ def __init__(self, obj, windows, boundary, side, coord_func, keep_attrs):
799780 self .side = side
800781 self .boundary = boundary
801782
802- if keep_attrs is not None :
803- warnings .warn (
804- "Passing ``keep_attrs`` to ``coarsen`` is deprecated and will raise an"
805- " error in xarray 0.19. Please pass ``keep_attrs`` directly to the"
806- " applied function, i.e. use ``ds.coarsen(...).mean(keep_attrs=False)``"
807- " instead of ``ds.coarsen(..., keep_attrs=False).mean()``"
808- " Note that keep_attrs is now True per default." ,
809- FutureWarning ,
810- )
811- self .keep_attrs = keep_attrs
812-
813783 absent_dims = [dim for dim in windows .keys () if dim not in self .obj .dims ]
814784 if absent_dims :
815785 raise ValueError (
@@ -823,15 +793,8 @@ def __init__(self, obj, windows, boundary, side, coord_func, keep_attrs):
823793 self .coord_func = coord_func
824794
825795 def _get_keep_attrs (self , keep_attrs ):
826-
827796 if keep_attrs is None :
828- # TODO: uncomment the next line and remove the others after the deprecation
829- # keep_attrs = _get_keep_attrs(default=True)
830-
831- if self .keep_attrs is None :
832- keep_attrs = _get_keep_attrs (default = True )
833- else :
834- keep_attrs = self .keep_attrs
797+ keep_attrs = _get_keep_attrs (default = True )
835798
836799 return keep_attrs
837800
0 commit comments