diff options
author | cookedm <cookedm@localhost> | 2006-02-21 23:01:17 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2006-02-21 23:01:17 +0000 |
commit | 0aa85cabe66a188a409e51e04186a050ba6d2d79 (patch) | |
tree | 326fdded339b8111ed8902595aa70b4f0a535252 /numpy | |
parent | b7db375217b511008205112cb015d10b1d577252 (diff) | |
download | numpy-0aa85cabe66a188a409e51e04186a050ba6d2d79.tar.gz |
Improve umath generation a bit (ufuncs are outputed in name-sorted order)
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index d9af119bd..727e0e6c4 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -9,9 +9,21 @@ class TypeDescription(object): def __init__(self, type, f=None, in_=None, out=None): self.type = type self.func_data = f + if in_ is not None: + in_ = in_.replace('.', type) self.in_ = in_ + if out is not None: + out = out.replace('.', type) self.out = out + def finish_signature(self, nin, nout): + if self.in_ is None: + self.in_ = self.type * nin + assert len(self.in_) == nin + if self.out is None: + self.out = self.type * nout + assert len(self.out) == nout + _fdata_map = dict(f='%sf', d='%s', g='%sl', F='nc_%sf', D='nc_%s', G='nc_%sl') def build_func_data(types, f): @@ -55,6 +67,8 @@ class Ufunc(object): self.type_descriptions = [] for td in type_descriptions: self.type_descriptions.extend(td) + for td in self.type_descriptions: + td.finish_signature(self.nin, self.nout) #each entry in defdict is @@ -501,7 +515,10 @@ def make_arrays(funcdict): # code1list = [] code2list = [] - for name, uf in funcdict.iteritems(): + names = funcdict.keys() + names.sort() + for name in names: + uf = funcdict[name] funclist = [] datalist = [] siglist = [] @@ -535,17 +552,7 @@ def make_arrays(funcdict): tname = chartoname[t.type].upper() funclist.append('%s_%s' % (tname, name)) - if t.in_ is None: - xlist = t.type * uf.nin - else: - xlist = t.in_ - for x in xlist: - siglist.append('PyArray_%s' % (chartoname[x].upper(),)) - if t.out is None: - xlist = t.type * uf.nout - else: - xlist = t.out - for x in xlist: + for x in t.in_ + t.out: siglist.append('PyArray_%s' % (chartoname[x].upper(),)) k += 1 @@ -563,7 +570,10 @@ def make_arrays(funcdict): def make_ufuncs(funcdict): code3list = [] - for name, uf in funcdict.items(): + names = funcdict.keys() + names.sort() + for name in names: + uf = funcdict[name] mlist = [] mlist.append(\ r"""f = PyUFunc_FromFuncAndData(%s_functions, %s_data, %s_signatures, %d, |