[Scipy-svn] r4776 - in branches/mb_mio_refactor: . arff/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sun Oct 5 01:02:36 EDT 2008


Author: matthew.brett at gmail.com
Date: 2008-10-05 00:02:32 -0500 (Sun, 05 Oct 2008)
New Revision: 4776

Modified:
   branches/mb_mio_refactor/SConscript
   branches/mb_mio_refactor/arff/tests/test_data.py
   branches/mb_mio_refactor/arff/tests/test_header.py
   branches/mb_mio_refactor/array_import.py
   branches/mb_mio_refactor/fopen.py
   branches/mb_mio_refactor/mmio.py
   branches/mb_mio_refactor/netcdf.py
   branches/mb_mio_refactor/npfile.py
   branches/mb_mio_refactor/wavfile.py
Log:
Completed copy of scipy working tree into branch

Modified: branches/mb_mio_refactor/SConscript
===================================================================
--- branches/mb_mio_refactor/SConscript	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/SConscript	2008-10-05 05:02:32 UTC (rev 4776)
@@ -1,11 +1,7 @@
 # Last Change: Wed Mar 05 03:00 PM 2008 J
 # vim:syntax=python
-from os.path import join
-
-from numpy.distutils.misc_util import get_numpy_include_dirs
 from numscons import GetNumpyEnvironment
 
 env = GetNumpyEnvironment(ARGUMENTS)
 
-env.AppendUnique(CPPPATH = get_numpy_include_dirs())
-env.DistutilsPythonExtension('numpyio', source = 'numpyiomodule.c')
+env.NumpyPythonExtension('numpyio', source = 'numpyiomodule.c')

Modified: branches/mb_mio_refactor/arff/tests/test_data.py
===================================================================
--- branches/mb_mio_refactor/arff/tests/test_data.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/arff/tests/test_data.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -2,9 +2,10 @@
 """Tests for parsing full arff files."""
 import os
 
-import numpy as N
-from scipy.testing import *
+import numpy as np
 
+from numpy.testing import *
+
 from scipy.io.arff.arffread import loadarff
 
 data_path = os.path.join(os.path.dirname(__file__), 'data')
@@ -16,8 +17,8 @@
         (1, 2, 3, 4, 'class3')]
 
 missing = os.path.join(data_path, 'missing.arff')
-expect_missing_raw = N.array([[1, 5], [2, 4], [N.nan, N.nan]])
-expect_missing = N.empty(3, [('yop', N.float), ('yap', N.float)])
+expect_missing_raw = np.array([[1, 5], [2, 4], [np.nan, np.nan]])
+expect_missing = np.empty(3, [('yop', np.float), ('yap', np.float)])
 expect_missing['yop'] = expect_missing_raw[:, 0]
 expect_missing['yap'] = expect_missing_raw[:, 1]
 

Modified: branches/mb_mio_refactor/arff/tests/test_header.py
===================================================================
--- branches/mb_mio_refactor/arff/tests/test_header.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/arff/tests/test_header.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -2,10 +2,9 @@
 """Test for parsing arff headers only."""
 import os
 
-from scipy.testing import *
+from numpy.testing import *
 
-from scipy.io.arff.arffread import read_header, MetaData, parse_type, \
-                                   ParseArffError
+from scipy.io.arff.arffread import read_header, parse_type, ParseArffError
 
 data_path = os.path.join(os.path.dirname(__file__), 'data')
 

Modified: branches/mb_mio_refactor/array_import.py
===================================================================
--- branches/mb_mio_refactor/array_import.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/array_import.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -169,7 +169,7 @@
             return lines[:-1]
 
     def __del__(self):
-        if hasattr(self.file,'close') and self.should_close_file:
+        if hasattr(getattr(self, 'file', None),'close') and self.should_close_file:
             self.file.close()
 
     def __getitem__(self, item):

Modified: branches/mb_mio_refactor/fopen.py
===================================================================
--- branches/mb_mio_refactor/fopen.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/fopen.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -2,7 +2,8 @@
 
 # Author: Travis Oliphant
 
-import struct, os, sys
+import struct
+import sys
 import types
 
 from numpy import *

Modified: branches/mb_mio_refactor/mmio.py
===================================================================
--- branches/mb_mio_refactor/mmio.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/mmio.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -10,9 +10,8 @@
 #
 
 import os
