Author: Brian Kearns <[email protected]>
Branch: numpy-refactor
Changeset: r69508:026fac042564
Date: 2014-02-27 02:24 -0500
http://bitbucket.org/pypy/pypy/changeset/026fac042564/
Log: allow creation of flagsobj from applevel
diff --git a/pypy/module/micronumpy/flagsobj.py
b/pypy/module/micronumpy/flagsobj.py
--- a/pypy/module/micronumpy/flagsobj.py
+++ b/pypy/module/micronumpy/flagsobj.py
@@ -6,9 +6,13 @@
class W_FlagsObject(W_Root):
def __init__(self, arr):
- self.arr = arr
self.flags = 0
+ def descr__new__(space, w_subtype):
+ self = space.allocate_instance(W_FlagsObject, w_subtype)
+ W_FlagsObject.__init__(self, None)
+ return self
+
def descr_get_contiguous(self, space):
return space.w_True
@@ -60,6 +64,8 @@
W_FlagsObject.typedef = TypeDef("flagsobj",
__module__ = "numpy",
+ __new__ = interp2app(W_FlagsObject.descr__new__.im_func),
+
__getitem__ = interp2app(W_FlagsObject.descr_getitem),
__setitem__ = interp2app(W_FlagsObject.descr_setitem),
__eq__ = interp2app(W_FlagsObject.descr_eq),
diff --git a/pypy/module/micronumpy/test/test_flagsobj.py
b/pypy/module/micronumpy/test/test_flagsobj.py
--- a/pypy/module/micronumpy/test/test_flagsobj.py
+++ b/pypy/module/micronumpy/test/test_flagsobj.py
@@ -2,6 +2,14 @@
class AppTestFlagsObj(BaseNumpyAppTest):
+ def test_init(self):
+ import numpy as np
+ a = np.array([1,2,3])
+ assert a.flags['C'] is True
+ b = type(a.flags)()
+ assert b is not a.flags
+ assert b['C'] is True
+
def test_repr(self):
import numpy as np
a = np.array([1,2,3])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit