[Numpy-svn] r8495 - in branches/1.5.x/numpy: core core/code_generators core/include/numpy core/src/multiarray core/src/umath core/tests f2py lib/tests random/mtrand
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Jul 17 14:31:17 EDT 2010
Author: ptvirtan
Date: 2010-07-17 13:31:17 -0500 (Sat, 17 Jul 2010)
New Revision: 8495
Modified:
branches/1.5.x/numpy/core/SConscript
branches/1.5.x/numpy/core/_internal.py
branches/1.5.x/numpy/core/arrayprint.py
branches/1.5.x/numpy/core/code_generators/cversions.txt
branches/1.5.x/numpy/core/code_generators/genapi.py
branches/1.5.x/numpy/core/code_generators/generate_umath.py
branches/1.5.x/numpy/core/code_generators/numpy_api.py
branches/1.5.x/numpy/core/include/numpy/arrayscalars.h
branches/1.5.x/numpy/core/include/numpy/ndarraytypes.h
branches/1.5.x/numpy/core/numerictypes.py
branches/1.5.x/numpy/core/setup.py
branches/1.5.x/numpy/core/setup_common.py
branches/1.5.x/numpy/core/src/multiarray/arrayobject.c
branches/1.5.x/numpy/core/src/multiarray/arraytypes.c.src
branches/1.5.x/numpy/core/src/multiarray/convert_datatype.c
branches/1.5.x/numpy/core/src/multiarray/descriptor.c
branches/1.5.x/numpy/core/src/multiarray/hashdescr.c
branches/1.5.x/numpy/core/src/multiarray/multiarraymodule.c
branches/1.5.x/numpy/core/src/multiarray/multiarraymodule_onefile.c
branches/1.5.x/numpy/core/src/multiarray/scalarapi.c
branches/1.5.x/numpy/core/src/multiarray/scalartypes.c.src
branches/1.5.x/numpy/core/src/umath/loops.c.src
branches/1.5.x/numpy/core/src/umath/loops.h
branches/1.5.x/numpy/core/src/umath/loops.h.src
branches/1.5.x/numpy/core/src/umath/ufunc_object.c
branches/1.5.x/numpy/core/tests/test_regression.py
branches/1.5.x/numpy/f2py/__version__.py
branches/1.5.x/numpy/lib/tests/test_type_check.py
branches/1.5.x/numpy/random/mtrand/numpy.pxi
Log:
ENH: restore ABI for 1.5.x branch
- remove the datetime functionality.
- roll back hasobject -> flags change
- roll back several other rearrangements in ndarraytypes
- restore ABI compatibility with numpy 1.4.
The patch is based on the following changesets/tickets:
r8098, r8113, r8107, r8108, r8115, #1502
Thanks to Christoph Gohlke for contributing this patch.
Modified: branches/1.5.x/numpy/core/SConscript
===================================================================
--- branches/1.5.x/numpy/core/SConscript 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/SConscript 2010-07-17 18:31:17 UTC (rev 8495)
@@ -426,7 +426,6 @@
multiarray_src = [pjoin('src', 'multiarray', 'multiarraymodule.c'),
pjoin('src', 'multiarray', 'hashdescr.c'),
pjoin('src', 'multiarray', 'arrayobject.c'),
- pjoin('src', 'multiarray', 'datetime.c'),
pjoin('src', 'multiarray', 'numpyos.c'),
pjoin('src', 'multiarray', 'flagsobject.c'),
pjoin('src', 'multiarray', 'descriptor.c'),
Modified: branches/1.5.x/numpy/core/_internal.py
===================================================================
--- branches/1.5.x/numpy/core/_internal.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/_internal.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -165,36 +165,7 @@
return newlist
-format_datetime = re.compile(asbytes(r"""
- (?P<typecode>M8|m8|datetime64|timedelta64)
- ([[]
- ((?P<num>\d+)?
- (?P<baseunit>Y|M|W|B|D|h|m|s|ms|us|ns|ps|fs|as)
- (/(?P<den>\d+))?
- []])
- (//(?P<events>\d+))?)?"""), re.X)
-# Return (baseunit, num, den, events), datetime
-# from date-time string
-def _datetimestring(astr):
- res = format_datetime.match(astr)
- if res is None:
- raise ValueError("Incorrect date-time string.")
- typecode = res.group('typecode')
- datetime = (typecode == asbytes('M8') or typecode == asbytes('datetime64'))
- defaults = [asbytes('us'), 1, 1, 1]
- names = ['baseunit', 'num', 'den', 'events']
- func = [bytes, int, int, int]
- dt_tuple = []
- for i, name in enumerate(names):
- value = res.group(name)
- if value:
- dt_tuple.append(func[i](value))
- else:
- dt_tuple.append(defaults[i])
-
- return tuple(dt_tuple), datetime
-
format_re = re.compile(asbytes(r'(?P<order1>[<>|=]?)(?P<repeats> *[(]?[ ,0-9]*[)]? *)(?P<order2>[<>|=]?)(?P<dtype>[A-Za-z0-9.]*)'))
# astr is a string (perhaps comma separated)
Modified: branches/1.5.x/numpy/core/arrayprint.py
===================================================================
--- branches/1.5.x/numpy/core/arrayprint.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/arrayprint.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -199,13 +199,10 @@
# make sure True and False line up.
format_function = _boolFormatter
elif issubclass(dtypeobj, _nt.integer):
- if issubclass(dtypeobj, _nt.timeinteger):
- format_function = str
- else:
- max_str_len = max(len(str(maximum.reduce(data))),
- len(str(minimum.reduce(data))))
- format = '%' + str(max_str_len) + 'd'
- format_function = lambda x: _formatInteger(x, format)
+ max_str_len = max(len(str(maximum.reduce(data))),
+ len(str(minimum.reduce(data))))
+ format = '%' + str(max_str_len) + 'd'
+ format_function = lambda x: _formatInteger(x, format)
elif issubclass(dtypeobj, _nt.floating):
if issubclass(dtypeobj, _nt.longfloat):
format_function = _longfloatFormatter(precision)
Modified: branches/1.5.x/numpy/core/code_generators/cversions.txt
===================================================================
--- branches/1.5.x/numpy/core/code_generators/cversions.txt 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/code_generators/cversions.txt 2010-07-17 18:31:17 UTC (rev 8495)
@@ -5,4 +5,4 @@
# Starting from here, the hash is defined from numpy_api.full_api dict
# version 4 added neighborhood iterators and PyArray_Correlate2
0x00000004 = 3d8940bf7b0d2a4e25be4338c14c3c85
-0x00000005 = 77e2e846db87f25d7cf99f9d812076f0
+
Modified: branches/1.5.x/numpy/core/code_generators/genapi.py
===================================================================
--- branches/1.5.x/numpy/core/code_generators/genapi.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/code_generators/genapi.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -43,7 +43,6 @@
join('multiarray', 'refcount.c'),
join('multiarray', 'conversion_utils.c'),
join('multiarray', 'buffer.c'),
- join('multiarray', 'datetime.c'),
join('umath', 'ufunc_object.c'),
join('umath', 'loops.c.src'),
]
Modified: branches/1.5.x/numpy/core/code_generators/generate_umath.py
===================================================================
--- branches/1.5.x/numpy/core/code_generators/generate_umath.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/code_generators/generate_umath.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -172,19 +172,16 @@
'F': 'cfloat',
'D': 'cdouble',
'G': 'clongdouble',
- 'M': 'datetime',
- 'm': 'timedelta',
'O': 'OBJECT',
# '.' is like 'O', but calls a method of the object instead
# of a function
'P': 'OBJECT',
}
-all = '?bBhHiIlLqQfdgFDGOMm'
+all = '?bBhHiIlLqQfdgFDGO'
O = 'O'
P = 'P'
ints = 'bBhHiIlLqQ'
-times = 'Mm'
intsO = ints + O
bints = '?' + ints
bintsO = bints + O
@@ -197,13 +194,13 @@
inexact = flts + cmplx
noint = inexact+O
nointP = inexact+P
-allP = bints+times+flts+cmplxP
+allP = bints+flts+cmplxP
nobool = all[1:]
-noobj = all[:-3]+all[-2:]
-nobool_or_obj = all[1:-3]+all[-2:]
+noobj = all[:-2]
+nobool_or_obj = all[1:-2]
intflt = ints+flts
intfltcmplx = ints+flts+cmplx
-nocmplx = bints+times+flts
+nocmplx = bints+flts
nocmplxO = nocmplx+O
nocmplxP = nocmplx+P
notimes_or_obj = bints + inexact
@@ -222,20 +219,12 @@
Ufunc(2, 1, Zero,
docstrings.get('numpy.core.umath.add'),
TD(notimes_or_obj),
- [TypeDescription('M', UsesArraysAsData, 'Mm', 'M'),
- TypeDescription('m', UsesArraysAsData, 'mm', 'm'),
- TypeDescription('M', UsesArraysAsData, 'mM', 'M'),
- ],
TD(O, f='PyNumber_Add'),
),
'subtract' :
Ufunc(2, 1, Zero,
docstrings.get('numpy.core.umath.subtract'),
TD(notimes_or_obj),
- [TypeDescription('M', UsesArraysAsData, 'Mm', 'M'),
- TypeDescription('m', UsesArraysAsData, 'mm', 'm'),
- TypeDescription('M', UsesArraysAsData, 'MM', 'm'),
- ],
TD(O, f='PyNumber_Subtract'),
),
'multiply' :
@@ -305,7 +294,7 @@
'absolute' :
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.absolute'),
- TD(bints+flts+times),
+ TD(bints+flts),
TD(cmplx, out=('f', 'd', 'g')),
TD(O, f='PyNumber_Absolute'),
),
@@ -317,7 +306,7 @@
'negative' :
Ufunc(1, 1, None,
docstrings.get('numpy.core.umath.negative'),
- TD(bints+flts+times),
+ TD(bints+flts),
TD(cmplx, f='neg'),
TD(O, f='PyNumber_Negative'),
),
Modified: branches/1.5.x/numpy/core/code_generators/numpy_api.py
===================================================================
--- branches/1.5.x/numpy/core/code_generators/numpy_api.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/code_generators/numpy_api.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -13,7 +13,7 @@
"""
multiarray_global_vars = {
- 'NPY_NUMUSERTYPES': 6,
+ 'NPY_NUMUSERTYPES': 7,
}
multiarray_global_vars_types = {
@@ -21,236 +21,239 @@
}
multiarray_scalar_bool_values = {
- '_PyArrayScalar_BoolValues': 8
+ '_PyArrayScalar_BoolValues': 9
}
multiarray_types_api = {
- 'PyArray_Type': 1,
- 'PyArrayDescr_Type': 2,
- 'PyArrayFlags_Type': 3,
- 'PyArrayIter_Type': 4,
- 'PyArrayMultiIter_Type': 5,
- 'PyBoolArrType_Type': 7,
- 'PyGenericArrType_Type': 9,
- 'PyNumberArrType_Type': 10,
- 'PyIntegerArrType_Type': 11,
- 'PySignedIntegerArrType_Type': 12,
- 'PyUnsignedIntegerArrType_Type': 13,
- 'PyInexactArrType_Type': 14,
- 'PyFloatingArrType_Type': 15,
- 'PyComplexFloatingArrType_Type': 16,
- 'PyFlexibleArrType_Type': 17,
- 'PyCharacterArrType_Type': 18,
- 'PyByteArrType_Type': 19,
- 'PyShortArrType_Type': 20,
- 'PyIntArrType_Type': 21,
- 'PyLongArrType_Type': 22,
- 'PyLongLongArrType_Type': 23,
- 'PyUByteArrType_Type': 24,
- 'PyUShortArrType_Type': 25,
- 'PyUIntArrType_Type': 26,
- 'PyULongArrType_Type': 27,
- 'PyULongLongArrType_Type': 28,
- 'PyFloatArrType_Type': 29,
- 'PyDoubleArrType_Type': 30,
- 'PyLongDoubleArrType_Type': 31,
- 'PyCFloatArrType_Type': 32,
- 'PyCDoubleArrType_Type': 33,
- 'PyCLongDoubleArrType_Type': 34,
- 'PyObjectArrType_Type': 35,
- 'PyStringArrType_Type': 36,
- 'PyUnicodeArrType_Type': 37,
- 'PyVoidArrType_Type': 38,
- 'PyTimeIntegerArrType_Type': 39,
- 'PyDatetimeArrType_Type': 40,
- 'PyTimedeltaArrType_Type': 41,
+ 'PyBigArray_Type': 1,
+ 'PyArray_Type': 2,
+ 'PyArrayDescr_Type': 3,
+ 'PyArrayFlags_Type': 4,
+ 'PyArrayIter_Type': 5,
+ 'PyArrayMultiIter_Type': 6,
+ 'PyBoolArrType_Type': 8,
+ 'PyGenericArrType_Type': 10,
+ 'PyNumberArrType_Type': 11,
+ 'PyIntegerArrType_Type': 12,
+ 'PySignedIntegerArrType_Type': 13,
+ 'PyUnsignedIntegerArrType_Type': 14,
+ 'PyInexactArrType_Type': 15,
+ 'PyFloatingArrType_Type': 16,
+ 'PyComplexFloatingArrType_Type': 17,
+ 'PyFlexibleArrType_Type': 18,
+ 'PyCharacterArrType_Type': 19,
+ 'PyByteArrType_Type': 20,
+ 'PyShortArrType_Type': 21,
+ 'PyIntArrType_Type': 22,
+ 'PyLongArrType_Type': 23,
+ 'PyLongLongArrType_Type': 24,
+ 'PyUByteArrType_Type': 25,
+ 'PyUShortArrType_Type': 26,
+ 'PyUIntArrType_Type': 27,
+ 'PyULongArrType_Type': 28,
+ 'PyULongLongArrType_Type': 29,
+ 'PyFloatArrType_Type': 30,
+ 'PyDoubleArrType_Type': 31,
+ 'PyLongDoubleArrType_Type': 32,
+ 'PyCFloatArrType_Type': 33,
+ 'PyCDoubleArrType_Type': 34,
+ 'PyCLongDoubleArrType_Type': 35,
+ 'PyObjectArrType_Type': 36,
+ 'PyStringArrType_Type': 37,
+ 'PyUnicodeArrType_Type': 38,
+ 'PyVoidArrType_Type': 39,
+# Those were added much later, and there is no space anymore between Void and
+# first functions from multiarray API
+# 'PyTimeIntegerArrType_Type': 215,
+# 'PyDatetimeArrType_Type': 216,
+# 'PyTimedeltaArrType_Type': 217,
}
-#define NPY_NUMUSERTYPES (*(int *)PyArray_API[6])
-#define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[7])
-#define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[8])
+#define NPY_NUMUSERTYPES (*(int *)PyArray_API[7])
+#define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[8])
+#define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[9])
multiarray_funcs_api = {
'PyArray_GetNDArrayCVersion': 0,
- 'PyArray_SetNumericOps': 42,
- 'PyArray_GetNumericOps': 43,
- 'PyArray_INCREF': 44,
- 'PyArray_XDECREF': 45,
- 'PyArray_SetStringFunction': 46,
- 'PyArray_DescrFromType': 47,
- 'PyArray_TypeObjectFromType': 48,
- 'PyArray_Zero': 49,
- 'PyArray_One': 50,
- 'PyArray_CastToType': 51,
- 'PyArray_CastTo': 52,
- 'PyArray_CastAnyTo': 53,
- 'PyArray_CanCastSafely': 54,
- 'PyArray_CanCastTo': 55,
- 'PyArray_ObjectType': 56,
- 'PyArray_DescrFromObject': 57,
- 'PyArray_ConvertToCommonType': 58,
- 'PyArray_DescrFromScalar': 59,
- 'PyArray_DescrFromTypeObject': 60,
- 'PyArray_Size': 61,
- 'PyArray_Scalar': 62,
- 'PyArray_FromScalar': 63,
- 'PyArray_ScalarAsCtype': 64,
- 'PyArray_CastScalarToCtype': 65,
- 'PyArray_CastScalarDirect': 66,
- 'PyArray_ScalarFromObject': 67,
- 'PyArray_GetCastFunc': 68,
- 'PyArray_FromDims': 69,
- 'PyArray_FromDimsAndDataAndDescr': 70,
- 'PyArray_FromAny': 71,
- 'PyArray_EnsureArray': 72,
- 'PyArray_EnsureAnyArray': 73,
- 'PyArray_FromFile': 74,
- 'PyArray_FromString': 75,
- 'PyArray_FromBuffer': 76,
- 'PyArray_FromIter': 77,
- 'PyArray_Return': 78,
- 'PyArray_GetField': 79,
- 'PyArray_SetField': 80,
- 'PyArray_Byteswap': 81,
- 'PyArray_Resize': 82,
- 'PyArray_MoveInto': 83,
- 'PyArray_CopyInto': 84,
- 'PyArray_CopyAnyInto': 85,
- 'PyArray_CopyObject': 86,
- 'PyArray_NewCopy': 87,
- 'PyArray_ToList': 88,
- 'PyArray_ToString': 89,
- 'PyArray_ToFile': 90,
- 'PyArray_Dump': 91,
- 'PyArray_Dumps': 92,
- 'PyArray_ValidType': 93,
- 'PyArray_UpdateFlags': 94,
- 'PyArray_New': 95,
- 'PyArray_NewFromDescr': 96,
- 'PyArray_DescrNew': 97,
- 'PyArray_DescrNewFromType': 98,
- 'PyArray_GetPriority': 99,
- 'PyArray_IterNew': 100,
- 'PyArray_MultiIterNew': 101,
- 'PyArray_PyIntAsInt': 102,
- 'PyArray_PyIntAsIntp': 103,
- 'PyArray_Broadcast': 104,
- 'PyArray_FillObjectArray': 105,
- 'PyArray_FillWithScalar': 106,
- 'PyArray_CheckStrides': 107,
- 'PyArray_DescrNewByteorder': 108,
- 'PyArray_IterAllButAxis': 109,
- 'PyArray_CheckFromAny': 110,
- 'PyArray_FromArray': 111,
- 'PyArray_FromInterface': 112,
- 'PyArray_FromStructInterface': 113,
- 'PyArray_FromArrayAttr': 114,
- 'PyArray_ScalarKind': 115,
- 'PyArray_CanCoerceScalar': 116,
- 'PyArray_NewFlagsObject': 117,
- 'PyArray_CanCastScalar': 118,
- 'PyArray_CompareUCS4': 119,
- 'PyArray_RemoveSmallest': 120,
- 'PyArray_ElementStrides': 121,
- 'PyArray_Item_INCREF': 122,
- 'PyArray_Item_XDECREF': 123,
- 'PyArray_FieldNames': 124,
- 'PyArray_Transpose': 125,
- 'PyArray_TakeFrom': 126,
- 'PyArray_PutTo': 127,
- 'PyArray_PutMask': 128,
- 'PyArray_Repeat': 129,
- 'PyArray_Choose': 130,
- 'PyArray_Sort': 131,
- 'PyArray_ArgSort': 132,
- 'PyArray_SearchSorted': 133,
- 'PyArray_ArgMax': 134,
- 'PyArray_ArgMin': 135,
- 'PyArray_Reshape': 136,
- 'PyArray_Newshape': 137,
- 'PyArray_Squeeze': 138,
- 'PyArray_View': 139,
- 'PyArray_SwapAxes': 140,
- 'PyArray_Max': 141,
- 'PyArray_Min': 142,
- 'PyArray_Ptp': 143,
- 'PyArray_Mean': 144,
- 'PyArray_Trace': 145,
- 'PyArray_Diagonal': 146,
- 'PyArray_Clip': 147,
- 'PyArray_Conjugate': 148,
- 'PyArray_Nonzero': 149,
- 'PyArray_Std': 150,
- 'PyArray_Sum': 151,
- 'PyArray_CumSum': 152,
- 'PyArray_Prod': 153,
- 'PyArray_CumProd': 154,
- 'PyArray_All': 155,
- 'PyArray_Any': 156,
- 'PyArray_Compress': 157,
- 'PyArray_Flatten': 158,
- 'PyArray_Ravel': 159,
- 'PyArray_MultiplyList': 160,
- 'PyArray_MultiplyIntList': 161,
- 'PyArray_GetPtr': 162,
- 'PyArray_CompareLists': 163,
- 'PyArray_AsCArray': 164,
- 'PyArray_As1D': 165,
- 'PyArray_As2D': 166,
- 'PyArray_Free': 167,
- 'PyArray_Converter': 168,
- 'PyArray_IntpFromSequence': 169,
- 'PyArray_Concatenate': 170,
- 'PyArray_InnerProduct': 171,
- 'PyArray_MatrixProduct': 172,
- 'PyArray_CopyAndTranspose': 173,
- 'PyArray_Correlate': 174,
- 'PyArray_TypestrConvert': 175,
- 'PyArray_DescrConverter': 176,
- 'PyArray_DescrConverter2': 177,
- 'PyArray_IntpConverter': 178,
- 'PyArray_BufferConverter': 179,
- 'PyArray_AxisConverter': 180,
- 'PyArray_BoolConverter': 181,
- 'PyArray_ByteorderConverter': 182,
- 'PyArray_OrderConverter': 183,
- 'PyArray_EquivTypes': 184,
- 'PyArray_Zeros': 185,
- 'PyArray_Empty': 186,
- 'PyArray_Where': 187,
- 'PyArray_Arange': 188,
- 'PyArray_ArangeObj': 189,
- 'PyArray_SortkindConverter': 190,
- 'PyArray_LexSort': 191,
- 'PyArray_Round': 192,
- 'PyArray_EquivTypenums': 193,
- 'PyArray_RegisterDataType': 194,
- 'PyArray_RegisterCastFunc': 195,
- 'PyArray_RegisterCanCast': 196,
- 'PyArray_InitArrFuncs': 197,
- 'PyArray_IntTupleFromIntp': 198,
- 'PyArray_TypeNumFromName': 199,
- 'PyArray_ClipmodeConverter': 200,
- 'PyArray_OutputConverter': 201,
- 'PyArray_BroadcastToShape': 202,
- '_PyArray_SigintHandler': 203,
- '_PyArray_GetSigintBuf': 204,
- 'PyArray_DescrAlignConverter': 205,
- 'PyArray_DescrAlignConverter2': 206,
- 'PyArray_SearchsideConverter': 207,
- 'PyArray_CheckAxis': 208,
- 'PyArray_OverflowMultiplyList': 209,
- 'PyArray_CompareString': 210,
- 'PyArray_MultiIterFromObjects': 211,
- 'PyArray_GetEndianness': 212,
- 'PyArray_GetNDArrayCFeatureVersion': 213,
- 'PyArray_Correlate2': 214,
- 'PyArray_NeighborhoodIterNew': 215,
- 'PyArray_SetDatetimeParseFunction': 216,
- 'PyArray_DatetimeToDatetimeStruct': 217,
- 'PyArray_TimedeltaToTimedeltaStruct': 218,
- 'PyArray_DatetimeStructToDatetime': 219,
- 'PyArray_TimedeltaStructToTimedelta': 220,
+ 'PyArray_SetNumericOps': 40,
+ 'PyArray_GetNumericOps': 41,
+ 'PyArray_INCREF': 42,
+ 'PyArray_XDECREF': 43,
+ 'PyArray_SetStringFunction': 44,
+ 'PyArray_DescrFromType': 45,
+ 'PyArray_TypeObjectFromType': 46,
+ 'PyArray_Zero': 47,
+ 'PyArray_One': 48,
+ 'PyArray_CastToType': 49,
+ 'PyArray_CastTo': 50,
+ 'PyArray_CastAnyTo': 51,
+ 'PyArray_CanCastSafely': 52,
+ 'PyArray_CanCastTo': 53,
+ 'PyArray_ObjectType': 54,
+ 'PyArray_DescrFromObject': 55,
+ 'PyArray_ConvertToCommonType': 56,
+ 'PyArray_DescrFromScalar': 57,
+ 'PyArray_DescrFromTypeObject': 58,
+ 'PyArray_Size': 59,
+ 'PyArray_Scalar': 60,
+ 'PyArray_FromScalar': 61,
+ 'PyArray_ScalarAsCtype': 62,
+ 'PyArray_CastScalarToCtype': 63,
+ 'PyArray_CastScalarDirect': 64,
+ 'PyArray_ScalarFromObject': 65,
+ 'PyArray_GetCastFunc': 66,
+ 'PyArray_FromDims': 67,
+ 'PyArray_FromDimsAndDataAndDescr': 68,
+ 'PyArray_FromAny': 69,
+ 'PyArray_EnsureArray': 70,
+ 'PyArray_EnsureAnyArray': 71,
+ 'PyArray_FromFile': 72,
+ 'PyArray_FromString': 73,
+ 'PyArray_FromBuffer': 74,
+ 'PyArray_FromIter': 75,
+ 'PyArray_Return': 76,
+ 'PyArray_GetField': 77,
+ 'PyArray_SetField': 78,
+ 'PyArray_Byteswap': 79,
+ 'PyArray_Resize': 80,
+ 'PyArray_MoveInto': 81,
+ 'PyArray_CopyInto': 82,
+ 'PyArray_CopyAnyInto': 83,
+ 'PyArray_CopyObject': 84,
+ 'PyArray_NewCopy': 85,
+ 'PyArray_ToList': 86,
+ 'PyArray_ToString': 87,
+ 'PyArray_ToFile': 88,
+ 'PyArray_Dump': 89,
+ 'PyArray_Dumps': 90,
+ 'PyArray_ValidType': 91,
+ 'PyArray_UpdateFlags': 92,
+ 'PyArray_New': 93,
+ 'PyArray_NewFromDescr': 94,
+ 'PyArray_DescrNew': 95,
+ 'PyArray_DescrNewFromType': 96,
+ 'PyArray_GetPriority': 97,
+ 'PyArray_IterNew': 98,
+ 'PyArray_MultiIterNew': 99,
+ 'PyArray_PyIntAsInt': 100,
+ 'PyArray_PyIntAsIntp': 101,
+ 'PyArray_Broadcast': 102,
+ 'PyArray_FillObjectArray': 103,
+ 'PyArray_FillWithScalar': 104,
+ 'PyArray_CheckStrides': 105,
+ 'PyArray_DescrNewByteorder': 106,
+ 'PyArray_IterAllButAxis': 107,
+ 'PyArray_CheckFromAny': 108,
+ 'PyArray_FromArray': 109,
+ 'PyArray_FromInterface': 110,
+ 'PyArray_FromStructInterface': 111,
+ 'PyArray_FromArrayAttr': 112,
+ 'PyArray_ScalarKind': 113,
+ 'PyArray_CanCoerceScalar': 114,
+ 'PyArray_NewFlagsObject': 115,
+ 'PyArray_CanCastScalar': 116,
+ 'PyArray_CompareUCS4': 117,
+ 'PyArray_RemoveSmallest': 118,
+ 'PyArray_ElementStrides': 119,
+ 'PyArray_Item_INCREF': 120,
+ 'PyArray_Item_XDECREF': 121,
+ 'PyArray_FieldNames': 122,
+ 'PyArray_Transpose': 123,
+ 'PyArray_TakeFrom': 124,
+ 'PyArray_PutTo': 125,
+ 'PyArray_PutMask': 126,
+ 'PyArray_Repeat': 127,
+ 'PyArray_Choose': 128,
+ 'PyArray_Sort': 129,
+ 'PyArray_ArgSort': 130,
+ 'PyArray_SearchSorted': 131,
+ 'PyArray_ArgMax': 132,
+ 'PyArray_ArgMin': 133,
+ 'PyArray_Reshape': 134,
+ 'PyArray_Newshape': 135,
+ 'PyArray_Squeeze': 136,
+ 'PyArray_View': 137,
+ 'PyArray_SwapAxes': 138,
+ 'PyArray_Max': 139,
+ 'PyArray_Min': 140,
+ 'PyArray_Ptp': 141,
+ 'PyArray_Mean': 142,
+ 'PyArray_Trace': 143,
+ 'PyArray_Diagonal': 144,
+ 'PyArray_Clip': 145,
+ 'PyArray_Conjugate': 146,
+ 'PyArray_Nonzero': 147,
+ 'PyArray_Std': 148,
+ 'PyArray_Sum': 149,
+ 'PyArray_CumSum': 150,
+ 'PyArray_Prod': 151,
+ 'PyArray_CumProd': 152,
+ 'PyArray_All': 153,
+ 'PyArray_Any': 154,
+ 'PyArray_Compress': 155,
+ 'PyArray_Flatten': 156,
+ 'PyArray_Ravel': 157,
+ 'PyArray_MultiplyList': 158,
+ 'PyArray_MultiplyIntList': 159,
+ 'PyArray_GetPtr': 160,
+ 'PyArray_CompareLists': 161,
+ 'PyArray_AsCArray': 162,
+ 'PyArray_As1D': 163,
+ 'PyArray_As2D': 164,
+ 'PyArray_Free': 165,
+ 'PyArray_Converter': 166,
+ 'PyArray_IntpFromSequence': 167,
+ 'PyArray_Concatenate': 168,
+ 'PyArray_InnerProduct': 169,
+ 'PyArray_MatrixProduct': 170,
+ 'PyArray_CopyAndTranspose': 171,
+ 'PyArray_Correlate': 172,
+ 'PyArray_TypestrConvert': 173,
+ 'PyArray_DescrConverter': 174,
+ 'PyArray_DescrConverter2': 175,
+ 'PyArray_IntpConverter': 176,
+ 'PyArray_BufferConverter': 177,
+ 'PyArray_AxisConverter': 178,
+ 'PyArray_BoolConverter': 179,
+ 'PyArray_ByteorderConverter': 180,
+ 'PyArray_OrderConverter': 181,
+ 'PyArray_EquivTypes': 182,
+ 'PyArray_Zeros': 183,
+ 'PyArray_Empty': 184,
+ 'PyArray_Where': 185,
+ 'PyArray_Arange': 186,
+ 'PyArray_ArangeObj': 187,
+ 'PyArray_SortkindConverter': 188,
+ 'PyArray_LexSort': 189,
+ 'PyArray_Round': 190,
+ 'PyArray_EquivTypenums': 191,
+ 'PyArray_RegisterDataType': 192,
+ 'PyArray_RegisterCastFunc': 193,
+ 'PyArray_RegisterCanCast': 194,
+ 'PyArray_InitArrFuncs': 195,
+ 'PyArray_IntTupleFromIntp': 196,
+ 'PyArray_TypeNumFromName': 197,
+ 'PyArray_ClipmodeConverter': 198,
+ 'PyArray_OutputConverter': 199,
+ 'PyArray_BroadcastToShape': 200,
+ '_PyArray_SigintHandler': 201,
+ '_PyArray_GetSigintBuf': 202,
+ 'PyArray_DescrAlignConverter': 203,
+ 'PyArray_DescrAlignConverter2': 204,
+ 'PyArray_SearchsideConverter': 205,
+ 'PyArray_CheckAxis': 206,
+ 'PyArray_OverflowMultiplyList': 207,
+ 'PyArray_CompareString': 208,
+ 'PyArray_MultiIterFromObjects': 209,
+ 'PyArray_GetEndianness': 210,
+ 'PyArray_GetNDArrayCFeatureVersion': 211,
+ 'PyArray_Correlate2': 212,
+ 'PyArray_NeighborhoodIterNew': 213,
+# 'PyArray_SetDatetimeParseFunction': 214,
+# 'PyArray_DatetimeToDatetimeStruct': 218,
+# 'PyArray_TimedeltaToTimedeltaStruct': 219,
+# 'PyArray_DatetimeStructToDatetime': 220,
+# 'PyArray_TimedeltaStructToTimedelta': 221,
}
ufunc_types_api = {
Modified: branches/1.5.x/numpy/core/include/numpy/arrayscalars.h
===================================================================
--- branches/1.5.x/numpy/core/include/numpy/arrayscalars.h 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/include/numpy/arrayscalars.h 2010-07-17 18:31:17 UTC (rev 8495)
@@ -110,21 +110,9 @@
PyObject * obval;
} PyObjectScalarObject;
-typedef struct {
- PyObject_HEAD
- npy_datetime obval;
- PyArray_DatetimeMetaData obmeta;
-} PyDatetimeScalarObject;
typedef struct {
PyObject_HEAD
- npy_timedelta obval;
- PyArray_DatetimeMetaData obmeta;
-} PyTimedeltaScalarObject;
-
-
-typedef struct {
- PyObject_HEAD
char obval;
} PyScalarObject;
Modified: branches/1.5.x/numpy/core/include/numpy/ndarraytypes.h
===================================================================
--- branches/1.5.x/numpy/core/include/numpy/ndarraytypes.h 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/include/numpy/ndarraytypes.h 2010-07-17 18:31:17 UTC (rev 8495)
@@ -66,8 +66,7 @@
NPY_LONGLONG, NPY_ULONGLONG,
NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE,
NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE,
- NPY_DATETIME, NPY_TIMEDELTA,
- NPY_OBJECT=19,
+ NPY_OBJECT=17,
NPY_STRING, NPY_UNICODE,
NPY_VOID,
NPY_NTYPES,
@@ -204,6 +203,7 @@
#define NPY_DATETIME_NUMUNITS (NPY_FR_as + 1)
#define NPY_DATETIME_DEFAULTUNIT NPY_FR_us
+
#define NPY_STR_Y "Y"
#define NPY_STR_M "M"
#define NPY_STR_W "W"
@@ -387,6 +387,10 @@
} PyArray_Dims;
typedef struct {
+ /* Functions to cast to all other standard types*/
+ /* Can have some NULL entries */
+ PyArray_VectorUnaryFunc *cast[NPY_NTYPES];
+
/* The next four functions *cannot* be NULL */
/*
@@ -480,24 +484,9 @@
PyArray_FastClipFunc *fastclip;
PyArray_FastPutmaskFunc *fastputmask;
PyArray_FastTakeFunc *fasttake;
-
- /*
- * A little room to grow --- should use generic function
- * interface for most additions
- */
- void *pad1;
- void *pad2;
- void *pad3;
- void *pad4;
-
- /*
- * Functions to cast to all other standard types
- * Can have some NULL entries
- */
- PyArray_VectorUnaryFunc *cast[NPY_NTYPES];
-
} PyArray_ArrFuncs;
+
/* The item must be reference counted when it is inserted or extracted. */
#define NPY_ITEM_REFCOUNT 0x01
/* Same as needing REFCOUNT */
@@ -528,50 +517,41 @@
NPY_NEEDS_INIT | NPY_NEEDS_PYAPI)
#define PyDataType_FLAGCHK(dtype, flag) \
- (((dtype)->flags & (flag)) == (flag))
+ (((dtype)->hasobject & (flag)) == (flag))
#define PyDataType_REFCHK(dtype) \
PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)
+/* Change dtype hasobject to 32-bit in 1.1 and change its name */
typedef struct _PyArray_Descr {
PyObject_HEAD
- PyTypeObject *typeobj; /*
- * the type object representing an
- * instance of this type -- should not
- * be two type_numbers with the same type
- * object.
- */
+ PyTypeObject *typeobj; /* the type object representing an
+ instance of this type -- should not
+ be two type_numbers with the same type
+ object. */
char kind; /* kind for this type */
char type; /* unique-character representing this type */
- char byteorder; /*
- * '>' (big), '<' (little), '|'
- * (not-applicable), or '=' (native).
- */
- char unused;
- int flags; /* flag describing data type */
- int type_num; /* number representing this type */
+ char byteorder; /* '>' (big), '<' (little), '|'
+ (not-applicable), or '=' (native). */
+ char hasobject; /* non-zero if it has object arrays
+ in fields */
+ int type_num; /* number representing this type */
int elsize; /* element size for this type */
int alignment; /* alignment needed for this type */
struct _arr_descr \
- *subarray; /*
- * Non-NULL if this type is
- * is an array (C-contiguous)
- * of some other type
- */
- PyObject *fields; /* The fields dictionary for this type
- * For statically defined descr this
- * is always Py_None
- */
+ *subarray; /* Non-NULL if this type is
+ is an array (C-contiguous)
+ of some other type
+ */
+ PyObject *fields; /* The fields dictionary for this type */
+ /* For statically defined descr this
+ is always Py_None */
- PyObject *names; /*
- * An ordered tuple of field names or NULL
- * if no fields are defined
- */
+ PyObject *names; /* An ordered tuple of field names or NULL
+ if no fields are defined */
- PyArray_ArrFuncs *f; /*
- * a table of functions specific for each
- * basic data descriptor
- */
+ PyArray_ArrFuncs *f; /* a table of functions specific for each
+ basic data descriptor */
PyObject *metadata; /* Metadata about this dtype */
} PyArray_Descr;
@@ -638,39 +618,6 @@
} PyArray_Chunk;
-typedef struct {
- NPY_DATETIMEUNIT base;
- int num;
- int den; /*
- * Converted to 1 on input for now -- an
- * input-only mechanism
- */
- int events;
-} PyArray_DatetimeMetaData;
-
-typedef struct {
- npy_longlong year;
- int month, day, hour, min, sec, us, ps, as;
-} npy_datetimestruct;
-
-typedef struct {
- npy_longlong day;
- int sec, us, ps, as;
-} npy_timedeltastruct;
-
-#if PY_VERSION_HEX >= 0x03000000
-#define PyDataType_GetDatetimeMetaData(descr) \
- ((descr->metadata == NULL) ? NULL : \
- ((PyArray_DatetimeMetaData *)(PyCapsule_GetPointer( \
- PyDict_GetItemString( \
- descr->metadata, NPY_METADATA_DTSTR), NULL))))
-#else
-#define PyDataType_GetDatetimeMetaData(descr) \
- ((descr->metadata == NULL) ? NULL : \
- ((PyArray_DatetimeMetaData *)(PyCObject_AsVoidPtr( \
- PyDict_GetItemString(descr->metadata, NPY_METADATA_DTSTR)))))
-#endif
-
typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
/*
@@ -1245,9 +1192,6 @@
#define PyTypeNum_ISFLEXIBLE(type) (((type) >=NPY_STRING) && \
((type) <=NPY_VOID))
-#define PyTypeNum_ISDATETIME(type) (((type) >=NPY_DATETIME) && \
- ((type) <=NPY_TIMEDELTA))
-
#define PyTypeNum_ISUSERDEF(type) (((type) >= NPY_USERDEF) && \
((type) < NPY_USERDEF+ \
NPY_NUMUSERTYPES))
@@ -1268,7 +1212,6 @@
#define PyDataType_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(((PyArray_Descr*)(obj))->type_num)
#define PyDataType_ISPYTHON(obj) PyTypeNum_ISPYTHON(((PyArray_Descr*)(obj))->type_num)
#define PyDataType_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(((PyArray_Descr*)(obj))->type_num)
-#define PyDataType_ISDATETIME(obj) PyTypeNum_ISDATETIME(((PyArray_Descr*)(obj))->type_num)
#define PyDataType_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(((PyArray_Descr*)(obj))->type_num)
#define PyDataType_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(((PyArray_Descr*)(obj))->type_num)
#define PyDataType_ISOBJECT(obj) PyTypeNum_ISOBJECT(((PyArray_Descr*)(obj))->type_num)
@@ -1284,7 +1227,6 @@
#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))
#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))
#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
-#define PyArray_ISDATETIME(obj) PyTypeNum_ISDATETIME(PyArray_TYPE(obj))
#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))
#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))
#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))
Modified: branches/1.5.x/numpy/core/numerictypes.py
===================================================================
--- branches/1.5.x/numpy/core/numerictypes.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/numerictypes.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -39,10 +39,6 @@
longfloat, clongfloat,
- datetime_, timedelta_, (these inherit from timeinteger which inherits
- from signedinteger)
-
-
As part of the type-hierarchy: xx -- is bit-width
generic
@@ -396,9 +392,7 @@
('longcomplex', 'clongdouble'),
('bool_', 'bool'),
('unicode_', 'unicode'),
- ('object_', 'object'),
- ('timedelta_', 'timedelta'),
- ('datetime_', 'datetime')]
+ ('object_', 'object')]
if sys.version_info[0] >= 3:
type_pairs.extend([('bytes_', 'string'),
('str_', 'unicode'),
@@ -412,7 +406,7 @@
sctypeDict[alias] = sctypeDict[t]
# Remove aliases overriding python types and modules
to_remove = ['ulong', 'object', 'unicode', 'int', 'long', 'float',
- 'complex', 'bool', 'string', 'datetime', 'timedelta']
+ 'complex', 'bool', 'string']
if sys.version_info[0] >= 3:
# Py3K
to_remove.append('bytes')
@@ -832,8 +826,7 @@
'Complex':'FDG',
'AllInteger':'bBhHiIlLqQpP',
'AllFloat':'fdgFDG',
- 'Datetime': 'Mm',
- 'All':'?bhilqpBHILQPfdgFDGSUVOMm'}
+ 'All':'?bhilqpBHILQPfdgFDGSUVO'}
# backwards compatibility --- deprecated name
typeDict = sctypeDict
@@ -844,13 +837,11 @@
# i -> signed integer
# f -> floating point
# c -> complex
-# M -> datetime
-# m -> timedelta
# S -> string
# U -> Unicode string
# V -> record
# O -> Python object
-_kind_list = ['b', 'u', 'i', 'f', 'c', 'S', 'U', 'V', 'O', 'M', 'm']
+_kind_list = ['b', 'u', 'i', 'f', 'c', 'S', 'U', 'V', 'O']
__test_types = typecodes['AllInteger'][:-2]+typecodes['AllFloat']+'O'
__len_test_types = len(__test_types)
Modified: branches/1.5.x/numpy/core/setup.py
===================================================================
--- branches/1.5.x/numpy/core/setup.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/setup.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -723,7 +723,6 @@
join('src', 'multiarray', 'arrayobject.c'),
join('src', 'multiarray', 'numpymemoryview.c'),
join('src', 'multiarray', 'buffer.c'),
- join('src', 'multiarray', 'datetime.c'),
join('src', 'multiarray', 'numpyos.c'),
join('src', 'multiarray', 'conversion_utils.c'),
join('src', 'multiarray', 'flagsobject.c'),
Modified: branches/1.5.x/numpy/core/setup_common.py
===================================================================
--- branches/1.5.x/numpy/core/setup_common.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/setup_common.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -21,7 +21,7 @@
# Binary compatibility version number. This number is increased whenever the
# C-API is changed such that binary compatibility is broken, i.e. whenever a
# recompile of extension modules is needed.
-C_ABI_VERSION = 0x02000000
+C_ABI_VERSION = 0x01000009
# Minor API version. This number is increased whenever a change is made to the
# C-API -- whether it breaks binary compatibility or not. Some changes, such
@@ -29,7 +29,7 @@
# without breaking binary compatibility. In this case, only the C_API_VERSION
# (*not* C_ABI_VERSION) would be increased. Whenever binary compatibility is
# broken, both C_API_VERSION and C_ABI_VERSION should be increased.
-C_API_VERSION = 0x00000005
+C_API_VERSION = 0x00000004
class MismatchCAPIWarning(Warning):
pass
Modified: branches/1.5.x/numpy/core/src/multiarray/arrayobject.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/arrayobject.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/arrayobject.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -323,7 +323,6 @@
static PyObject *PyArray_StrFunction = NULL;
static PyObject *PyArray_ReprFunction = NULL;
-static PyObject *PyArray_DatetimeParseFunction = NULL;
/*NUMPY_API
* Set the array print function to be a Python function.
@@ -349,21 +348,6 @@
}
}
-/*NUMPY_API
- * Set the date time print function to be a Python function.
- */
-NPY_NO_EXPORT void
-PyArray_SetDatetimeParseFunction(PyObject *op)
-{
- /* Dispose of previous callback */
- Py_XDECREF(PyArray_DatetimeParseFunction);
- /* Add a reference to the new callback */
- Py_XINCREF(op);
- /* Remember new callback */
- PyArray_DatetimeParseFunction = op;
-}
-
-
static PyObject *
array_repr(PyArrayObject *self)
{
Modified: branches/1.5.x/numpy/core/src/multiarray/arraytypes.c.src
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/arraytypes.c.src 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/arraytypes.c.src 2010-07-17 18:31:17 UTC (rev 8495)
@@ -1,7 +1,6 @@
/* -*- c -*- */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "datetime.h"
#include "structmember.h"
#define _MULTIARRAYMODULE
@@ -17,7 +16,6 @@
#include "ctors.h"
#include "usertypes.h"
#include "npy_config.h"
-#include "_datetime.h"
#include "numpyos.h"
@@ -761,464 +759,8 @@
return -1;
}
-/*
- * Acknowledgement: Example code contributed by Marty Fuhr sponsored by
- * Google Summer of Code 2009 was used to integrate and adapt the mxDateTime
- * parser
- */
-/* #include "datetime.c" --- now included in multiarray_onefile */
-
-
-/* DateTime Objects in Python only keep microsecond resolution.
- *
- * When converting from datetime objects with an event component return a
- * tuple: * (baseunit, number of event) where baseunit follows is a datetime
- * type and number of events is a Python integer
- */
-
-
/*
- * Return a Python Datetime Object from a number representing the number of
- * units since the epoch (1970-01-01T00:00:00Z) ignoring leap seconds.
- */
-
-NPY_NO_EXPORT PyObject *
-PyDateTime_FromNormalized(npy_datetime val, NPY_DATETIMEUNIT base)
-{
- npy_datetimestruct ydate;
-
- /* Must be here to use PyDateTime_FromDateAndTime */
- PyDateTime_IMPORT;
-
- /* We just truncate the unused variables and don't wory about overflow */
- PyArray_DatetimeToDatetimeStruct(val, base, &ydate);
-
- /* FIXME?: We discard ydate.ns, ydate.ps, ydate.fs, and ydate.as */
- return PyDateTime_FromDateAndTime(ydate.year, ydate.month, ydate.day,
- ydate.hour, ydate.min, ydate.sec,
- ydate.us);
-}
-
-/*
- * We also can lose precision and range here. Ignored.
- * Don't use this function if you care.
- */
-
-NPY_NO_EXPORT PyObject *
-PyTimeDelta_FromNormalized(npy_timedelta val, NPY_DATETIMEUNIT base)
-{
- npy_timedeltastruct td;
-
- PyDateTime_IMPORT;
- PyArray_TimedeltaToTimedeltaStruct(val, base, &td);
-
- /* We discard td.ps and td.as */
- return PyDelta_FromDSU(td.day, td.sec, td.us);
-}
-
-
-NPY_NO_EXPORT PyObject *
-PyDateTime_FromInt64(datetime val, PyArray_Descr *descr)
-{
- PyArray_DatetimeMetaData *meta;
-
- meta = PyDataType_GetDatetimeMetaData(descr);
- if (meta == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "metadata not set for descriptor");
- return NULL;
- }
-
- if (meta->events > 1) {
- int events, rem, div;
- PyObject *obj;
-
- obj = PyTuple_New(2);
- events = meta->events;
- div = val/events;
- rem = val % events;
- PyTuple_SET_ITEM(obj, 1, PyInt_FromLong(rem));
- /* This resets meta->events for recursive call */
- meta->events = 1;
- PyTuple_SET_ITEM(obj, 0, PyDateTime_FromInt64(div, descr));
- meta->events = events;
- if (PyErr_Occurred()) {
- Py_DECREF(obj);
- return NULL;
- }
- return obj;
- }
-
- /*
- * We normalize the number to a base-unit and then return a
- * Python Datetime Object
- *
- * FIXME? : We silently truncate if it doesn't fit, either too
- * wide (e.g. 10 BC) or too narrow (nanoseconds)
- */
-
- /* Normalization and then conversion to Datetime */
- /* FIXME? : Check for Overflow... */
- return PyDateTime_FromNormalized(val*meta->num, meta->base);
-}
-
-
-NPY_NO_EXPORT PyObject *
-PyTimeDelta_FromInt64(timedelta val, PyArray_Descr *descr)
-{
- PyArray_DatetimeMetaData *meta;
- meta = PyDataType_GetDatetimeMetaData(descr);
- if (meta == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "metadata not set for descriptor");
- return NULL;
- }
-
- if (meta->events > 1) {
- int events, rem, div;
- PyObject *obj;
-
- obj = PyTuple_New(2);
- events = meta->events;
- div = val/events;
- rem = val % events;
- PyTuple_SET_ITEM(obj, 1, PyInt_FromLong(rem));
- /* This resets meta->events for recursive call */
- meta->events = 1;
- PyTuple_SET_ITEM(obj, 0, PyTimeDelta_FromInt64(div, descr));
- meta->events = events;
- if (PyErr_Occurred()) {
- Py_DECREF(obj);
- return NULL;
- }
- return obj;
- }
-
- /* FIXME? : Check for Overflow */
- return PyTimeDelta_FromNormalized(val*meta->num, meta->base);
-}
-
-
-
-NPY_NO_EXPORT npy_datetime
-PyDateTime_AsNormalized(PyObject *obj, NPY_DATETIMEUNIT base)
-{
- npy_datetimestruct ydate;
-
- /* Must be here to use PyDateTime_FromDateAndTime */
- PyDateTime_IMPORT;
-
- if (!PyDateTime_Check(obj) && !PyDate_Check(obj)) {
- PyErr_SetString(PyExc_ValueError,
- "Must be a datetime.date or datetime.datetime object");
- return -1;
- }
-
- ydate.year = PyDateTime_GET_YEAR(obj);
- ydate.month = PyDateTime_GET_MONTH(obj);
- ydate.day = PyDateTime_GET_DAY(obj);
-
- if (PyDateTime_Check(obj)) {
- ydate.hour = PyDateTime_DATE_GET_HOUR(obj);
- ydate.min = PyDateTime_DATE_GET_MINUTE(obj);
- ydate.sec = PyDateTime_DATE_GET_SECOND(obj);
- ydate.us = PyDateTime_DATE_GET_MICROSECOND(obj);
- }
- else {
- ydate.hour = 0;
- ydate.min = 0;
- ydate.sec = 0;
- ydate.us = 0;
- }
-
- ydate.ps = 0;
- ydate.as = 0;
-
- /* We just truncate the unused variables and don't wory about overflow */
- return PyArray_DatetimeStructToDatetime(base, &ydate);
-}
-
-NPY_NO_EXPORT npy_timedelta
-PyTimeDelta_AsNormalized(PyObject *obj, NPY_DATETIMEUNIT base)
-{
- npy_timedeltastruct td;
-
- PyDateTime_IMPORT;
-
- if (!PyDelta_Check(obj)) {
- PyErr_SetString(PyExc_ValueError,
- "Must be a datetime.timedelta object");
- return -1;
- }
-
- td.day = ((PyDateTime_Delta *)obj)->days;
- td.sec = ((PyDateTime_Delta *)obj)->seconds;
- td.us = ((PyDateTime_Delta *)obj)->microseconds;
- td.ps = 0;
- td.as = 0;
-
- return PyArray_TimedeltaStructToTimedelta(base, &td);
-}
-
-
-/*
- * These expect a 2-tuple if meta->events > 1 (baseobj, num-counts)
- * where baseobj is a datetime object or a timedelta object respectively.
- *
- */
-
-NPY_NO_EXPORT npy_datetime
-PyDateTime_AsInt64(PyObject *obj, PyArray_Descr *descr)
-{
- PyArray_DatetimeMetaData *meta;
- npy_datetime res;
-
- meta = PyDataType_GetDatetimeMetaData(descr);
- if (meta == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "metadata not set for descriptor");
- return -1;
- }
-
-
- if (meta->events > 1) {
- datetime tmp;
- int events;
-
- if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2) {
- PyErr_SetString(PyExc_ValueError,
- "need a 2-tuple on setting if events > 1");
- return -1;
- }
- /* Alter the dictionary and call again */
- /* FIXME: not thread safe */
- events = meta->events;
- meta->events = 1;
- tmp = PyDateTime_AsInt64(PyTuple_GET_ITEM(obj, 0), descr);
- meta->events = events;
- if (PyErr_Occurred()) {
- return -1;
- }
- /* FIXME: Check for overflow */
- tmp *= events;
- tmp += MyPyLong_AsLongLong(PyTuple_GET_ITEM(obj, 1));
- if (PyErr_Occurred()) {
- return -1;
- }
- return tmp;
- }
-
- res = PyDateTime_AsNormalized(obj, meta->base);
- return res/meta->num;
-}
-
-
-NPY_NO_EXPORT timedelta
-PyTimeDelta_AsInt64(PyObject *obj, PyArray_Descr *descr)
-{
- PyArray_DatetimeMetaData *meta;
- npy_timedelta res;
-
- meta = PyDataType_GetDatetimeMetaData(descr);
- if (meta == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "metadata not set for descriptor");
- return -1;
- }
-
- if (meta->events > 1) {
- timedelta tmp;
- int events;
-
- if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2) {
- PyErr_SetString(PyExc_ValueError,
- "need a 2-tuple on setting if events > 1");
- return -1;
- }
- /* Alter the dictionary and call again (not thread safe) */
- events = meta->events;
- meta->events = 1;
- tmp = PyTimeDelta_AsInt64(PyTuple_GET_ITEM(obj, 0), descr);
- meta->events = events;
- if (PyErr_Occurred()) {
- return -1;
- }
- /* FIXME: Check for overflow */
- tmp *= events;
- tmp += MyPyLong_AsLongLong(PyTuple_GET_ITEM(obj, 1));
- if (PyErr_Occurred()) {
- return -1;
- }
- return tmp;
- }
-
- res = PyTimeDelta_AsNormalized(obj, meta->base);
- return res / meta->num;
-}
-
-
-/*
- * Always return DateTime Object after normalizing to basic units (or a tuple
- * if meta->events > 1):
- *
- * Problem: DateTime does not support all the resolutions (ns) nor the
- * dynamic range (pre 1 AD) of NumPy Date-times.
- *
- * getitem is not used that much --- if losing resolution hurts, stick
- * with the array scalar versions of the date-time.
- *
- * considered returning array scalars here just like longdouble. This has the
- * problem of recursion in some cases (because in a few places the code
- * expects getitem to return a Python-system object)
- *
- * considered returning different things depending on the resolution but this
- * would make it hard to write generic code --- but do you need to write
- * generic code on all the frequencies because they cover a wide range.
- *
- * Solution: The use-case of actually wanting a date-time object when the
- * resolution and dynamic range match, make it the compelling default. When it
- * does fails, there are alternatives for the programmer to use.
- *
- * New question: Should we change (c)longdouble at this point? to return Python Float?
- */
-
-static PyObject *
-DATETIME_getitem(char *ip, PyArrayObject *ap) {
- datetime t1;
-
- if ((ap == NULL) || PyArray_ISBEHAVED_RO(ap)) {
- t1 = *((datetime *)ip);
- return PyDateTime_FromInt64((datetime)t1, ap->descr);
- }
- else {
- ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap), ap);
- return PyDateTime_FromInt64((datetime)t1, ap->descr);
- }
-}
-
-
-static PyObject *
-TIMEDELTA_getitem(char *ip, PyArrayObject *ap) {
- timedelta t1;
-
- if ((ap == NULL) || PyArray_ISBEHAVED_RO(ap)) {
- t1 = *((timedelta *)ip);
- return PyTimeDelta_FromInt64((timedelta)t1, ap->descr);
- }
- else {
- ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap), ap);
- return PyTimeDelta_FromInt64((timedelta)t1, ap->descr);
- }
-}
-
-/* FIXME:
- * This needs to take
- * 1) Integers and Longs (anything that can be converted to an Int)
- * 2) Strings (ISO-style dates)
- * 3) Datetime Scalars (that it converts based on scalar dtype.
- * 4) Datetime and Date objects
- * Plus a tuple for meta->events > 1
- *
- * 3) is partially implemented, 4) is implemented
- */
-
-static int
-DATETIME_setitem(PyObject *op, char *ov, PyArrayObject *ap) {
- /* ensure alignment */
- datetime temp;
-
- if (PyArray_IsScalar(op, Datetime)) {
- /* This needs to convert based on type */
- temp = ((PyDatetimeScalarObject *)op)->obval;
- }
-#if defined(NPY_PY3K)
- else if (PyUString_Check(op)) {
-#else
- else if (PyUString_Check(op) || PyUnicode_Check(op)) {
-#endif
- /* FIXME: Converts to DateTime first and therefore does not handle extended notation */
- /* import _mx_datetime_parser
- * res = _mx_datetime_parser(name)
- * Convert from datetime to Int
- */
- PyObject *res, *module;
-
- module = PyImport_ImportModule("numpy.core._mx_datetime_parser");
- if (module == NULL) { return -1; }
- res = PyObject_CallMethod(module, "datetime_from_string", "O", op);
- Py_DECREF(module);
- if (res == NULL) { return -1; }
- temp = PyDateTime_AsInt64(res, ap->descr);
- Py_DECREF(res);
- if (PyErr_Occurred()) return -1;
- }
- else if (PyInt_Check(op)) {
- temp = PyInt_AS_LONG(op);
- }
- else if (PyLong_Check(op)) {
- temp = PyLong_AsLongLong(op);
- }
- else {
- temp = PyDateTime_AsInt64(op, ap->descr);
- }
- if (PyErr_Occurred()) {
- if (PySequence_Check(op)) {
- PyErr_Clear();
- PyErr_SetString(PyExc_ValueError, _SEQUENCE_MESSAGE);
- }
- return -1;
- }
- if (ap == NULL || PyArray_ISBEHAVED(ap))
- *((datetime *)ov)=temp;
- else {
- ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), ap);
- }
- return 0;
-}
-
-/* FIXME: This needs to take
- * 1) Integers and Longs (anything that can be converted to an Int)
- * 2) Timedelta scalar objects (with resolution conversion)
- * 3) Python Timedelta objects
- *
- * Plus a tuple for meta->events > 1
- */
-
-static int
-TIMEDELTA_setitem(PyObject *op, char *ov, PyArrayObject *ap) {
- /* ensure alignment */
- timedelta temp;
-
- if (PyArray_IsScalar(op, Timedelta)) {
- temp = ((PyTimedeltaScalarObject *)op)->obval;
- }
- else if (PyInt_Check(op)) {
- temp = PyInt_AS_LONG(op);
- }
- else if (PyLong_Check(op)) {
- temp = PyLong_AsLongLong(op);
- }
- else {
- temp = PyTimeDelta_AsInt64(op, ap->descr);
- }
- if (PyErr_Occurred()) {
- if (PySequence_Check(op)) {
- PyErr_Clear();
- PyErr_SetString(PyExc_ValueError, _SEQUENCE_MESSAGE);
- }
- return -1;
- }
- if (ap == NULL || PyArray_ISBEHAVED(ap))
- *((timedelta *)ov)=temp;
- else {
- ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), ap);
- }
- return 0;
-}
-
-
-/*
*****************************************************************************
** TYPE TO TYPE CONVERSIONS **
*****************************************************************************
@@ -1231,21 +773,17 @@
/**begin repeat
*
* #TOTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, DATETIME,
- * TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #totype = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble, datetime,
- * timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
/**begin repeat1
*
* #FROMTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, DATETIME,
- * TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #fromtype = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble, datetime,
- * timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@FROMTYPE at _to_@TOTYPE@(@fromtype@ *ip, @totype@ *op, intp n,
@@ -1279,11 +817,9 @@
/**begin repeat
*
* #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, DATETIME,
- * TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble, datetime,
- * timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@FROMTYPE at _to_BOOL(@fromtype@ *ip, Bool *op, intp n,
@@ -1314,11 +850,9 @@
/**begin repeat
* #TOTYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, DATETIME,
- * TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #totype = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble, datetime,
- * timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
BOOL_to_ at TOTYPE@(Bool *ip, @totype@ *op, intp n,
@@ -1338,11 +872,9 @@
/**begin repeat1
* #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, DATETIME,
- * TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble, datetime,
- * timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@FROMTYPE at _to_@TOTYPE@(@fromtype@ *ip, @totype@ *op, intp n,
@@ -1384,13 +916,11 @@
*
* #FROMTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID, OBJECT,
- * DATETIME, TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID, OBJECT#
* #fromtype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * cfloat, cdouble, clongdouble, char, char, char, PyObject *,
- * datetime, timedelta#
- * #skip = 1*17, aip->descr->elsize*3, 1*3#
+ * cfloat, cdouble, clongdouble, char, char, char, PyObject *#
+ * #skip = 1*17, aip->descr->elsize*3, 1*1#
*/
static void
@FROMTYPE at _to_OBJECT(@fromtype@ *ip, PyObject **op, intp n, PyArrayObject *aip,
@@ -1432,13 +962,11 @@
*
* #TOTYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID, DATETIME,
- * TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID#
* #totype = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * cfloat, cdouble, clongdouble, char, char, char, datetime,
- * timedelta#
- * #skip = 1*17, aop->descr->elsize*3, 1*2#
+ * cfloat, cdouble, clongdouble, char, char, char#
+ * #skip = 1*17, aop->descr->elsize*3#
*/
static void
OBJECT_to_ at TOTYPE@(PyObject **ip, @totype@ *op, intp n,
@@ -1461,13 +989,13 @@
/**begin repeat
*
- * #from = STRING*22, UNICODE*22, VOID*22#
- * #fromtyp = char*66#
- * #to = (BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID, DATETIME, TIMEDELTA)*3#
- * #totyp = (Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char, datetime, timedelta)*3#
- * #oskip = (1*17,aop->descr->elsize*3,1*2)*3#
- * #convert = 1*17, 0*3, 1*2, 1*17, 0*3, 1*2, 0*22#
- * #convstr = (Int*9, Long*2, Float*3, Complex*3, Tuple*3, Long*2)*3#
+ * #from = STRING*20, UNICODE*20, VOID*20#
+ * #fromtyp = char*60#
+ * #to = (BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, VOID)*3#
+ * #totyp = (Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, char, char, char)*3#
+ * #oskip = (1*17,aop->descr->elsize*3)*3#
+ * #convert = 1*17, 0*3, 1*17, 0*3, 0*20#
+ * #convstr = (Int*9, Long*2, Float*3, Complex*3, Tuple*3)*3#
*/
static void
@from at _to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
@@ -1513,14 +1041,14 @@
/**begin repeat
*
- * #to = STRING*19, UNICODE*19, VOID*19#
- * #totyp = char*19, char*19, char*19#
+ * #to = STRING*17, UNICODE*17, VOID*17#
+ * #totyp = char*17, char*17, char*17#
* #from = (BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, DATETIME, TIMEDELTA)*3#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE)*3#
* #fromtyp = (Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * cfloat, cdouble, clongdouble, datetime, timedelta)*3#
+ * cfloat, cdouble, clongdouble)*3#
*/
static void
@from at _to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip,
@@ -1617,8 +1145,7 @@
}
/**begin repeat
- * #fname = CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID,
- * DATETIME, TIMEDELTA#
+ * #fname = CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID#
*/
#define @fname at _scan NULL
/**end repeat**/
@@ -1633,11 +1160,11 @@
/**begin repeat
* #fname = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG,
- * ULONGLONG, DATETIME, TIMEDELTA#
+ * ULONGLONG#
* #type = byte, ubyte, short, ushort, int, uint, long, ulong, longlong,
- * ulonglong, datetime, timedelta#
- * #func = (l, ul)*5, l, l#
- * #btype = (long, ulong)*5, long, long#
+ * ulonglong#
+ * #func = (l, ul)*5#
+ * #btype = (long, ulong)*5#
*/
static int
@fname at _fromstr(char *str, @type@ *ip, char **endptr, PyArray_Descr *NPY_UNUSED(ignore))
@@ -1685,11 +1212,11 @@
/**begin repeat
*
* #fname = SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT,
- * DOUBLE, LONGDOUBLE, DATETIME, TIMEDELTA#
+ * DOUBLE, LONGDOUBLE#
* #fsize = SHORT, SHORT, INT, INT, LONG, LONG, LONGLONG, LONGLONG, FLOAT,
- * DOUBLE, LONGDOUBLE, DATETIME, TIMEDELTA#
+ * DOUBLE, LONGDOUBLE#
* #type = short, ushort, int, uint, long, ulong, longlong, ulonglong, float,
- * double, longdouble, datetime, timedelta#
+ * double, longdouble#
*/
static void
@fname at _copyswapn (void *dst, intp dstride, void *src, intp sstride,
@@ -2226,11 +1753,9 @@
/**begin repeat
*
* #fname = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble,
- * datetime, timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static Bool
@fname at _nonzero (char *ip, PyArrayObject *ap)
@@ -2447,9 +1972,9 @@
/**begin repeat
* #TYPE = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, DATETIME, TIMEDELTA#
+ * LONGLONG, ULONGLONG#
* #type = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, datetime, timedelta#
+ * longlong, ulonglong#
*/
static int
@@ -2731,11 +2256,11 @@
*
* #fname = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, DATETIME, TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE#
* #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * float, double, longdouble, datetime, timedelta#
- * #incr = ip++*14, ip+=2*3, ip++*2#
+ * float, double, longdouble#
+ * #incr= ip++*14, ip+=2*3#
*/
static int
@fname at _argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *NPY_UNUSED(aip))
@@ -2842,14 +2367,11 @@
/**begin repeat
*
* #name = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #type = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble,
- * datetime, timedelta#
+ * longlong, ulonglong, float, double, longdouble#
* #out = long, ulong, long, ulong, long, ulong, long, ulong,
- * longlong, ulonglong, float, double, longdouble,
- * datetime, timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@name at _dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n,
@@ -2977,11 +2499,9 @@
/**begin repeat
*
* #NAME = BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #typ = byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble,
- * datetime, timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@NAME at _fill(@typ@ *buffer, intp length, void *NPY_UNUSED(ignored))
@@ -3051,11 +2571,9 @@
/**begin repeat
*
* #NAME = SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG,
- * FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#
* #typ = short, ushort, int, uint, long, ulong, longlong, ulonglong,
- * float, double, longdouble, cfloat, cdouble, clongdouble,
- * datetime, timedelta#
+ * float, double, longdouble, cfloat, cdouble, clongdouble#
*/
static void
@NAME at _fillwithscalar(@typ@ *buffer, intp length, @typ@ *value, void *NPY_UNUSED(ignored))
@@ -3080,11 +2598,9 @@
/**begin repeat
*
* #name = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
- * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE#
* #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
- * longlong, ulonglong, float, double, longdouble,
- * datetime, timedelta#
+ * longlong, ulonglong, float, double, longdouble#
*/
static void
@name at _fastclip(@type@ *in, intp ni, @type@ *min, @type@ *max, @type@ *out)
@@ -3186,10 +2702,10 @@
*
* #name = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, DATETIME, TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE#
* #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * cfloat, cdouble, clongdouble, datetime, timedelta#
+ * cfloat, cdouble, clongdouble#
*/
static void
@name at _fastputmask(@type@ *in, Bool *mask, intp ni, @type@ *vals, intp nv)
@@ -3230,10 +2746,10 @@
*
* #name = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, DATETIME, TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE#
* #type = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * cfloat, cdouble, clongdouble, datetime, timedelta#
+ * cfloat, cdouble, clongdouble#
*/
static int
@name at _fasttake(@type@ *dest, @type@ *src, intp *indarray,
@@ -3349,6 +2865,29 @@
* #endian = |, |, =#
*/
static PyArray_ArrFuncs _Py at NAME@_ArrFuncs = {
+ {
+ (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
+ (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_INT,
+ (PyArray_VectorUnaryFunc*)@from at _to_UINT,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
+ (PyArray_VectorUnaryFunc*)@from at _to_STRING,
+ (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
+ (PyArray_VectorUnaryFunc*)@from at _to_VOID,
+ },
(PyArray_GetItemFunc*)@from at _getitem,
(PyArray_SetItemFunc*)@from at _setitem,
(PyArray_CopySwapNFunc*)@from at _copyswapn,
@@ -3373,33 +2912,7 @@
NULL,
(PyArray_FastClipFunc *)NULL,
(PyArray_FastPutmaskFunc *)NULL,
- (PyArray_FastTakeFunc *)NULL,
- NULL, NULL, NULL, NULL,
- {
- (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
- (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_INT,
- (PyArray_VectorUnaryFunc*)@from at _to_UINT,
- (PyArray_VectorUnaryFunc*)@from at _to_LONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_DATETIME,
- (PyArray_VectorUnaryFunc*)@from at _to_TIMEDELTA,
- (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
- (PyArray_VectorUnaryFunc*)@from at _to_STRING,
- (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
- (PyArray_VectorUnaryFunc*)@from at _to_VOID
- }
+ (PyArray_FastTakeFunc *)NULL
};
/*
@@ -3412,7 +2925,6 @@
PyArray_ at from@LTR,
'@endian@',
0,
- 0,
PyArray_ at from@,
0,
_ALIGN(@align@),
@@ -3430,21 +2942,44 @@
*
* #from = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG,
* LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, DATETIME, TIMEDELTA#
- * #num = 1*14, 2*3, 1*3#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT#
+ * #num = 1*14, 2*3, 1*1#
* #fromtyp = Bool, byte, ubyte, short, ushort, int, uint, long, ulong,
* longlong, ulonglong, float, double, longdouble,
- * float, double, longdouble, PyObject *, datetime, timedelta#
+ * float, double, longdouble, PyObject *#
* #NAME = Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong,
* LongLong, ULongLong, Float, Double, LongDouble,
- * CFloat, CDouble, CLongDouble, Object, Datetime, Timedelta#
+ * CFloat, CDouble, CLongDouble, Object#
* #kind = GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED,
* SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING,
- * COMPLEX, COMPLEX, COMPLEX, OBJECT, DATETIME, TIMEDELTA#
- * #endian = |*3, =*14, |, =*2#
- * #isobject= 0*17,NPY_OBJECT_DTYPE_FLAGS,0*2#
+ * COMPLEX, COMPLEX, COMPLEX, OBJECT#
+ * #endian = |*3, =*14, |#
+ * #isobject= 0*17,NPY_OBJECT_DTYPE_FLAGS#
*/
static PyArray_ArrFuncs _Py at NAME@_ArrFuncs = {
+ {
+ (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
+ (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
+ (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
+ (PyArray_VectorUnaryFunc*)@from at _to_INT,
+ (PyArray_VectorUnaryFunc*)@from at _to_UINT,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
+ (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
+ (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
+ (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
+ (PyArray_VectorUnaryFunc*)@from at _to_STRING,
+ (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
+ (PyArray_VectorUnaryFunc*)@from at _to_VOID,
+ },
(PyArray_GetItemFunc*)@from at _getitem,
(PyArray_SetItemFunc*)@from at _setitem,
(PyArray_CopySwapNFunc*)@from at _copyswapn,
@@ -3469,33 +3004,7 @@
NULL,
(PyArray_FastClipFunc*)@from at _fastclip,
(PyArray_FastPutmaskFunc*)@from at _fastputmask,
- (PyArray_FastTakeFunc*)@from at _fasttake,
- NULL, NULL, NULL, NULL,
- {
- (PyArray_VectorUnaryFunc*)@from at _to_BOOL,
- (PyArray_VectorUnaryFunc*)@from at _to_BYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_UBYTE,
- (PyArray_VectorUnaryFunc*)@from at _to_SHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_USHORT,
- (PyArray_VectorUnaryFunc*)@from at _to_INT,
- (PyArray_VectorUnaryFunc*)@from at _to_UINT,
- (PyArray_VectorUnaryFunc*)@from at _to_LONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONG,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_ULONGLONG,
- (PyArray_VectorUnaryFunc*)@from at _to_FLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_DOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_LONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CFLOAT,
- (PyArray_VectorUnaryFunc*)@from at _to_CDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_CLONGDOUBLE,
- (PyArray_VectorUnaryFunc*)@from at _to_DATETIME,
- (PyArray_VectorUnaryFunc*)@from at _to_TIMEDELTA,
- (PyArray_VectorUnaryFunc*)@from at _to_OBJECT,
- (PyArray_VectorUnaryFunc*)@from at _to_STRING,
- (PyArray_VectorUnaryFunc*)@from at _to_UNICODE,
- (PyArray_VectorUnaryFunc*)@from at _to_VOID
- }
+ (PyArray_FastTakeFunc*)@from at _fasttake
};
/*
@@ -3507,7 +3016,6 @@
PyArray_ at kind@LTR,
PyArray_ at from@LTR,
'@endian@',
- 0,
@isobject@,
PyArray_ at from@,
@num@*sizeof(@fromtyp@),
@@ -3521,29 +3029,6 @@
/**end repeat**/
-static void
-_init_datetime_descr(PyArray_Descr *descr)
-{
- PyArray_DatetimeMetaData *dt_data;
- PyObject *cobj;
-
- dt_data = _pya_malloc(sizeof(PyArray_DatetimeMetaData));
- dt_data->base = NPY_FR_us;
- dt_data->num = 1;
- dt_data->den = 1;
- dt_data->events = 1;
-
-/* FIXME
- * There is no error check here and no way to indicate an error
- * until the metadata turns up NULL.
- */
- cobj = NpyCapsule_FromVoidPtr((void *)dt_data, simple_capsule_dtor);
- descr->metadata = PyDict_New();
- PyDict_SetItemString(descr->metadata, NPY_METADATA_DTSTR, cobj);
- Py_DECREF(cobj);
-
-}
-
#define _MAX_LETTER 128
static char _letter_to_num[_MAX_LETTER];
@@ -3565,8 +3050,6 @@
&CFLOAT_Descr,
&CDOUBLE_Descr,
&CLONGDOUBLE_Descr,
- &DATETIME_Descr,
- &TIMEDELTA_Descr,
&OBJECT_Descr,
&STRING_Descr,
&UNICODE_Descr,
@@ -3624,13 +3107,6 @@
Py_INCREF(ret);
}
- /* Make sure dtype metadata is initialized for DATETIME */
- if (PyTypeNum_ISDATETIME(type)) {
- if (ret->metadata == NULL) {
- _init_datetime_descr(ret);
- }
- }
-
return ret;
}
@@ -3656,8 +3132,7 @@
*
* #name = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT, INTP, UINTP,
* LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID,
- * DATETIME,TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID#
*/
_letter_to_num[PyArray_ at name@LTR] = PyArray_ at name@;
/**end repeat**/
@@ -3666,8 +3141,7 @@
/**begin repeat
* #name = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, UINT,
* LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE,
- * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID,
- * DATETIME, TIMEDELTA#
+ * CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, STRING, UNICODE, VOID#
*/
@name at _Descr.fields = Py_None;
/**end repeat**/
@@ -3783,32 +3257,6 @@
_ALIGN(char),
(PyObject *) &PyVoidArrType_Type));
Py_DECREF(s);
- PyDict_SetItemString(infodict, "DATETIME",
-#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiNNO", PyArray_DATETIMELTR,
-#else
- s = Py_BuildValue("ciiiNNO", PyArray_DATETIMELTR,
-#endif
- PyArray_DATETIME,
- sizeof(npy_datetime) * CHAR_BIT,
- _ALIGN(npy_datetime),
- MyPyLong_FromInt64(MAX_DATETIME),
- MyPyLong_FromInt64(MIN_DATETIME),
- (PyObject *) &PyDatetimeArrType_Type));
- Py_DECREF(s);
- PyDict_SetItemString(infodict, "TIMEDELTA",
-#if defined(NPY_PY3K)
- s = Py_BuildValue("CiiiNNO", PyArray_TIMEDELTALTR,
-#else
- s = Py_BuildValue("ciiiNNO",PyArray_TIMEDELTALTR,
-#endif
- PyArray_TIMEDELTA,
- sizeof(npy_timedelta) * CHAR_BIT,
- _ALIGN(npy_timedelta),
- MyPyLong_FromInt64(MAX_TIMEDELTA),
- MyPyLong_FromInt64(MIN_TIMEDELTA),
- (PyObject *)&PyTimedeltaArrType_Type));
- Py_DECREF(s);
#define SETTYPE(name) \
Py_INCREF(&Py##name##ArrType_Type); \
@@ -3820,7 +3268,6 @@
SETTYPE(Integer);
SETTYPE(Inexact);
SETTYPE(SignedInteger);
- SETTYPE(TimeInteger);
SETTYPE(UnsignedInteger);
SETTYPE(Floating);
SETTYPE(ComplexFloating);
Modified: branches/1.5.x/numpy/core/src/multiarray/convert_datatype.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/convert_datatype.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/convert_datatype.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -530,10 +530,6 @@
if (totype == PyArray_BOOL) {
return 0;
}
- if (fromtype == PyArray_DATETIME || fromtype == PyArray_TIMEDELTA ||
- totype == PyArray_DATETIME || totype == PyArray_TIMEDELTA) {
- return 0;
- }
if (totype == PyArray_OBJECT || totype == PyArray_VOID) {
return 1;
}
Modified: branches/1.5.x/numpy/core/src/multiarray/descriptor.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/descriptor.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/descriptor.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -134,32 +134,7 @@
return 0;
}
-static int
-_check_for_datetime(char *type, int len)
-{
- if (len < 1) {
- return 0;
- }
- if (type[1] == '8' && (type[0] == 'M' || type[0] == 'm')) {
- return 1;
- }
- if (len < 10) {
- return 0;
- }
- if (strncmp(type, "datetime64", 10) == 0) {
- return 1;
- }
- if (len < 11) {
- return 0;
- }
- if (strncmp(type, "timedelta64", 11) == 0) {
- return 1;
- }
- return 0;
-}
-
-
#undef _chk_byteorder
static PyArray_Descr *
@@ -253,7 +228,7 @@
PyDimMem_FREE(shape.ptr);
newdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));
newdescr->subarray->base = type;
- newdescr->flags = type->flags;
+ newdescr->hasobject = type->hasobject;
Py_INCREF(val);
newdescr->subarray->shape = val;
Py_XDECREF(newdescr->fields);
@@ -381,7 +356,7 @@
"two fields with the same name");
goto fail;
}
- dtypeflags |= (conv->flags & NPY_FROM_FIELDS);
+ dtypeflags |= (conv->hasobject & NPY_FROM_FIELDS);
tup = PyTuple_New((title == NULL ? 2 : 3));
PyTuple_SET_ITEM(tup, 0, (PyObject *)conv);
if (align) {
@@ -426,7 +401,7 @@
new->fields = fields;
new->names = nameslist;
new->elsize = totalsize;
- new->flags=dtypeflags;
+ new->hasobject=dtypeflags;
if (maxalign > 1) {
totalsize = ((totalsize + maxalign - 1)/maxalign)*maxalign;
}
@@ -489,7 +464,7 @@
Py_DECREF(key);
goto fail;
}
- dtypeflags |= (conv->flags & NPY_FROM_FIELDS);
+ dtypeflags |= (conv->hasobject & NPY_FROM_FIELDS);
PyTuple_SET_ITEM(tup, 0, (PyObject *)conv);
if (align) {
int _align;
@@ -509,7 +484,7 @@
new = PyArray_DescrNewFromType(PyArray_VOID);
new->fields = fields;
new->names = nameslist;
- new->flags=dtypeflags;
+ new->hasobject=dtypeflags;
if (maxalign > 1) {
totalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;
}
@@ -525,263 +500,7 @@
return NULL;
}
-/* Exported as DATETIMEUNITS in multiarraymodule.c */
-NPY_NO_EXPORT char *_datetime_strings[] = {
- NPY_STR_Y,
- NPY_STR_M,
- NPY_STR_W,
- NPY_STR_B,
- NPY_STR_D,
- NPY_STR_h,
- NPY_STR_m,
- NPY_STR_s,
- NPY_STR_ms,
- NPY_STR_us,
- NPY_STR_ns,
- NPY_STR_ps,
- NPY_STR_fs,
- NPY_STR_as
-};
-static NPY_DATETIMEUNIT
- _unit_from_str(char *base)
-{
- NPY_DATETIMEUNIT unit;
-
- if (base == NULL) {
- return NPY_DATETIME_DEFAULTUNIT;
- }
-
- unit = NPY_FR_Y;
- while (unit < NPY_DATETIME_NUMUNITS) {
- if (strcmp(base, _datetime_strings[unit]) == 0) {
- break;
- }
- unit++;
- }
- if (unit == NPY_DATETIME_NUMUNITS) {
- return NPY_DATETIME_DEFAULTUNIT;
- }
-
- return unit;
-}
-
-static int _multiples_table[16][4] = {
- {12, 52, 365}, /* NPY_FR_Y */
- {NPY_FR_M, NPY_FR_W, NPY_FR_D},
- {4, 30, 720}, /* NPY_FR_M */
- {NPY_FR_W, NPY_FR_D, NPY_FR_h},
- {5, 7, 168, 10080}, /* NPY_FR_W */
- {NPY_FR_B, NPY_FR_D, NPY_FR_h, NPY_FR_m},
- {24, 1440, 86400}, /* NPY_FR_B */
- {NPY_FR_h, NPY_FR_m, NPY_FR_s},
- {24, 1440, 86400}, /* NPY_FR_D */
- {NPY_FR_h, NPY_FR_m, NPY_FR_s},
- {60, 3600}, /* NPY_FR_h */
- {NPY_FR_m, NPY_FR_s},
- {60, 60000}, /* NPY_FR_m */
- {NPY_FR_s, NPY_FR_ms},
- {1000, 1000000}, /* >=NPY_FR_s */
- {0, 0}
-};
-
-
-/* Translate divisors into multiples of smaller units */
-static int
-_convert_divisor_to_multiple(PyArray_DatetimeMetaData *meta)
-{
- int i, num, ind;
- int *totry;
- NPY_DATETIMEUNIT *baseunit;
- int q, r;
-
- ind = ((int)meta->base - (int)NPY_FR_Y)*2;
- totry = _multiples_table[ind];
- baseunit = (NPY_DATETIMEUNIT *)_multiples_table[ind + 1];
-
- num = 3;
- if (meta->base == NPY_FR_W) {
- num = 4;
- }
- else if (meta->base > NPY_FR_D) {
- num = 2;
- }
- if (meta->base >= NPY_FR_s) {
- ind = ((int)NPY_FR_s - (int)NPY_FR_Y)*2;
- totry = _multiples_table[ind];
- baseunit = (NPY_DATETIMEUNIT *)_multiples_table[ind + 1];
- baseunit[0] = meta->base + 1;
- baseunit[1] = meta->base + 2;
- if (meta->base == NPY_DATETIME_NUMUNITS - 2) {
- num = 1;
- }
- if (meta->base == NPY_DATETIME_NUMUNITS - 1) {
- num = 0;
- }
- }
-
- for (i = 0; i < num; i++) {
- q = totry[i] / meta->den;
- r = totry[i] % meta->den;
- if (r == 0) {
- break;
- }
- }
- if (i == num) {
- PyErr_Format(PyExc_ValueError,
- "divisor (%d) is not a multiple of a lower-unit", meta->den);
- return -1;
- }
- meta->base = baseunit[i];
- meta->den = 1;
- meta->num *= q;
-
- return 0;
-}
-
-
-static PyObject *
-_get_datetime_tuple_from_cobj(PyObject *cobj)
-{
- PyArray_DatetimeMetaData *dt_data;
- PyObject *dt_tuple;
-
- dt_data = NpyCapsule_AsVoidPtr(cobj);
- dt_tuple = PyTuple_New(4);
-
- PyTuple_SET_ITEM(dt_tuple, 0,
- PyBytes_FromString(_datetime_strings[dt_data->base]));
- PyTuple_SET_ITEM(dt_tuple, 1,
- PyInt_FromLong(dt_data->num));
- PyTuple_SET_ITEM(dt_tuple, 2,
- PyInt_FromLong(dt_data->den));
- PyTuple_SET_ITEM(dt_tuple, 3,
- PyInt_FromLong(dt_data->events));
-
- return dt_tuple;
-}
-
-static PyObject *
-_convert_datetime_tuple_to_cobj(PyObject *tuple)
-{
- PyArray_DatetimeMetaData *dt_data;
- PyObject *ret;
-
- dt_data = _pya_malloc(sizeof(PyArray_DatetimeMetaData));
- dt_data->base = _unit_from_str(
- PyBytes_AsString(PyTuple_GET_ITEM(tuple, 0)));
-
- /* Assumes other objects are Python integers */
- dt_data->num = PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 1));
- dt_data->den = PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 2));
- dt_data->events = PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, 3));
-
- if (dt_data->den > 1) {
- if (_convert_divisor_to_multiple(dt_data) < 0) {
- return NULL;
- }
- }
-
-/* FIXME
- * There is no error handling here.
- */
- ret = NpyCapsule_FromVoidPtr((void *)dt_data, simple_capsule_dtor);
- return ret;
-}
-
-static PyArray_Descr *
-_convert_from_datetime_tuple(PyObject *obj)
-{
- PyArray_Descr *new;
- PyObject *dt_tuple;
- PyObject *dt_cobj;
- PyObject *datetime;
-
- if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj)!=2) {
- PyErr_SetString(PyExc_RuntimeError,
- "_datetimestring is not returning a tuple with length 2");
- return NULL;
- }
-
- dt_tuple = PyTuple_GET_ITEM(obj, 0);
- datetime = PyTuple_GET_ITEM(obj, 1);
- if (!PyTuple_Check(dt_tuple)
- || PyTuple_GET_SIZE(dt_tuple) != 4
- || !PyInt_Check(datetime)) {
- PyErr_SetString(PyExc_RuntimeError,
- "_datetimestring is not returning a length 4 tuple"\
- " and an integer");
- return NULL;
- }
-
- /* Create new timedelta or datetime dtype */
- if (PyObject_IsTrue(datetime)) {
- new = PyArray_DescrNewFromType(PyArray_DATETIME);
- }
- else {
- new = PyArray_DescrNewFromType(PyArray_TIMEDELTA);
- }
-
- if (new == NULL) {
- return NULL;
- }
- /*
- * Remove any reference to old metadata dictionary
- * And create a new one for this new dtype
- */
- Py_XDECREF(new->metadata);
- if ((new->metadata = PyDict_New()) == NULL) {
- return NULL;
- }
- dt_cobj = _convert_datetime_tuple_to_cobj(dt_tuple);
- if (dt_cobj == NULL) {
- /* Failure in conversion */
- Py_DECREF(new);
- return NULL;
- }
-
- /* Assume this sets a new reference to dt_cobj */
- PyDict_SetItemString(new->metadata, NPY_METADATA_DTSTR, dt_cobj);
- Py_DECREF(dt_cobj);
- return new;
-}
-
-
-static PyArray_Descr *
-_convert_from_datetime(PyObject *obj)
-{
- PyObject *tupleobj;
- PyArray_Descr *res;
- PyObject *_numpy_internal;
-
- if (!PyBytes_Check(obj)) {
- return NULL;
- }
- _numpy_internal = PyImport_ImportModule("numpy.core._internal");
- if (_numpy_internal == NULL) {
- return NULL;
- }
- tupleobj = PyObject_CallMethod(_numpy_internal,
- "_datetimestring", "O", obj);
- Py_DECREF(_numpy_internal);
- if (!tupleobj) {
- return NULL;
- }
- /*
- * tuple of a standard tuple (baseunit, num, den, events) and a timedelta
- * boolean
- */
- res = _convert_from_datetime_tuple(tupleobj);
- Py_DECREF(tupleobj);
- if (!res && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_ValueError,
- "invalid data-type");
- return NULL;
- }
- return res;
-}
-
-
/*
* comma-separated string
* this is the format developed by the numarray records module and implemented
@@ -892,7 +611,7 @@
new->names = conv->names;
Py_XINCREF(new->names);
}
- new->flags = conv->flags;
+ new->hasobject = conv->hasobject;
Py_DECREF(conv);
*errflag = 0;
return new;
@@ -1092,7 +811,7 @@
if ((ret == PY_FAIL) || (newdescr->elsize == 0)) {
goto fail;
}
- dtypeflags |= (newdescr->flags & NPY_FROM_FIELDS);
+ dtypeflags |= (newdescr->hasobject & NPY_FROM_FIELDS);
totalsize += newdescr->elsize;
}
@@ -1115,7 +834,7 @@
}
new->names = names;
new->fields = fields;
- new->flags = dtypeflags;
+ new->hasobject = dtypeflags;
metadata = PyDict_GetItemString(obj, "metadata");
@@ -1277,14 +996,7 @@
if (len <= 0) {
goto fail;
}
- /* check for datetime format */
- if ((len > 1) && _check_for_datetime(type, len)) {
- *at = _convert_from_datetime(obj);
- if (*at) {
- return PY_SUCCEED;
- }
- return PY_FAIL;
- }
+
/* check for commas present or first (or second) element a digit */
if (_check_for_commastring(type, len)) {
*at = _convert_from_commastring(obj, 0);
@@ -1529,7 +1241,7 @@
{"alignment",
T_INT, offsetof(PyArray_Descr, alignment), READONLY, NULL},
{"flags",
- T_INT, offsetof(PyArray_Descr, flags), READONLY, NULL},
+ T_UBYTE, offsetof(PyArray_Descr, hasobject), READONLY, NULL},
{NULL, 0, 0, 0, NULL},
};
@@ -1544,48 +1256,7 @@
(PyObject *)self->subarray->base, self->subarray->shape);
}
-static PyObject *
-_append_to_datetime_typestr(PyArray_Descr *self, PyObject *ret)
-{
- PyObject *tmp;
- PyObject *res;
- int num, den, events;
- char *basestr;
- PyArray_DatetimeMetaData *dt_data;
- /* This shouldn't happen */
- if (self->metadata == NULL) {
- return ret;
- }
- tmp = PyDict_GetItemString(self->metadata, NPY_METADATA_DTSTR);
- dt_data = NpyCapsule_AsVoidPtr(tmp);
- num = dt_data->num;
- den = dt_data->den;
- events = dt_data->events;
- basestr = _datetime_strings[dt_data->base];
-
- if (num == 1) {
- tmp = PyUString_FromString(basestr);
- }
- else {
- tmp = PyUString_FromFormat("%d%s", num, basestr);
- }
- if (den != 1) {
- res = PyUString_FromFormat("/%d", den);
- PyUString_ConcatAndDel(&tmp, res);
- }
-
- res = PyUString_FromString("[");
- PyUString_ConcatAndDel(&res, tmp);
- PyUString_ConcatAndDel(&res, PyUString_FromString("]"));
- if (events != 1) {
- tmp = PyUString_FromFormat("//%d", events);
- PyUString_ConcatAndDel(&res, tmp);
- }
- PyUString_ConcatAndDel(&ret, res);
- return ret;
-}
-
NPY_NO_EXPORT PyObject *
arraydescr_protocol_typestr_get(PyArray_Descr *self)
{
@@ -1605,9 +1276,6 @@
}
ret = PyUString_FromFormat("%c%c%d", endian, basic_, size);
- if (PyDataType_ISDATETIME(self)) {
- ret = _append_to_datetime_typestr(self, ret);
- }
return ret;
}
@@ -1648,9 +1316,6 @@
p = PyUString_FromFormat("%d", self->elsize * 8);
PyUString_ConcatAndDel(&res, p);
}
- if (PyDataType_ISDATETIME(self)) {
- res = _append_to_datetime_typestr(self, res);
- }
return res;
}
@@ -2013,31 +1678,7 @@
return (PyObject *)conv;
}
-/*
- * Return a tuple of
- * (cleaned metadata dictionary, tuple with (str, num, events))
- */
-static PyObject *
-_get_pickleabletype_from_metadata(PyObject *metadata)
-{
- PyObject *newdict;
- PyObject *newtup, *dt_tuple;
- PyObject *cobj;
- newdict = PyDict_Copy(metadata);
- PyDict_DelItemString(newdict, NPY_METADATA_DTSTR);
- newtup = PyTuple_New(2);
- PyTuple_SET_ITEM(newtup, 0, newdict);
-
- cobj = PyDict_GetItemString(metadata, NPY_METADATA_DTSTR);
- dt_tuple = _get_datetime_tuple_from_cobj(cobj);
-
- PyTuple_SET_ITEM(newtup, 1, dt_tuple);
-
- return newtup;
-}
-
-
/* return a tuple of (callable object, args, state). */
static PyObject *
arraydescr_reduce(PyArray_Descr *self, PyObject *NPY_UNUSED(args))
@@ -2098,20 +1739,8 @@
if (self->metadata) {
state = PyTuple_New(9);
PyTuple_SET_ITEM(state, 0, PyInt_FromLong(version));
- if (PyDataType_ISDATETIME(self)) {
- PyObject *newobj;
- /* Handle CObject in NPY_METADATA_DTSTR key separately */
- /*
- * newobj is a tuple of cleaned metadata dictionary
- * and tuple of date_time info (str, num, den, events)
- */
- newobj = _get_pickleabletype_from_metadata(self->metadata);
- PyTuple_SET_ITEM(state, 8, newobj);
- }
- else {
- Py_INCREF(self->metadata);
- PyTuple_SET_ITEM(state, 8, self->metadata);
- }
+ Py_INCREF(self->metadata);
+ PyTuple_SET_ITEM(state, 8, self->metadata);
}
else { /* Use version 3 pickle format */
state = PyTuple_New(8);
@@ -2144,7 +1773,7 @@
}
PyTuple_SET_ITEM(state, 5, PyInt_FromLong(elsize));
PyTuple_SET_ITEM(state, 6, PyInt_FromLong(alignment));
- PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->flags));
+ PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->hasobject));
PyTuple_SET_ITEM(ret, 2, state);
return ret;
@@ -2157,7 +1786,7 @@
static int
_descr_find_object(PyArray_Descr *self)
{
- if (self->flags
+ if (self->hasobject
|| self->type_num == PyArray_OBJECT
|| self->kind == 'O') {
return NPY_OBJECT_DTYPE_FLAGS;
@@ -2177,7 +1806,7 @@
return 0;
}
if (_descr_find_object(new)) {
- new->flags = NPY_OBJECT_DTYPE_FLAGS;
+ new->hasobject = NPY_OBJECT_DTYPE_FLAGS;
return NPY_OBJECT_DTYPE_FLAGS;
}
}
@@ -2361,33 +1990,22 @@
self->alignment = alignment;
}
- self->flags = dtypeflags;
+ self->hasobject = dtypeflags;
if (version < 3) {
- self->flags = _descr_find_object(self);
+ self->hasobject = _descr_find_object(self);
}
Py_XDECREF(self->metadata);
- if (PyDataType_ISDATETIME(self)
- && (metadata != Py_None)
- && (metadata != NULL)) {
- PyObject *cobj;
- self->metadata = PyTuple_GET_ITEM(metadata, 0);
- Py_INCREF(self->metadata);
- cobj = _convert_datetime_tuple_to_cobj(PyTuple_GET_ITEM(metadata, 1));
- PyDict_SetItemString(self->metadata, NPY_METADATA_DTSTR, cobj);
- Py_DECREF(cobj);
+
+ /*
+ * We have a borrowed reference to metadata so no need
+ * to alter reference count
+ */
+ if (metadata == Py_None) {
+ metadata = NULL;
}
- else {
- /*
- * We have a borrowed reference to metadata so no need
- * to alter reference count
- */
- if (metadata == Py_None) {
- metadata = NULL;
- }
- self->metadata = metadata;
- Py_XINCREF(metadata);
- }
+ self->metadata = metadata;
+ Py_XINCREF(metadata);
Py_INCREF(Py_None);
return Py_None;
Modified: branches/1.5.x/numpy/core/src/multiarray/hashdescr.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/hashdescr.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/hashdescr.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -53,11 +53,11 @@
PyObject *t, *item;
/*
- * For builtin type, hash relies on : kind + byteorder + flags +
+ * For builtin type, hash relies on : kind + byteorder + hasobject +
* type_num + elsize + alignment
*/
- t = Py_BuildValue("(cciiii)", descr->kind, descr->byteorder,
- descr->flags, descr->type_num, descr->elsize,
+ t = Py_BuildValue("(ccciii)", descr->kind, descr->byteorder,
+ descr->hasobject, descr->type_num, descr->elsize,
descr->alignment);
for(i = 0; i < PyTuple_Size(t); ++i) {
Modified: branches/1.5.x/numpy/core/src/multiarray/multiarraymodule.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/multiarraymodule.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/multiarraymodule.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -43,6 +43,8 @@
#include "scalartypes.h"
#include "numpymemoryview.h"
+NPY_NO_EXPORT PyTypeObject PyBigArray_Type;
+
/*NUMPY_API
* Get Priority from object
*/
@@ -1328,40 +1330,7 @@
return same;
}
-/*
- * compare the metadata for two date-times
- * return 1 if they are the same
- * or 0 if not
- */
-static int
-_equivalent_units(PyObject *meta1, PyObject *meta2)
-{
- PyObject *cobj1, *cobj2;
- PyArray_DatetimeMetaData *data1, *data2;
- /* Same meta object */
- if (meta1 == meta2) {
- return 1;
- }
-
- cobj1 = PyDict_GetItemString(meta1, NPY_METADATA_DTSTR);
- cobj2 = PyDict_GetItemString(meta2, NPY_METADATA_DTSTR);
- if (cobj1 == cobj2) {
- return 1;
- }
-
-/* FIXME
- * There is no err handling here.
- */
- data1 = NpyCapsule_AsVoidPtr(cobj1);
- data2 = NpyCapsule_AsVoidPtr(cobj2);
- return ((data1->base == data2->base)
- && (data1->num == data2->num)
- && (data1->den == data2->den)
- && (data1->events == data2->events));
-}
-
-
/*NUMPY_API
*
* This function returns true if the two typecodes are
@@ -1386,13 +1355,7 @@
return ((typenum1 == typenum2)
&& _equivalent_fields(typ1->fields, typ2->fields));
}
- if (typenum1 == PyArray_DATETIME
- || typenum1 == PyArray_DATETIME
- || typenum2 == PyArray_TIMEDELTA
- || typenum2 == PyArray_TIMEDELTA) {
- return ((typenum1 == typenum2)
- && _equivalent_units(typ1->metadata, typ2->metadata));
- }
+
return typ1->kind == typ2->kind;
}
@@ -2012,40 +1975,7 @@
return oldops;
}
-static PyObject *
-array_set_datetimeparse_function(PyObject *NPY_UNUSED(self), PyObject *args,
- PyObject *kwds)
-{
- PyObject *op = NULL;
- static char *kwlist[] = {"f", NULL};
- PyObject *_numpy_internal;
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &op)) {
- return NULL;
- }
- /* reset the array_repr function to built-in */
- if (op == Py_None) {
- _numpy_internal = PyImport_ImportModule("numpy.core._internal");
- if (_numpy_internal == NULL) {
- return NULL;
- }
- op = PyObject_GetAttrString(_numpy_internal, "datetime_from_string");
- }
- else { /* Must balance reference count increment in both branches */
- if (!PyCallable_Check(op)) {
- PyErr_SetString(PyExc_TypeError,
- "Argument must be callable.");
- return NULL;
- }
- Py_INCREF(op);
- }
- PyArray_SetDatetimeParseFunction(op);
- Py_DECREF(op);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-
/*NUMPY_API
* Where
*/
@@ -2684,9 +2614,6 @@
{"set_numeric_ops",
(PyCFunction)array_set_ops_function,
METH_VARARGS|METH_KEYWORDS, NULL},
- {"set_datetimeparse_function",
- (PyCFunction)array_set_datetimeparse_function,
- METH_VARARGS|METH_KEYWORDS, NULL},
{"set_typeDict",
(PyCFunction)array_set_typeDict,
METH_VARARGS, NULL},
@@ -2891,10 +2818,6 @@
SINGLE_INHERIT(LongLong, SignedInteger);
#endif
- SINGLE_INHERIT(TimeInteger, SignedInteger);
- SINGLE_INHERIT(Datetime, TimeInteger);
- SINGLE_INHERIT(Timedelta, TimeInteger);
-
/*
fprintf(stderr,
"tp_free = %p, PyObject_Del = %p, int_tp_free = %p, base.tp_free = %p\n",
@@ -3084,13 +3007,6 @@
PyDict_SetItemString(d, "METADATA_DTSTR", s);
Py_DECREF(s);
-/* FIXME
- * There is no error handling here
- */
- s = NpyCapsule_FromVoidPtr((void *)_datetime_strings, NULL);
- PyDict_SetItemString(d, "DATETIMEUNITS", s);
- Py_DECREF(s);
-
#define ADDCONST(NAME) \
s = PyInt_FromLong(NPY_##NAME); \
PyDict_SetItemString(d, #NAME, s); \
Modified: branches/1.5.x/numpy/core/src/multiarray/multiarraymodule_onefile.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/multiarraymodule_onefile.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/multiarraymodule_onefile.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -10,7 +10,6 @@
#include "scalartypes.c"
#include "scalarapi.c"
-#include "datetime.c"
#include "arraytypes.c"
#include "hashdescr.c"
Modified: branches/1.5.x/numpy/core/src/multiarray/scalarapi.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/scalarapi.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/scalarapi.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -64,8 +64,6 @@
CASE(CDOUBLE, CDouble);
CASE(CLONGDOUBLE, CLongDouble);
CASE(OBJECT, Object);
- CASE(DATETIME, Datetime);
- CASE(TIMEDELTA, Timedelta);
#undef CASE
case NPY_STRING:
return (void *)PyString_AS_STRING(scalar);
@@ -93,10 +91,6 @@
_IFCASE(Int);
_IFCASE(Long);
_IFCASE(LongLong);
- if _CHK(TimeInteger) {
- _IFCASE(Datetime);
- _IFCASE(Timedelta);
- }
}
else {
/* Unsigned Integer */
@@ -516,42 +510,6 @@
return descr;
}
- if (PyArray_IsScalar(sc, TimeInteger)) {
- PyObject *cobj;
- PyArray_DatetimeMetaData *dt_data;
-
- dt_data = _pya_malloc(sizeof(PyArray_DatetimeMetaData));
- if (PyArray_IsScalar(sc, Datetime)) {
- descr = PyArray_DescrNewFromType(PyArray_DATETIME);
- memcpy(dt_data, &((PyDatetimeScalarObject *)sc)->obmeta,
- sizeof(PyArray_DatetimeMetaData));
- }
- else {
- /* Timedelta */
- descr = PyArray_DescrNewFromType(PyArray_TIMEDELTA);
- memcpy(dt_data, &((PyTimedeltaScalarObject *)sc)->obmeta,
- sizeof(PyArray_DatetimeMetaData));
- }
- cobj = NpyCapsule_FromVoidPtr((void *)dt_data, simple_capsule_dtor);
-
- /* Add correct meta-data to the data-type */
- if (descr == NULL) {
- Py_DECREF(cobj);
- return NULL;
- }
- Py_XDECREF(descr->metadata);
- if ((descr->metadata = PyDict_New()) == NULL) {
- Py_DECREF(descr);
- Py_DECREF(cobj);
- return NULL;
- }
-
- /* Assume this sets a new reference to cobj */
- PyDict_SetItemString(descr->metadata, NPY_METADATA_DTSTR, cobj);
- Py_DECREF(cobj);
- return descr;
- }
-
descr = PyArray_DescrFromTypeObject((PyObject *)Py_TYPE(sc));
if (descr->elsize == 0) {
PyArray_DESCR_REPLACE(descr);
@@ -656,22 +614,6 @@
if (obj == NULL) {
return NULL;
}
- if (PyTypeNum_ISDATETIME(type_num)) {
- /*
- * We need to copy the resolution information over to the scalar
- * Get the void * from the metadata dictionary
- */
- PyObject *cobj;
- PyArray_DatetimeMetaData *dt_data;
- cobj = PyDict_GetItemString(descr->metadata, NPY_METADATA_DTSTR);
-
-/* FIXME
- * There is no error handling here.
- */
- dt_data = NpyCapsule_AsVoidPtr(cobj);
- memcpy(&(((PyDatetimeScalarObject *)obj)->obmeta), dt_data,
- sizeof(PyArray_DatetimeMetaData));
- }
if (PyTypeNum_ISFLEXIBLE(type_num)) {
if (type_num == PyArray_STRING) {
destptr = PyString_AS_STRING(obj);
Modified: branches/1.5.x/numpy/core/src/multiarray/scalartypes.c.src
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/scalartypes.c.src 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/multiarray/scalartypes.c.src 2010-07-17 18:31:17 UTC (rev 8495)
@@ -2091,12 +2091,12 @@
/**begin repeat
* #name = byte, short, int, long, longlong, ubyte, ushort, uint, ulong,
* ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble,
- * string, unicode, object, datetime, timedelta#
+ * string, unicode, object#
* #TYPE = BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG,
* ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE,
- * STRING, UNICODE, OBJECT, DATETIME, TIMEDELTA#
- * #work = 0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,z,z,0,0,0#
- * #default = 0*16,1*2,2,0*2#
+ * STRING, UNICODE, OBJECT#
+ * #work = 0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,z,z,0#
+ * #default = 0*16,1*2,2#
*/
#define _NPY_UNUSED2_1
@@ -2518,49 +2518,6 @@
/**end repeat**/
-/**begin repeat
- * #lname=datetime, timedelta#
- * #name=Datetime,Timedelta#
- */
-#if SIZEOF_LONG==SIZEOF_DATETIME
-static long
- at lname@_arrtype_hash(PyObject *obj)
-{
- long x = (long)(((Py at name@ScalarObject *)obj)->obval);
- if (x == -1) {
- x = -2;
- }
- return x;
-}
-#elif SIZEOF_LONGLONG==SIZEOF_DATETIME
-static long
- at lname@_arrtype_hash(PyObject *obj)
-{
- long y;
- longlong x = (((Py at name@ScalarObject *)obj)->obval);
-
- if ((x <= LONG_MAX)) {
- y = (long) x;
- }
- else {
- union Mask {
- long hashvals[2];
- longlong v;
- } both;
-
- both.v = x;
- y = both.hashvals[0] + (1000003)*both.hashvals[1];
- }
- if (y == -1) {
- y = -2;
- }
- return y;
-}
-#endif
-/**end repeat**/
-
-
-
/* Wrong thing to do for longdouble, but....*/
/**begin repeat
@@ -3031,10 +2988,9 @@
/**begin repeat
* #NAME = Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong,
- * ULongLong, Float, Double, LongDouble, Datetime, Timedelta#
- * #name = int*5, uint*5, float*3, datetime, timedelta#
- * #CNAME = (CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE,
- * DATETIME, TIMEDELTA#
+ * ULongLong, Float, Double, LongDouble#
+ * #name = int*5, uint*5, float*3#
+ * #CNAME = (CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE#
*/
#if BITSOF_ at CNAME@ == 8
#define _THIS_SIZE "8"
@@ -3286,10 +3242,10 @@
/**begin repeat
* #name = bool, byte, short, int, long, longlong, ubyte, ushort, uint,
* ulong, ulonglong, float, double, longdouble, cfloat, cdouble,
- * clongdouble, string, unicode, void, object, datetime, timedelta#
+ * clongdouble, string, unicode, void, object#
* #NAME = Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt,
* ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble,
- * CLongDouble, String, Unicode, Void, Object, Datetime, Timedelta#
+ * CLongDouble, String, Unicode, Void, Object#
*/
Py at NAME@ArrType_Type.tp_flags = BASEFLAGS;
Py at NAME@ArrType_Type.tp_new = @name at _arrtype_new;
@@ -3298,11 +3254,9 @@
/**begin repeat
* #name = bool, byte, short, ubyte, ushort, uint, ulong, ulonglong,
- * float, longdouble, cfloat, clongdouble, void, object, datetime,
- * timedelta#
+ * float, longdouble, cfloat, clongdouble, void, object#
* #NAME = Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong,
- * Float, LongDouble, CFloat, CLongDouble, Void, Object, Datetime,
- * Timedelta#
+ * Float, LongDouble, CFloat, CLongDouble, Void, Object#
*/
Py at NAME@ArrType_Type.tp_hash = @name at _arrtype_hash;
/**end repeat**/
@@ -3393,8 +3347,6 @@
&PyCFloatArrType_Type,
&PyCDoubleArrType_Type,
&PyCLongDoubleArrType_Type,
- &PyDatetimeArrType_Type,
- &PyTimedeltaArrType_Type,
&PyObjectArrType_Type,
&PyStringArrType_Type,
&PyUnicodeArrType_Type,
Modified: branches/1.5.x/numpy/core/src/umath/loops.c.src
===================================================================
--- branches/1.5.x/numpy/core/src/umath/loops.c.src 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/umath/loops.c.src 2010-07-17 18:31:17 UTC (rev 8495)
@@ -849,170 +849,7 @@
/**end repeat**/
-/*
- *****************************************************************************
- ** DATETIME LOOPS **
- *****************************************************************************
- */
-/**begin repeat
- * #type = datetime, timedelta#
- * #TYPE = DATETIME, TIMEDELTA#
- * #ftype = double, double#
- */
-
-NPY_NO_EXPORT void
- at TYPE@_ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data))
-{
- OUTPUT_LOOP {
- *((@type@ *)op1) = 1;
- }
-}
-
-NPY_NO_EXPORT void
- at TYPE@_negative(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- UNARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- *((@type@ *)op1) = (@type@)(-(@type@)in1);
- }
-}
-
-NPY_NO_EXPORT void
- at TYPE@_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- UNARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- *((Bool *)op1) = !in1;
- }
-}
-
-
-/**begin repeat1
- * #kind = equal, not_equal, greater, greater_equal, less, less_equal,
- * logical_and, logical_or#
- * #OP = ==, !=, >, >=, <, <=, &&, ||#
- */
-NPY_NO_EXPORT void
- at TYPE@_ at kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- const @type@ in2 = *(@type@ *)ip2;
- *((Bool *)op1) = in1 @OP@ in2;
- }
-}
-/**end repeat1**/
-
-NPY_NO_EXPORT void
- at TYPE@_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- const @type@ in2 = *(@type@ *)ip2;
- *((Bool *)op1)= (in1 && !in2) || (!in1 && in2);
- }
-}
-
-/**begin repeat1
- * #kind = maximum, minimum#
- * #OP = >, <#
- **/
-NPY_NO_EXPORT void
- at TYPE@_ at kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- const @type@ in2 = *(@type@ *)ip2;
- *((@type@ *)op1) = (in1 @OP@ in2) ? in1 : in2;
- }
-}
-/**end repeat1**/
-
-NPY_NO_EXPORT void
- at TYPE@_absolute(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- UNARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- *((@type@ *)op1) = (in1 >= 0) ? in1 : -in1;
- }
-}
-
-NPY_NO_EXPORT void
- at TYPE@_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- UNARY_LOOP {
- const @type@ in1 = *(@type@ *)ip1;
- *((@type@ *)op1) = in1 > 0 ? 1 : (in1 < 0 ? -1 : 0);
- }
-}
-
-/**end repeat**/
-
-/* FIXME: implement the following correctly using the metadata: data is the
- sequence of ndarrays in the same order as args.
- */
-NPY_NO_EXPORT void
-DATETIME_Mm_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data))
-{
- BINARY_LOOP {
- const datetime in1 = *(datetime *)ip1;
- const timedelta in2 = *(timedelta *)ip2;
- *((datetime *)op1) = in1 + in2;
- }
-}
-
-NPY_NO_EXPORT void
-DATETIME_mM_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const timedelta in1 = *(timedelta *)ip1;
- const datetime in2 = *(datetime *)ip2;
- *((datetime *)op1) = in1 + in2;
- }
-}
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const timedelta in1 = *(timedelta *)ip1;
- const timedelta in2 = *(timedelta *)ip2;
- *((timedelta *)op1) = in1 + in2;
- }
-}
-
-NPY_NO_EXPORT void
-DATETIME_Mm_M_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const datetime in1 = *(datetime *)ip1;
- const timedelta in2 = *(timedelta *)ip2;
- *((datetime *)op1) = in1 - in2;
- }
-}
-
-NPY_NO_EXPORT void
-DATETIME_MM_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const datetime in1 = *(datetime *)ip1;
- const datetime in2 = *(datetime *)ip2;
- *((timedelta *)op1) = in1 - in2;
- }
-}
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
-{
- BINARY_LOOP {
- const timedelta in1 = *(timedelta *)ip1;
- const timedelta in2 = *(timedelta *)ip2;
- *((timedelta *)op1) = in1 - in2;
- }
-}
-
-
/*
*****************************************************************************
** FLOAT LOOPS **
Modified: branches/1.5.x/numpy/core/src/umath/loops.h
===================================================================
--- branches/1.5.x/numpy/core/src/umath/loops.h 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/umath/loops.h 2010-07-17 18:31:17 UTC (rev 8495)
@@ -2355,179 +2355,34 @@
#undef CEQ
#undef CNE
-/*
- *****************************************************************************
- ** DATETIME LOOPS **
- *****************************************************************************
- */
-#line 406
-#define DATETIME_fmax DATETIME_maximum
-#define DATETIME_fmin DATETIME_minimum
-
-#line 406
-#define TIMEDELTA_fmax TIMEDELTA_maximum
-#define TIMEDELTA_fmin TIMEDELTA_minimum
-
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_absolute(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_absolute(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_logical_and(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_logical_and(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_logical_or(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_logical_or(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_maximum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_maximum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_minimum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_minimum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_negative(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_negative(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-#line 415
-NPY_NO_EXPORT void
-DATETIME_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-
-NPY_NO_EXPORT void
-DATETIME_Mm_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_mM_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_Mm_M_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_MM_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
/*
*****************************************************************************
** OBJECT LOOPS **
*****************************************************************************
*/
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-#line 450
+#line 407
NPY_NO_EXPORT void
OBJECT_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
Modified: branches/1.5.x/numpy/core/src/umath/loops.h.src
===================================================================
--- branches/1.5.x/numpy/core/src/umath/loops.h.src 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/umath/loops.h.src 2010-07-17 18:31:17 UTC (rev 8495)
@@ -396,49 +396,6 @@
/*
*****************************************************************************
- ** DATETIME LOOPS **
- *****************************************************************************
- */
-
-/**begin repeat
- * #TYPE = DATETIME, TIMEDELTA#
- */
-#define @TYPE at _fmax @TYPE at _maximum
-#define @TYPE at _fmin @TYPE at _minimum
-/**end repeat**/
-
-/**begin repeat
- * #kind = equal, not_equal, greater, greater_equal, less, less_equal,
- * absolute, logical_and, logical_not, logical_or, logical_xor, maximum,
- * minimum, negative, ones_like, sign#
- */
-NPY_NO_EXPORT void
-DATETIME_ at kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_ at kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-/**end repeat**/
-
-NPY_NO_EXPORT void
-DATETIME_Mm_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_mM_M_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_Mm_M_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-DATETIME_MM_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_add(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-NPY_NO_EXPORT void
-TIMEDELTA_mm_m_subtract(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func));
-
-/*
- *****************************************************************************
** OBJECT LOOPS **
*****************************************************************************
*/
Modified: branches/1.5.x/numpy/core/src/umath/ufunc_object.c
===================================================================
--- branches/1.5.x/numpy/core/src/umath/ufunc_object.c 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/src/umath/ufunc_object.c 2010-07-17 18:31:17 UTC (rev 8495)
@@ -215,8 +215,6 @@
case PyArray_INT:
case PyArray_LONG:
case PyArray_LONGLONG:
- case PyArray_DATETIME:
- case PyArray_TIMEDELTA:
return PyArray_BYTE;
/* case PyArray_UBYTE */
case PyArray_USHORT:
@@ -1541,13 +1539,6 @@
|| (arg_types[i] == PyArray_OBJECT))) {
loop->obj = UFUNC_OBJ_ISOBJECT|UFUNC_OBJ_NEEDS_API;
}
- if (!(loop->obj & UFUNC_OBJ_NEEDS_API)
- && ((mps[i]->descr->type_num == PyArray_DATETIME)
- || (mps[i]->descr->type_num == PyArray_TIMEDELTA)
- || (arg_types[i] == PyArray_DATETIME)
- || (arg_types[i] == PyArray_TIMEDELTA))) {
- loop->obj = UFUNC_OBJ_NEEDS_API;
- }
}
if (self->core_enabled && (loop->obj & UFUNC_OBJ_ISOBJECT)) {
@@ -2504,13 +2495,6 @@
if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT) {
loop->obj = UFUNC_OBJ_ISOBJECT | UFUNC_OBJ_NEEDS_API;
}
- else if ((otype == PyArray_DATETIME)
- || (aar->descr->type_num == PyArray_DATETIME)
- || (otype == PyArray_TIMEDELTA)
- || (aar->descr->type_num == PyArray_TIMEDELTA))
- {
- loop->obj = UFUNC_OBJ_NEEDS_API;
- }
else {
loop->obj = 0;
}
Modified: branches/1.5.x/numpy/core/tests/test_regression.py
===================================================================
--- branches/1.5.x/numpy/core/tests/test_regression.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/core/tests/test_regression.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -1304,8 +1304,7 @@
def test_ticket_1539(self):
dtypes = [x for x in np.typeDict.values()
- if (issubclass(x, np.number)
- and not issubclass(x, np.timeinteger))]
+ if issubclass(x, np.number)]
a = np.array([], dtypes[0])
failures = []
for x in dtypes:
Modified: branches/1.5.x/numpy/f2py/__version__.py
===================================================================
--- branches/1.5.x/numpy/f2py/__version__.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/f2py/__version__.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -1,4 +1,4 @@
-major = 2
+major = 1
try:
from __svn_version__ import version
Modified: branches/1.5.x/numpy/lib/tests/test_type_check.py
===================================================================
--- branches/1.5.x/numpy/lib/tests/test_type_check.py 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/lib/tests/test_type_check.py 2010-07-17 18:31:17 UTC (rev 8495)
@@ -376,12 +376,5 @@
assert issubdtype(a.dtype,float)
-class TestDateTimeData:
-
- def test_basic(self):
- a = array(['1980-03-23'], dtype=datetime64)
- assert_equal(datetime_data(a.dtype), (asbytes('us'), 1, 1, 1))
-
-
if __name__ == "__main__":
run_module_suite()
Modified: branches/1.5.x/numpy/random/mtrand/numpy.pxi
===================================================================
--- branches/1.5.x/numpy/random/mtrand/numpy.pxi 2010-07-17 18:18:25 UTC (rev 8494)
+++ branches/1.5.x/numpy/random/mtrand/numpy.pxi 2010-07-17 18:31:17 UTC (rev 8495)
@@ -73,7 +73,7 @@
ctypedef extern class numpy.dtype [object PyArray_Descr]:
cdef int type_num, elsize, alignment
- cdef char type, kind, byteorder, flags
+ cdef char type, kind, byteorder, hasobject
cdef object fields, typeobj
ctypedef extern class numpy.ndarray [object PyArrayObject]:
More information about the Numpy-svn
mailing list