Author: Ronan Lamy <[email protected]>
Branch: can_cast
Changeset: r76910:9e8922d9dce5
Date: 2015-04-23 20:32 +0100
http://bitbucket.org/pypy/pypy/changeset/9e8922d9dce5/
Log: create W_Dtype.can_cast_to()
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
@@ -302,7 +302,10 @@
@unwrap_spec(casting=str)
def can_cast(space, w_from, w_totype, casting='safe'):
- return space.w_True
+ target = as_dtype(space, w_totype)
+ origin = as_dtype(space, w_from) # XXX
+ return space.wrap(origin.can_cast_to(target))
+
def as_dtype(space, w_arg):
# roughly equivalent to CNumPy's PyArray_DescrConverter2
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -87,6 +87,9 @@
def box_complex(self, real, imag):
return self.itemtype.box_complex(real, imag)
+ def can_cast_to(self, other):
+ return True
+
def coerce(self, space, w_item):
return self.itemtype.coerce(space, self, w_item)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit