summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scipy/base/convertcode.py1
-rw-r--r--scipy/base/function_base.py55
-rw-r--r--scipy/test/__init__.py (renamed from test/__init__.py)0
-rw-r--r--scipy/test/auto_test.py (renamed from test/auto_test.py)0
-rw-r--r--scipy/test/info_scipy_test.py (renamed from test/info_scipy_test.py)0
-rw-r--r--scipy/test/logging.py (renamed from test/logging.py)0
-rw-r--r--scipy/test/scipy_test_version.py (renamed from test/scipy_test_version.py)0
-rwxr-xr-xscipy/test/setup_scipy_test.py (renamed from test/setup_scipy_test.py)0
-rw-r--r--scipy/test/testing.py (renamed from test/testing.py)0
-rwxr-xr-xsetup.py7
-rw-r--r--weave/__init__.py4
-rw-r--r--weave/accelerate_tools.py6
-rw-r--r--weave/blitz_spec.py7
-rw-r--r--weave/blitz_tools.py2
-rw-r--r--weave/catalog.py5
-rw-r--r--weave/converters.py2
-rwxr-xr-xweave/setup.py8
-rwxr-xr-xweave/setup_weave.py47
-rw-r--r--weave/size_check.py2
-rw-r--r--weave/standard_array_spec.py21
20 files changed, 92 insertions, 75 deletions
diff --git a/scipy/base/convertcode.py b/scipy/base/convertcode.py
index 08d43066f..a63ea83d7 100644
--- a/scipy/base/convertcode.py
+++ b/scipy/base/convertcode.py
@@ -38,7 +38,6 @@ def replacetypechars(astr):
astr = astr.replace("'c'","'S1'")
astr = astr.replace("'b'","'B'")
astr = astr.replace("'1'","'b'")
- astr = astr.replace("'s'","'h'")
astr = astr.replace("'w'","'H'")
astr = astr.replace("'u'","'I'")
return astr
diff --git a/scipy/base/function_base.py b/scipy/base/function_base.py
index 693951cab..a1ed19449 100644
--- a/scipy/base/function_base.py
+++ b/scipy/base/function_base.py
@@ -1,6 +1,6 @@
import types
import numeric as _nx
-from numeric import ones, zeros, arange, concatenate, array, asarray
+from numeric import ones, zeros, arange, concatenate, array, asarray, empty
from umath import pi, multiply, add, arctan2, maximum, minimum, frompyfunc, \
isnan
from oldnumeric import ravel, nonzero, choose, \
@@ -10,7 +10,7 @@ from shape_base import squeeze, atleast_1d
from _compiled_base import digitize, bincount, _insert
__all__ = ['round','logspace','linspace','fix','mod',
- 'select','trim_zeros','alen','amax', 'amin', 'ptp',
+ 'select','piecewise','trim_zeros','alen','amax', 'amin', 'ptp',
'copy',
'prod','cumprod', 'diff','gradient','angle','unwrap','sort_complex',
'disp','unique','extract','insert','nansum','nanmax','nanargmax',
@@ -175,13 +175,62 @@ def mod(x,y):
"""
return x - y*_nx.floor(x*1.0/y)
+def piecewise(x, condlist, funclist, *args, **kw):
+ """Returns a piecewise-defined function.
+
+ x is the domain
+
+ condlist is a list of boolean arrays or a single boolean array
+ The length of the condition list must be n2 or n2-1 where n2
+ is the length of the function list. If len(condlist)==n2-1, then
+ an 'otherwise' condition is formed by |'ing all the conditions
+ and inverting.
+
+ funclist is a list of functions to call of length (n2).
+ Each function should return an array output for an array input
+ Each function can take (the same set) of extra arguments and
+ keyword arguments which are passed in after the function list.
+
+ The output is the same shape and type as x and is found by
+ calling the functions on the appropriate portions of x.
+
+ Note: This is similar to choose or select, except
+ the the functions are only evaluated on elements of x
+ that satisfy the corresponding condition.
+
+ The result is
+ |--
+ | f1(x) for condition1
+ y = --| f2(x) for condition2
+ | ...
+ | fn(x) for conditionn
+ |--
+
+ """
+ n2 = len(funclist)
+ if not isinstance(condlist, type([])):
+ condlist = [condlist]
+ n = len(condlist)
+ if n == n2-1: # compute the "otherwise" condition.
+ totlist = condlist[0]
+ for k in range(1,n):
+ totlist |= condlist
+ condlist.append(~totlist)
+ n += 1
+ if (n != n2):
+ raise ValueError, "function list and condition list must be the same."
+ y = empty(x.shape, x.dtype)
+ for k in range(n):
+ y[condlist[k]] = funclist[k](x[condlist[k]], *args, **kw)
+ return y
+
def select(condlist, choicelist, default=0):
""" Returns an array comprised from different elements of choicelist
depending on the list of conditions.
condlist is a list of condition arrays containing ones or zeros
- choicelist is a list of choice matrices (of the "same" size as the
+ choicelist is a list of choice arrays (of the "same" size as the
arrays in condlist). The result array has the "same" size as the
arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist
must be of length N. The elements of the choicelist can then be
diff --git a/test/__init__.py b/scipy/test/__init__.py
index f86197cda..f86197cda 100644
--- a/test/__init__.py
+++ b/scipy/test/__init__.py
diff --git a/test/auto_test.py b/scipy/test/auto_test.py
index c86014c8f..c86014c8f 100644
--- a/test/auto_test.py
+++ b/scipy/test/auto_test.py
diff --git a/test/info_scipy_test.py b/scipy/test/info_scipy_test.py
index 3290ef3a1..3290ef3a1 100644
--- a/test/info_scipy_test.py
+++ b/scipy/test/info_scipy_test.py
diff --git a/test/logging.py b/scipy/test/logging.py
index 1973471ce..1973471ce 100644
--- a/test/logging.py
+++ b/scipy/test/logging.py
diff --git a/test/scipy_test_version.py b/scipy/test/scipy_test_version.py
index 8f27d48a8..8f27d48a8 100644
--- a/test/scipy_test_version.py
+++ b/scipy/test/scipy_test_version.py
diff --git a/test/setup_scipy_test.py b/scipy/test/setup_scipy_test.py
index 6495ffa90..6495ffa90 100755
--- a/test/setup_scipy_test.py
+++ b/scipy/test/setup_scipy_test.py
diff --git a/test/testing.py b/scipy/test/testing.py
index 48752e5b5..48752e5b5 100644
--- a/test/testing.py
+++ b/scipy/test/testing.py
diff --git a/setup.py b/setup.py
index 044b9ada4..4d3a10d4a 100755
--- a/setup.py
+++ b/setup.py
@@ -16,12 +16,13 @@ def setup_package():
try:
config = Configuration(
version = version,
- maintainer = "Travis Oliphant",
- maintainer_email = "oliphant.travis@ieee.org",
+ maintainer = "SciPy Developers",
+ maintainer_email = "scipy-dev@scipy.org",
description = "Core SciPy",
- url = "http://numpy.sourceforge.net",
+ url = "http://numeric.scipy.org",
)
config.add_subpackage('scipy')
+ config.add_subpackage('weave')
config.name = 'scipy_core'
print config.name,'version',config.version
setup( **config.todict() )
diff --git a/weave/__init__.py b/weave/__init__.py
index fc54088da..eea8d383c 100644
--- a/weave/__init__.py
+++ b/weave/__init__.py
@@ -8,7 +8,7 @@ from weave_version import weave_version as __version__
try:
from blitz_tools import blitz
except ImportError:
- pass # Numeric wasn't available
+ pass # scipy (core) wasn't available
from inline_tools import inline
import ext_tools
@@ -18,5 +18,5 @@ try:
except:
pass
-from scipy_test.testing import ScipyTest
+from scipy.test.testing import ScipyTest
test = ScipyTest('weave').test
diff --git a/weave/accelerate_tools.py b/weave/accelerate_tools.py
index f9b59a0df..0b6fc581a 100644
--- a/weave/accelerate_tools.py
+++ b/weave/accelerate_tools.py
@@ -109,7 +109,7 @@ Integer = Integer()
Double = Double()
String = String()
-import scipy_base.numerix as nx
+import scipy.base as nx
class Vector(Type_Descriptor):
cxxtype = 'PyArrayObject*'
@@ -121,7 +121,7 @@ class Vector(Type_Descriptor):
owned = 0 # Convertion is by casting!
prerequisites = Type_Descriptor.prerequisites+\
- [nx.NX_INCLUDE]
+ ['#include "scipy/arrayobject.h"']
dims = 1
def check(self,s):
return "PyArray_Check(%s) && ((PyArrayObject*)%s)->nd == %d && ((PyArrayObject*)%s)->descr->type_num == %s"%(
@@ -260,7 +260,7 @@ def lookup_type(x):
try:
return typedefs[T]
except:
- import scipy_base.numerix as nx
+ import scipy.base as nx
if isinstance(T,nx.ArrayType):
return typedefs[(T,len(x.shape),x.typecode())]
elif T == InstanceType:
diff --git a/weave/blitz_spec.py b/weave/blitz_spec.py
index 088a03560..2f0c97ba7 100644
--- a/weave/blitz_spec.py
+++ b/weave/blitz_spec.py
@@ -4,13 +4,12 @@
handle different data types. The information includes
such as include files, libraries, and even code snippets.
- array_info -- for building functions that use Python
- numerix arrays.
+ array_info -- for building functions that use scipy arrays
"""
import base_info
import standard_array_spec
-from scipy_base.numerix import *
+from scipy.base import *
from types import *
import os
@@ -85,7 +84,7 @@ class array_converter(standard_array_spec.array_converter):
def init_info(self):
standard_array_spec.array_converter.init_info(self)
blitz_headers = ['"blitz/array.h"',
- '"%s/arrayobject.h"' % nx.NX_ARRAYPKG,
+ '"scipy/arrayobject.h"',
'<complex>','<math.h>']
self.headers.extend(blitz_headers)
self.include_dirs = [blitz_dir]
diff --git a/weave/blitz_tools.py b/weave/blitz_tools.py
index 71719dc1f..8adf7913a 100644
--- a/weave/blitz_tools.py
+++ b/weave/blitz_tools.py
@@ -10,7 +10,7 @@ import converters
from ast_tools import *
-from scipy_base.numerix import *
+from scipy.base import *
from types import *
import inline_tools
diff --git a/weave/catalog.py b/weave/catalog.py
index 41444069a..d77adda6a 100644
--- a/weave/catalog.py
+++ b/weave/catalog.py
@@ -34,7 +34,6 @@
import os,sys,string
import pickle
import tempfile
-import scipy_base.numerix as nx
try:
import dbhash
@@ -156,7 +155,6 @@ def default_dir():
to try and keep people from being able to sneak a bad module
in on you.
- NUMERIX adds a suffix of _numeric or _numarray to the dirname.
"""
# Use a cached value for fast return if possible
@@ -168,8 +166,7 @@ def default_dir():
python_name = "python%d%d_compiled" % tuple(sys.version_info[:2])
if sys.platform != 'win32':
try:
- path = os.path.join(os.environ['HOME'],'.' + python_name +
- "_" + nx.which[0])
+ path = os.path.join(os.environ['HOME'],'.' + python_name)
except KeyError:
temp_dir = `os.getuid()` + '_' + python_name
path = os.path.join(tempfile.gettempdir(),temp_dir)
diff --git a/weave/converters.py b/weave/converters.py
index 89893e643..51eeabb1b 100644
--- a/weave/converters.py
+++ b/weave/converters.py
@@ -21,7 +21,7 @@ default = [c_spec.int_converter(),
#common_spec.module_converter()]
#----------------------------------------------------------------------------
-# If numerix is installed, add numeric array converters to the default
+# If scipy_core is installed, add numeric array converters to the default
# converter list.
#----------------------------------------------------------------------------
try:
diff --git a/weave/setup.py b/weave/setup.py
index fcd88d65a..e6bee0f5a 100755
--- a/weave/setup.py
+++ b/weave/setup.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
import os,sys
-from scipy_distutils.core import setup
-from scipy_distutils.misc_util import get_path, merge_config_dicts
-from scipy_distutils.misc_util import package_config
+from scipy.distutils.core import setup
+from scipy.distutils.misc_util import get_path, merge_config_dicts
+from scipy.distutils.misc_util import package_config
from weave_version import weave_version
@@ -13,7 +13,7 @@ def stand_alone_package(with_dependencies = 0):
try:
primary = ['weave']
if with_dependencies:
- dependencies= ['scipy_distutils','scipy_test','scipy_base']
+ dependencies= ['scipy.distutils','scipy.test','scipy.base']
else:
dependencies = []
diff --git a/weave/setup_weave.py b/weave/setup_weave.py
index f9bd66017..320a69065 100755
--- a/weave/setup_weave.py
+++ b/weave/setup_weave.py
@@ -2,54 +2,27 @@
import os
from glob import glob
-from scipy_distutils.misc_util import get_path, default_config_dict, dot_join
+from scipy.distutils.misc_util import get_path, Configuration, dot_join
def configuration(parent_package='',parent_path=None):
parent_path2 = parent_path
parent_path = parent_package
local_path = get_path(__name__,parent_path2)
- config = default_config_dict('weave',parent_package)
- config['packages'].append(dot_join(parent_package,'weave.tests'))
+ config = Configuration('weave',parent_package)
test_path = os.path.join(local_path,'tests')
- config['package_dir']['weave.tests'] = test_path
-
+ config.add_subpackage(dot_join(parent_package, 'tests'),test_path)
scxx_files = glob(os.path.join(local_path,'scxx','*.*'))
install_path = os.path.join(parent_path,'weave','scxx')
- config['data_files'].extend( [(install_path,scxx_files)])
-
- blitz_files = glob(os.path.join(local_path,'blitz','blitz','*.*'))
- install_path = os.path.join(parent_path,'weave','blitz',
- 'blitz')
- config['data_files'].extend( [(install_path,blitz_files)])
-
- array_files = glob(os.path.join(local_path,'blitz','blitz',
- 'array','*.*'))
- install_path = os.path.join(parent_path,'weave','blitz',
- 'blitz','array')
- config['data_files'].extend( [(install_path,array_files)])
-
- meta_files = glob(os.path.join(local_path,'blitz','blitz',
- 'meta','*.*'))
- install_path = os.path.join(parent_path,'weave','blitz',
- 'blitz','meta')
- config['data_files'].extend( [(install_path,meta_files)])
-
- swig_files = glob(os.path.join(local_path,'swig','*.c'))
- install_path = os.path.join(parent_path,'weave','swig')
- config['data_files'].extend( [(install_path,swig_files)])
-
- doc_files = glob(os.path.join(local_path,'doc','*.html'))
- install_path = os.path.join(parent_path,'weave','doc')
- config['data_files'].extend( [(install_path,doc_files)])
-
- example_files = glob(os.path.join(local_path,'examples','*.py'))
- install_path = os.path.join(parent_path,'weave','examples')
- config['data_files'].extend( [(install_path,example_files)])
-
+ config.add_data_dir(os.path.join(local_path,'scxx'))
+ config.add_data_dir(os.path.join(local_path,'blitz','blitz'))
+ config.add_data_dir(os.path.join(local_path,'blitz','blitz','array'))
+ config.add_data_dir(os.path.join(local_path,'blitz','blitz','meta'))
+ config.add_data_files(*glob(os.path.join(local_path,'doc','*.html')))
+ config.add_data_files(*glob(os.path.join(local_path,'examples','*.py')))
return config
if __name__ == '__main__':
- from scipy_distutils.core import setup
+ from scipy.distutils.core import setup
from weave_version import weave_version
setup(version = weave_version,
description = "Tools for inlining C/C++ in Python",
diff --git a/weave/size_check.py b/weave/size_check.py
index 1e3749e5f..b7a4c2387 100644
--- a/weave/size_check.py
+++ b/weave/size_check.py
@@ -1,4 +1,4 @@
-from scipy_base.numerix import *
+from scipy.base import *
from ast_tools import *
from types import *
diff --git a/weave/standard_array_spec.py b/weave/standard_array_spec.py
index 18651ca28..261aeb3a5 100644
--- a/weave/standard_array_spec.py
+++ b/weave/standard_array_spec.py
@@ -1,18 +1,17 @@
from c_spec import common_base_converter
from c_spec import num_to_c_types
-from scipy_base.numerix import *
+from scipy.base import *
from types import *
import os
num_typecode = {}
-num_typecode['c'] = 'PyArray_CHAR'
-num_typecode['1'] = 'PyArray_SBYTE'
-num_typecode['b'] = 'PyArray_UBYTE'
-num_typecode['s'] = 'PyArray_SHORT'
-num_typecode['w'] = 'PyArray_USHORT'
+num_typecode['b'] = 'PyArray_SBYTE'
+num_typecode['B'] = 'PyArray_UBYTE'
+num_typecode['h'] = 'PyArray_SHORT'
+num_typecode['H'] = 'PyArray_USHORT'
num_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??
-num_typecode['u'] = 'PyArray_UINT'
+num_typecode['I'] = 'PyArray_UINT'
num_typecode['l'] = 'PyArray_LONG'
num_typecode['f'] = 'PyArray_FLOAT'
num_typecode['d'] = 'PyArray_DOUBLE'
@@ -117,8 +116,8 @@ numeric_init_code = \
"""
Py_Initialize();
import_array();
-PyImport_ImportModule("%s");
-""" % NX_ARRAYPKG
+PyImport_ImportModule("scipy");
+"""
class array_converter(common_base_converter):
@@ -130,13 +129,13 @@ class array_converter(common_base_converter):
self.return_type = 'PyArrayObject*'
self.to_c_return = '(PyArrayObject*) py_obj'
self.matching_types = [ArrayType]
- self.headers = ['"%s/arrayobject.h"' % NX_ARRAYPKG,
+ self.headers = ['"scipy/arrayobject.h"',
'<complex>','<math.h>']
self.support_code = [size_check_code, type_check_code]
self.module_init_code = [numeric_init_code]
def get_var_type(self,value):
- return value.typecode()
+ return value.dtypechar
def template_vars(self,inline=0):
res = common_base_converter.template_vars(self,inline)