Author: Ronan Lamy <[email protected]>
Branch: can_cast
Changeset: r76931:48070170c83b
Date: 2015-04-25 04:00 +0100
http://bitbucket.org/pypy/pypy/changeset/48070170c83b/

Log:    implement casting=no and casting=equiv

diff --git a/pypy/module/micronumpy/arrayops.py 
b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -304,7 +304,15 @@
 def can_cast(space, w_from, w_totype, casting='safe'):
     target = as_dtype(space, w_totype)
     origin = as_dtype(space, w_from)  # XXX
-    return space.wrap(origin.can_cast_to(target))
+    return space.wrap(can_cast_type(space, origin, target, casting))
+
+def can_cast_type(space, origin, target, casting):
+    if casting == 'no':
+        return origin.eq(space, target)
+    elif casting == 'equiv':
+        return origin.num == target.num and origin.elsize == target.elsize
+    else:
+        return origin.can_cast_to(target)
 
 
 def as_dtype(space, w_arg):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to