brain_numpy_ma.py 990 B

123456789101112131415161718192021222324252627282930313233
  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. """Astroid hooks for numpy ma module."""
  5. from astroid import nodes
  6. from astroid.brain.helpers import register_module_extender
  7. from astroid.builder import parse
  8. from astroid.manager import AstroidManager
  9. def numpy_ma_transform() -> nodes.Module:
  10. """
  11. Infer the call of various numpy.ma functions.
  12. :param node: node to infer
  13. :param context: inference context
  14. """
  15. return parse(
  16. """
  17. import numpy.ma
  18. def masked_where(condition, a, copy=True):
  19. return numpy.ma.masked_array(a, mask=[])
  20. def masked_invalid(a, copy=True):
  21. return numpy.ma.masked_array(a, mask=[])
  22. """
  23. )
  24. def register(manager: AstroidManager) -> None:
  25. register_module_extender(manager, "numpy.ma", numpy_ma_transform)