-from numpy import asarray, real, imag, conj, zeros, ndarray, \
-                  empty, concatenate, ones, ascontiguousarray, \
-                  vstack, savetxt, fromfile, fromstring
+from numpy import asarray, real, imag, conj, zeros, ndarray, concatenate, \
+                  ones, ascontiguousarray, vstack, savetxt, fromfile, fromstring
 
 __all__ = ['mminfo','mmread','mmwrite', 'MMFile']
 

Modified: branches/mb_mio_refactor/netcdf.py
===================================================================
--- branches/mb_mio_refactor/netcdf.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/netcdf.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -15,7 +15,6 @@
 __all__ = ['netcdf_file', 'netcdf_variable']
 
 import struct
-import itertools
 import mmap
 
 from numpy import ndarray, zeros, array

Modified: branches/mb_mio_refactor/npfile.py
===================================================================
--- branches/mb_mio_refactor/npfile.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/npfile.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -6,7 +6,7 @@
 
 import sys
 
-import numpy as N
+import numpy as np
 
 __all__ = ['sys_endian_code', 'npfile']
 
@@ -40,9 +40,9 @@
 
     Example use:
     >>> from StringIO import StringIO
-    >>> import numpy as N
+    >>> import numpy as np
     >>> from scipy.io import npfile
-    >>> arr = N.arange(10).reshape(5,2)
+    >>> arr = np.arange(10).reshape(5,2)
     >>> # Make file-like object (could also be file name)
     >>> my_file = StringIO()
     >>> npf = npfile(my_file)
@@ -167,7 +167,7 @@
                     (if None from self.order)
         '''
         endian, order = self._endian_order(endian, order)
-        data = N.asarray(data)
+        data = np.asarray(data)
         dt_endian = self._endian_from_dtype(data.dtype)
         if not endian == 'dtype':
             if dt_endian != endian:
@@ -194,7 +194,7 @@
         arr       - array from file with given dtype (dt)
         '''
         endian, order = self._endian_order(endian, order)
-        dt = N.dtype(dt)
+        dt = np.dtype(dt)
         try:
             shape = list(shape)
         except TypeError:
@@ -203,7 +203,7 @@
         if minus_ones == 0:
             pass
         elif minus_ones == 1:
-            known_dimensions_size = -N.product(shape,axis=0) * dt.itemsize
+            known_dimensions_size = -np.product(shape,axis=0) * dt.itemsize
             unknown_dimension_size, illegal = divmod(self.remaining_bytes(),
                                                      known_dimensions_size)
             if illegal:
@@ -212,10 +212,10 @@
         else:
             raise ValueError(
                 "illegal -1 count; can only specify one unknown dimension")
-        sz = dt.itemsize * N.product(shape)
+        sz = dt.itemsize * np.product(shape)
         dt_endian = self._endian_from_dtype(dt)
         buf = self.file.read(sz)
-        arr = N.ndarray(shape=shape,
+        arr = np.ndarray(shape=shape,
                          dtype=dt,
                          buffer=buf,
                          order=order)
@@ -223,7 +223,7 @@
             return arr.byteswap()
         return arr.copy()
 
-npfile = N.deprecate_with_doc("""
+npfile = np.deprecate_with_doc("""
 You can achieve the same effect as using npfile, using ndarray.tofile
 and numpy.fromfile.
 

Modified: branches/mb_mio_refactor/wavfile.py
===================================================================
--- branches/mb_mio_refactor/wavfile.py	2008-10-05 04:49:23 UTC (rev 4775)
+++ branches/mb_mio_refactor/wavfile.py	2008-10-05 05:02:32 UTC (rev 4776)
@@ -4,7 +4,7 @@
 # assumes file pointer is immediately
 #  after the 'fmt ' id
 def _read_fmt_chunk(fid):
-    res = struct.unpack('lhHLLHH',fid.read(20))
+    res = struct.unpack('ihHIIHH',fid.read(20))
     size, comp, noc, rate, sbytes, ba, bits = res
     if (comp != 1 or size > 16):
         print "Warning:  unfamiliar format bytes..."
@@ -96,7 +96,7 @@
     bits = data.dtype.itemsize * 8
     sbytes = rate*(bits / 8)*noc
     ba = noc * (bits / 8)
-    fid.write(struct.pack('lhHLLHH', 16, 1, noc, rate, sbytes, ba, bits))
+    fid.write(struct.pack('ihHIIHH', 16, 1, noc, rate, sbytes, ba, bits))
     # data chunk
     fid.write('data')
     fid.write(struct.pack('i', data.nbytes))




More information about the Scipy-svn mailing list