diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-08-24 09:01:21 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-08-24 09:01:21 +0000 |
commit | 7d8826633219e26bf1f8e2ba07f014c52a1ceb83 (patch) | |
tree | aa7b1bc5575cff5528db3624da5784fbbd1668b8 | |
parent | 3dcec2dd2de5f41ca913aff8e0c6d9dd56caa952 (diff) | |
download | numpy-7d8826633219e26bf1f8e2ba07f014c52a1ceb83.tar.gz |
Fix the test and fix the arrtype_new code for scalars a little bit.
-rw-r--r-- | numpy/core/src/scalartypes.inc.src | 16 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 2 |
2 files changed, 8 insertions, 10 deletions
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src index 764b7ba46..3855a6eb3 100644 --- a/numpy/core/src/scalartypes.inc.src +++ b/numpy/core/src/scalartypes.inc.src @@ -1923,10 +1923,8 @@ static PyObject * #elif @default@ == 1 robj = PyArray_Scalar(NULL, typecode, NULL); #elif @default@ == 2 - obj = Py_None; - robj = type->tp_alloc(type, 0); Py_INCREF(Py_None); - ((PyObjectScalarObject *)robj)->obval = obj; + robj = Py_None; #endif Py_DECREF(typecode); goto finish; @@ -1942,14 +1940,15 @@ static PyObject * /* 0-d array */ robj = PyArray_ToScalar(PyArray_DATA(arr), (NPY_AO *)arr); Py_DECREF(arr); + +finish: + #if @default@ == 2 /* In OBJECT case, robj is no longer a PyArrayScalar at this point but the remaining code assumes it is */ return robj; -#endif - -finish: +#else /* Normal return */ if ((robj == NULL) || (robj->ob_type == type)) { return robj; @@ -1983,12 +1982,11 @@ finish: itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE); } memcpy(dest, src, itemsize); -#elif @default@ == 2 /* Object arrays */ - memcpy(dest, src, sizeof(void *)); - Py_INCREF(*((PyObject **)dest)); + /* @default@ == 2 won't get here */ #endif Py_DECREF(robj); return obj; +#endif } /**end repeat**/ diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index ff9c7e2e6..c92ad4779 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1196,7 +1196,7 @@ class TestRegression(TestCase): assert type(b2) is float assert type(c) is np.ndarray assert c.dtype == object - assert d.type == object + assert d.dtype == object if __name__ == "__main__": run_module_suite() |