55
66import numpy as np
77
8- from pandas .core .dtypes .common import is_integer
98from pandas .core .dtypes .generic import ABCDataFrame , ABCSeries
109
11- import pandas .core .common as com
1210from pandas .core .generic import _shared_docs
1311from pandas .core .groupby .base import GroupByMixin
1412from pandas .core .indexes .api import MultiIndex
@@ -224,75 +222,6 @@ def dataframe_from_int_dict(data, frame_template):
224222 return _flex_binary_moment (arg2 , arg1 , f )
225223
226224
227- def _get_center_of_mass (comass , span , halflife , alpha ):
228- valid_count = com .count_not_none (comass , span , halflife , alpha )
229- if valid_count > 1 :
230- raise ValueError ("comass, span, halflife, and alpha are mutually exclusive" )
231-
232- # Convert to center of mass; domain checks ensure 0 < alpha <= 1
233- if comass is not None :
234- if comass < 0 :
235- raise ValueError ("comass must satisfy: comass >= 0" )
236- elif span is not None :
237- if span < 1 :
238- raise ValueError ("span must satisfy: span >= 1" )
239- comass = (span - 1 ) / 2.0
240- elif halflife is not None :
241- if halflife <= 0 :
242- raise ValueError ("halflife must satisfy: halflife > 0" )
243- decay = 1 - np .exp (np .log (0.5 ) / halflife )
244- comass = 1 / decay - 1
245- elif alpha is not None :
246- if alpha <= 0 or alpha > 1 :
247- raise ValueError ("alpha must satisfy: 0 < alpha <= 1" )
248- comass = (1.0 - alpha ) / alpha
249- else :
250- raise ValueError ("Must pass one of comass, span, halflife, or alpha" )
251-
252- return float (comass )
253-
254-
255- def calculate_center_offset (window ):
256- if not is_integer (window ):
257- window = len (window )
258- return int ((window - 1 ) / 2.0 )
259-
260-
261- def calculate_min_periods (
262- window : int ,
263- min_periods : Optional [int ],
264- num_values : int ,
265- required_min_periods : int ,
266- floor : int ,
267- ) -> int :
268- """
269- Calculates final minimum periods value for rolling aggregations.
270-
271- Parameters
272- ----------
273- window : passed window value
274- min_periods : passed min periods value
275- num_values : total number of values
276- required_min_periods : required min periods per aggregation function
277- floor : required min periods per aggregation function
278-
279- Returns
280- -------
281- min_periods : int
282- """
283- if min_periods is None :
284- min_periods = window
285- else :
286- min_periods = max (required_min_periods , min_periods )
287- if min_periods > window :
288- raise ValueError (f"min_periods { min_periods } must be <= window { window } " )
289- elif min_periods > num_values :
290- min_periods = num_values + 1
291- elif min_periods < 0 :
292- raise ValueError ("min_periods must be >= 0" )
293- return max (min_periods , floor )
294-
295-
296225def zsqrt (x ):
297226 with np .errstate (all = "ignore" ):
298227 result = np .sqrt (x )
@@ -317,12 +246,3 @@ def prep_binary(arg1, arg2):
317246 Y = arg2 + 0 * arg1
318247
319248 return X , Y
320-
321-
322- def get_weighted_roll_func (cfunc : Callable ) -> Callable :
323- def func (arg , window , min_periods = None ):
324- if min_periods is None :
325- min_periods = len (window )
326- return cfunc (arg , window , min_periods )
327-
328- return func
0 commit comments