Skip to content

Commit 376d483

Browse files
committed
Trial fix to ticket numpy#698
1 parent 1f58f4d commit 376d483

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎numpy/core/memmap.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def __new__(subtype, filename, dtype=uint8, mode='r+', offset=0,
219219
self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm,
220220
offset=offset, order=order)
221221
self._mmap = mm
222+
# Should get rid of these... Are they used?
222223
self._offset = offset
223224
self._mode = mode
224225
self._size = size

‎numpy/core/src/scalarmathmodule.c.src‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,13 @@ _@name@_convert_to_ctype(PyObject *a, @name@ *arg1)
524524
return -2;
525525
}
526526

527+
/**end repeat**/
528+
529+
530+
/**begin repeat
531+
#name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,cfloat,cdouble#
532+
**/
533+
527534
static int
528535
_@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1,
529536
PyObject *b, @name@ *arg2)
@@ -538,6 +545,27 @@ _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1,
538545

539546
/**end repeat**/
540547

548+
/**begin repeat
549+
#name=longdouble, clongdouble#
550+
**/
551+
552+
static int
553+
_@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1,
554+
PyObject *b, @name@ *arg2)
555+
{
556+
int ret;
557+
ret = _@name@_convert_to_ctype(a, arg1);
558+
if (ret < 0) return ret;
559+
ret = _@name@_convert_to_ctype(b, arg2);
560+
if (ret == -2) ret = -3;
561+
if (ret < 0) return ret;
562+
return 0;
563+
}
564+
565+
/**end repeat**/
566+
567+
568+
541569
/**begin repeat
542570
#name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong)*13, (float, double, longdouble, cfloat, cdouble, clongdouble)*6, (float, double, longdouble)*2#
543571
#Name=(Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong)*13, (Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*6, (Float, Double, LongDouble)*2#
@@ -569,10 +597,14 @@ static PyObject *
569597
break;
570598
case -1: /* one of them can't be cast safely
571599
must be mixed-types*/
572-
return PyArray_Type.tp_as_number->nb_@oper@(a,b);
600+
return PyArray_Type.tp_as_number->nb_@oper@(a,b);
573601
case -2: /* use default handling */
574602
if (PyErr_Occurred()) return NULL;
575603
return PyGenericArrType_Type.tp_as_number->nb_@oper@(a,b);
604+
case -3: /* special case for longdouble and clongdouble
605+
because they have a recursive getitem in their dtype */
606+
Py_INCREF(Py_NotImplemented);
607+
return Py_NotImplemented;
576608
}
577609

578610
#if @fperr@
@@ -658,6 +690,10 @@ static PyObject *
658690
case -2: /* use default handling */
659691
if (PyErr_Occurred()) return NULL;
660692
return PyGenericArrType_Type.tp_as_number->nb_power(a,b,NULL);
693+
case -3: /* special case for longdouble and clongdouble
694+
because they have a recursive getitem in their dtype */
695+
Py_INCREF(Py_NotImplemented);
696+
return Py_NotImplemented;
661697
}
662698

663699
PyUFunc_clearfperr();
@@ -887,6 +923,10 @@ static PyObject*
887923
case -2: /* use ufunc */
888924
if (PyErr_Occurred()) return NULL;
889925
return PyGenericArrType_Type.tp_richcompare(self, other, cmp_op);
926+
case -3: /* special case for longdouble and clongdouble
927+
because they have a recursive getitem in their dtype */
928+
Py_INCREF(Py_NotImplemented);
929+
return Py_NotImplemented;
890930
}
891931

892932
/* here we do the actual calculation with arg1 and arg2 */

0 commit comments

Comments
 (0)