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

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

28 statements  

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

2 

3import warnings 

4 

5import numpy as np 

6 

7from pandas.util.version import Version 

8 

9# numpy versioning 

10_np_version = np.__version__ 

11_nlv = Version(_np_version) 

12np_version_gt2 = _nlv >= Version("2.0.0") 

13np_version_gt2_3 = _nlv >= Version("2.3.0") 

14np_version_gt2_5 = _nlv >= Version("2.5.0") 

15np_version_gt2_6 = _nlv >= Version("2.6.0.dev0") 

16is_numpy_dev = _nlv.dev is not None 

17_min_numpy_ver = "1.26.0" 

18 

19 

20if _nlv < Version(_min_numpy_ver): 

21 raise ImportError( 

22 f"Please upgrade numpy to >= {_min_numpy_ver} to use this pandas version.\n" 

23 f"Your numpy version is {_np_version}." 

24 ) 

25 

26 

27np_long: type 

28np_ulong: type 

29 

30if np_version_gt2: 

31 try: 

32 with warnings.catch_warnings(): 

33 warnings.filterwarnings( 

34 "ignore", 

35 r".*In the future `np\.long` will be defined as.*", 

36 FutureWarning, 

37 ) 

38 np_long = np.long 

39 np_ulong = np.ulong 

40 except AttributeError: 

41 np_long = np.int_ 

42 np_ulong = np.uint 

43else: 

44 np_long = np.int_ 

45 np_ulong = np.uint 

46 

47 

48__all__ = [ 

49 "_np_version", 

50 "is_numpy_dev", 

51]