brain_numpy_ma.py 896 B

12345678910111213141516171819202122232425262728293031
  1. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  2. # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
  3. # Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
  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 various numpy.ma functions.
  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. def masked_invalid(a, copy=True):
  20. return numpy.ma.masked_array(a, mask=[])
  21. """
  22. )
  23. register_module_extender(AstroidManager(), "numpy.ma", numpy_ma_transform)