brain_numpy_ma.py 788 B

12345678910111213141516171819202122232425262728
  1. # Copyright (c) 2021 hippo91 <guillaume.peillex@gmail.com>
  2. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  3. # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
  4. """Astroid hooks for numpy ma module"""
  5. from astroid.brain.helpers import register_module_extender
  6. from astroid.builder import parse
  7. from astroid.manager import AstroidManager
  8. def numpy_ma_transform():
  9. """
  10. Infer the call of the masked_where function
  11. :param node: node to infer
  12. :param context: inference context
  13. """
  14. return parse(
  15. """
  16. import numpy.ma
  17. def masked_where(condition, a, copy=True):
  18. return numpy.ma.masked_array(a, mask=[])
  19. """
  20. )
  21. register_module_extender(AstroidManager(), "numpy.ma", numpy_ma_transform)