Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/astroid/brain/brain_numpy_ma.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

9 statements  

1# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html 

2# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE 

3# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt 

4 

5"""Astroid hooks for numpy ma module.""" 

6 

7from astroid import nodes 

8from astroid.brain.helpers import register_module_extender 

9from astroid.builder import parse 

10from astroid.manager import AstroidManager 

11 

12 

13def numpy_ma_transform() -> nodes.Module: 

14 """ 

15 Infer the call of various numpy.ma functions. 

16 

17 :param node: node to infer 

18 :param context: inference context 

19 """ 

20 return parse( 

21 """ 

22 import numpy.ma 

23 def masked_where(condition, a, copy=True): 

24 return numpy.ma.masked_array(a, mask=[]) 

25 

26 def masked_invalid(a, copy=True): 

27 return numpy.ma.masked_array(a, mask=[]) 

28 """ 

29 ) 

30 

31 

32def register(manager: AstroidManager) -> None: 

33 register_module_extender(manager, "numpy.ma", numpy_ma_transform)