1. Keisuke Takahashi
  2. pypy


Armin Rigo  committed 65001a8

Add a module 'numpy' which raises an ImportError giving a detailed
explanation. Tweak 'numpypy' to replace 'numpy' when imported.

  • Participants
  • Parent commits c772d9d
  • Branches default

Comments (0)

Files changed (3)

File lib_pypy/numpy.py

View file
  • Ignore whitespace
+raise ImportError(
+    "The 'numpy' module of PyPy is in-development and not complete. "
+    "To try it out anyway, you can either import from 'numpypy', "
+    "or just write 'import numpypy' first in your program and then "
+    "import from 'numpy' as usual.")

File lib_pypy/numpypy/__init__.py

View file
  • Ignore whitespace
 from _numpypy import *
 from .core import *
+import sys
+sys.modules.setdefault('numpy', sys.modules['numpypy'])

File pypy/module/test_lib_pypy/numpypy/test_numpy.py

View file
  • Ignore whitespace
+from pypy.conftest import gettestobjspace
+class AppTestNumpy:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=['micronumpy'])
+    def test_imports(self):
+        try:
+            import numpy   # fails if 'numpypy' was not imported so far
+        except ImportError:
+            pass
+        import numpypy
+        import numpy     # works after 'numpypy' has been imported