Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py: 89%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

18 statements  

1""" support numpy compatibility across versions """ 

2import numpy as np 

3 

4from pandas.util.version import Version 

5 

6# numpy versioning 

7_np_version = np.__version__ 

8_nlv = Version(_np_version) 

9np_version_under1p21 = _nlv < Version("1.21") 

10np_version_under1p22 = _nlv < Version("1.22") 

11np_version_gte1p22 = _nlv >= Version("1.22") 

12np_version_gte1p24 = _nlv >= Version("1.24") 

13np_version_gte1p24p3 = _nlv >= Version("1.24.3") 

14np_version_gte1p25 = _nlv >= Version("1.25") 

15is_numpy_dev = _nlv.dev is not None 

16_min_numpy_ver = "1.20.3" 

17 

18if is_numpy_dev or not np_version_under1p22: 

19 np_percentile_argname = "method" 

20else: 

21 np_percentile_argname = "interpolation" 

22 

23 

24if _nlv < Version(_min_numpy_ver): 

25 raise ImportError( 

26 f"this version of pandas is incompatible with numpy < {_min_numpy_ver}\n" 

27 f"your numpy version is {_np_version}.\n" 

28 f"Please upgrade numpy to >= {_min_numpy_ver} to use this pandas version" 

29 ) 

30 

31 

32__all__ = [ 

33 "np", 

34 "_np_version", 

35 "is_numpy_dev", 

36]