[pypy-commit] pypy default: support ndarray.flags.fnc/forc
bdkearns
noreply at buildbot.pypy.org
Thu Dec 12 01:25:13 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r68410:750ec15cf8e6
Date: 2013-12-11 19:23 -0500
http://bitbucket.org/pypy/pypy/changeset/750ec15cf8e6/
Log: support ndarray.flags.fnc/forc
diff --git a/pypy/module/micronumpy/interp_flagsobj.py b/pypy/module/micronumpy/interp_flagsobj.py
--- a/pypy/module/micronumpy/interp_flagsobj.py
+++ b/pypy/module/micronumpy/interp_flagsobj.py
@@ -18,6 +18,16 @@
def descr_get_writeable(self, space):
return space.w_True
+ def descr_get_fnc(self, space):
+ return space.wrap(
+ space.is_true(self.descr_get_fortran(space)) and not
+ space.is_true(self.descr_get_contiguous(space)))
+
+ def descr_get_forc(self, space):
+ return space.wrap(
+ space.is_true(self.descr_get_fortran(space)) or
+ space.is_true(self.descr_get_contiguous(space)))
+
def descr_getitem(self, space, w_item):
key = space.str_w(w_item)
if key == "C" or key == "CONTIGUOUS" or key == "C_CONTIGUOUS":
@@ -26,6 +36,10 @@
return self.descr_get_fortran(space)
if key == "W" or key == "WRITEABLE":
return self.descr_get_writeable(space)
+ if key == "FNC":
+ return self.descr_get_fnc(space)
+ if key == "FORC":
+ return self.descr_get_forc(space)
raise OperationError(space.w_KeyError, space.wrap(
"Unknown flag"))
@@ -56,4 +70,6 @@
f_contiguous = GetSetProperty(W_FlagsObject.descr_get_fortran),
fortran = GetSetProperty(W_FlagsObject.descr_get_fortran),
writeable = GetSetProperty(W_FlagsObject.descr_get_writeable),
+ fnc = GetSetProperty(W_FlagsObject.descr_get_fnc),
+ forc = GetSetProperty(W_FlagsObject.descr_get_forc),
)
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
@@ -12,6 +12,10 @@
a = np.array([1,2,3])
assert a.flags.c_contiguous == True
assert a.flags['W'] == True
+ assert a.flags.fnc == False
+ assert a.flags.forc == True
+ assert a.flags['FNC'] == False
+ assert a.flags['FORC'] == True
raises(KeyError, "a.flags['blah']")
raises(KeyError, "a.flags['C_CONTIGUOUS'] = False")
raises((TypeError, AttributeError), "a.flags.c_contiguous = False")
More information about the pypy-commit
mailing list