[Numpy-svn] r3626 - in trunk/numpy: . core/include/numpy

numpy-svn@scip... numpy-svn@scip...
Sat Mar 31 17:56:24 CDT 2007


Author: oliphant
Date: 2007-03-31 17:56:19 -0500 (Sat, 31 Mar 2007)
New Revision: 3626

Modified:
   trunk/numpy/__init__.py
   trunk/numpy/_import_tools.py
   trunk/numpy/core/include/numpy/ndarrayobject.h
Log:
Add new MACRO.  Fix ticket #454 by changing pkgload to a function instead of an object.

Modified: trunk/numpy/__init__.py
===================================================================
--- trunk/numpy/__init__.py	2007-03-31 07:40:31 UTC (rev 3625)
+++ trunk/numpy/__init__.py	2007-03-31 22:56:19 UTC (rev 3626)
@@ -29,8 +29,11 @@
     from version import version as __version__
 
     from _import_tools import PackageLoader
-    pkgload = PackageLoader()
 
+    def pkgload(*packages, **options):
+        loader = PackageLoader(infunc=True)
+        return loader(*packages, **options)
+
     import testing
     from testing import ScipyTest, NumpyTest
     import core

Modified: trunk/numpy/_import_tools.py
===================================================================
--- trunk/numpy/_import_tools.py	2007-03-31 07:40:31 UTC (rev 3625)
+++ trunk/numpy/_import_tools.py	2007-03-31 22:56:19 UTC (rev 3626)
@@ -7,11 +7,15 @@
 __all__ = ['PackageLoader']
 
 class PackageLoader:
-    def __init__(self, verbose=False):
+    def __init__(self, verbose=False, infunc=False):
         """ Manages loading packages.
         """
 
-        self.parent_frame = frame = sys._getframe(1)
+        if infunc:
+            _level = 2
+        else:
+            _level = 1
+        self.parent_frame = frame = sys._getframe(_level)
         self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)
         parent_path = eval('__path__',frame.f_globals,frame.f_locals)
         if isinstance(parent_path, str):

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2007-03-31 07:40:31 UTC (rev 3625)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2007-03-31 22:56:19 UTC (rev 3626)
@@ -1761,9 +1761,9 @@
 
 
 #define PyDataType_ISNOTSWAPPED(d) PyArray_ISNBO(((PyArray_Descr *)(d))->byteorder)
+#define PyDataType_ISBYTESWAPPED(d) (!PyDataType_ISNOTSWAPPED(d))
 
 
-
 /* This is the form of the struct that's returned pointed by the
    PyCObject attribute of an array __array_struct__. See
    http://numeric.scipy.org/array_interface.html for the full



More information about the Numpy-svn mailing list