Author: Brian Kearns <[email protected]>
Branch:
Changeset: r67692:895903d707dd
Date: 2013-10-29 12:00 -0400
http://bitbucket.org/pypy/pypy/changeset/895903d707dd/
Log: clean up this file used for a single function
diff --git a/pypy/module/micronumpy/dot.py b/pypy/module/micronumpy/dot.py
deleted file mode 100644
--- a/pypy/module/micronumpy/dot.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from pypy.interpreter.error import OperationError
-
-def match_dot_shapes(space, left, right):
- left_shape = left.get_shape()
- right_shape = right.get_shape()
- my_critical_dim_size = left_shape[-1]
- right_critical_dim_size = right_shape[0]
- right_critical_dim = 0
- out_shape = []
- if len(right_shape) > 1:
- right_critical_dim = len(right_shape) - 2
- right_critical_dim_size = right_shape[right_critical_dim]
- assert right_critical_dim >= 0
- out_shape = out_shape + left_shape[:-1] + \
- right_shape[0:right_critical_dim] + \
- right_shape[right_critical_dim + 1:]
- elif len(right_shape) > 0:
- #dot does not reduce for scalars
- out_shape = out_shape + left_shape[:-1]
- if my_critical_dim_size != right_critical_dim_size:
- raise OperationError(space.w_ValueError, space.wrap(
- "objects are not aligned"))
- return out_shape, right_critical_dim
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -12,7 +12,6 @@
from pypy.module.micronumpy.interp_flatiter import W_FlatIterator
from pypy.module.micronumpy.appbridge import get_appbridge_cache
from pypy.module.micronumpy import loop
-from pypy.module.micronumpy.dot import match_dot_shapes
from pypy.module.micronumpy.interp_arrayops import repeat, choose, put
from pypy.module.micronumpy.arrayimpl import scalar
from rpython.tool.sourcetools import func_with_new_name
@@ -31,6 +30,28 @@
shape += dtype.shape
return shape[:]
+def _match_dot_shapes(space, left, right):
+ left_shape = left.get_shape()
+ right_shape = right.get_shape()
+ my_critical_dim_size = left_shape[-1]
+ right_critical_dim_size = right_shape[0]
+ right_critical_dim = 0
+ out_shape = []
+ if len(right_shape) > 1:
+ right_critical_dim = len(right_shape) - 2
+ right_critical_dim_size = right_shape[right_critical_dim]
+ assert right_critical_dim >= 0
+ out_shape = out_shape + left_shape[:-1] + \
+ right_shape[0:right_critical_dim] + \
+ right_shape[right_critical_dim + 1:]
+ elif len(right_shape) > 0:
+ #dot does not reduce for scalars
+ out_shape = out_shape + left_shape[:-1]
+ if my_critical_dim_size != right_critical_dim_size:
+ raise OperationError(space.w_ValueError, space.wrap(
+ "objects are not aligned"))
+ return out_shape, right_critical_dim
+
class __extend__(W_NDimArray):
@jit.unroll_safe
def descr_get_shape(self, space):
@@ -820,7 +841,7 @@
# numpy compatability
return W_NDimArray.new_scalar(space, dtype, space.wrap(0))
# Do the dims match?
- out_shape, other_critical_dim = match_dot_shapes(space, self, other)
+ out_shape, other_critical_dim = _match_dot_shapes(space, self, other)
w_res = W_NDimArray.from_shape(space, out_shape, dtype,
w_instance=self)
# This is the place to add fpypy and blas
return loop.multidim_dot(space, self, other, w_res, dtype,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit