@@ -210,7 +210,6 @@ typedef enum {
210
210
211
211
/* For specifying allowed casting in operations which support it */
212
212
typedef enum {
213
- _NPY_ERROR_OCCURRED_IN_CAST = -1 ,
214
213
/* Only allow identical types */
215
214
NPY_NO_CASTING = 0 ,
216
215
/* Allow identical and byte swapped types */
@@ -220,14 +219,7 @@ typedef enum {
220
219
/* Allow safe casts or casts within the same kind */
221
220
NPY_SAME_KIND_CASTING = 3 ,
222
221
/* Allow any casts */
223
- NPY_UNSAFE_CASTING = 4 ,
224
- /*
225
- * Flag to allow signalling that a cast is a view, this flag is not
226
- * valid when requesting a cast of specific safety.
227
- * _NPY_CAST_IS_VIEW|NPY_EQUIV_CASTING means the same as NPY_NO_CASTING.
228
- */
229
- // TODO-DTYPES: Needs to be documented.
230
- _NPY_CAST_IS_VIEW = 1 << 16 ,
222
+ NPY_UNSAFE_CASTING = 4
231
223
} NPY_CASTING ;
232
224
233
225
typedef enum {
@@ -349,6 +341,9 @@ struct NpyAuxData_tag {
349
341
#define NPY_ERR (str ) fprintf(stderr, #str); fflush(stderr);
350
342
#define NPY_ERR2 (str ) fprintf(stderr, str); fflush(stderr);
351
343
344
+ #define NPY_STRINGIFY (x ) #x
345
+ #define NPY_TOSTRING (x ) NPY_STRINGIFY(x)
346
+
352
347
/*
353
348
* Macros to define how array, and dimension/strides data is
354
349
* allocated.
@@ -709,7 +704,6 @@ typedef struct tagPyArrayObject_fields {
709
704
int flags ;
710
705
/* For weak references */
711
706
PyObject * weakreflist ;
712
- void * _buffer_info ; /* private buffer info, tagged to allow warning */
713
707
} PyArrayObject_fields ;
714
708
715
709
/*
@@ -729,18 +723,7 @@ typedef struct tagPyArrayObject {
729
723
} PyArrayObject ;
730
724
#endif
731
725
732
- /*
733
- * Removed 2020-Nov-25, NumPy 1.20
734
- * #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
735
- *
736
- * The above macro was removed as it gave a false sense of a stable ABI
737
- * with respect to the structures size. If you require a runtime constant,
738
- * you can use `PyArray_Type.tp_basicsize` instead. Otherwise, please
739
- * see the PyArrayObject documentation or ask the NumPy developers for
740
- * information on how to correctly replace the macro in a way that is
741
- * compatible with multiple NumPy versions.
742
- */
743
-
726
+ #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
744
727
745
728
/* Array Flags Object */
746
729
typedef struct PyArrayFlagsObject {
@@ -1567,15 +1550,11 @@ PyArray_GETITEM(const PyArrayObject *arr, const char *itemptr)
1567
1550
(void * )itemptr , (PyArrayObject * )arr );
1568
1551
}
1569
1552
1570
- /*
1571
- * SETITEM should only be used if it is known that the value is a scalar
1572
- * and of a type understood by the arrays dtype.
1573
- * Use `PyArray_Pack` if the value may be of a different dtype.
1574
- */
1575
1553
static NPY_INLINE int
1576
1554
PyArray_SETITEM (PyArrayObject * arr , char * itemptr , PyObject * v )
1577
1555
{
1578
- return ((PyArrayObject_fields * )arr )-> descr -> f -> setitem (v , itemptr , arr );
1556
+ return ((PyArrayObject_fields * )arr )-> descr -> f -> setitem (
1557
+ v , itemptr , arr );
1579
1558
}
1580
1559
1581
1560
#else
@@ -1779,8 +1758,8 @@ typedef struct {
1779
1758
} npy_stride_sort_item ;
1780
1759
1781
1760
/************************************************************
1782
- * This is the form of the struct that's stored in the
1783
- * PyCapsule returned by an array's __array_struct__ attribute . See
1761
+ * This is the form of the struct that's returned pointed by the
1762
+ * PyCObject attribute of an array __array_struct__. See
1784
1763
* https://docs.scipy.org/doc/numpy/reference/arrays.interface.html for the full
1785
1764
* documentation.
1786
1765
************************************************************/
@@ -1830,107 +1809,6 @@ typedef struct {
1830
1809
typedef void (PyDataMem_EventHookFunc )(void * inp , void * outp , size_t size ,
1831
1810
void * user_data );
1832
1811
1833
-
1834
- /*
1835
- * PyArray_DTypeMeta related definitions.
1836
- *
1837
- * As of now, this API is preliminary and will be extended as necessary.
1838
- */
1839
- #if defined(NPY_INTERNAL_BUILD ) && NPY_INTERNAL_BUILD
1840
- /*
1841
- * The Structures defined in this block are considered private API and
1842
- * may change without warning!
1843
- */
1844
- /* TODO: Make this definition public in the API, as soon as its settled */
1845
- NPY_NO_EXPORT extern PyTypeObject PyArrayDTypeMeta_Type ;
1846
-
1847
- typedef struct PyArray_DTypeMeta_tag PyArray_DTypeMeta ;
1848
-
1849
- typedef PyArray_Descr * (discover_descr_from_pyobject_function )(
1850
- PyArray_DTypeMeta * cls , PyObject * obj );
1851
-
1852
- /*
1853
- * Before making this public, we should decide whether it should pass
1854
- * the type, or allow looking at the object. A possible use-case:
1855
- * `np.array(np.array([0]), dtype=np.ndarray)`
1856
- * Could consider arrays that are not `dtype=ndarray` "scalars".
1857
- */
1858
- typedef int (is_known_scalar_type_function )(
1859
- PyArray_DTypeMeta * cls , PyTypeObject * obj );
1860
-
1861
- typedef PyArray_Descr * (default_descr_function )(PyArray_DTypeMeta * cls );
1862
- typedef PyArray_DTypeMeta * (common_dtype_function )(
1863
- PyArray_DTypeMeta * dtype1 , PyArray_DTypeMeta * dtyep2 );
1864
- typedef PyArray_Descr * (common_instance_function )(
1865
- PyArray_Descr * dtype1 , PyArray_Descr * dtyep2 );
1866
-
1867
- /*
1868
- * While NumPy DTypes would not need to be heap types the plan is to
1869
- * make DTypes available in Python at which point they will be heap types.
1870
- * Since we also wish to add fields to the DType class, this looks like
1871
- * a typical instance definition, but with PyHeapTypeObject instead of
1872
- * only the PyObject_HEAD.
1873
- * This must only be exposed very extremely careful consideration, since
1874
- * it is a fairly complex construct which may be better to allow
1875
- * refactoring of.
1876
- */
1877
- struct PyArray_DTypeMeta_tag {
1878
- PyHeapTypeObject super ;
1879
-
1880
- /*
1881
- * Most DTypes will have a singleton default instance, for the
1882
- * parametric legacy DTypes (bytes, string, void, datetime) this
1883
- * may be a pointer to the *prototype* instance?
1884
- */
1885
- PyArray_Descr * singleton ;
1886
- /*
1887
- * Is this DType created using the old API? This exists mainly to
1888
- * allow for assertions in paths specific to wrapping legacy types.
1889
- */
1890
- npy_bool legacy ;
1891
- /* The values stored by a parametric datatype depend on its instance */
1892
- npy_bool parametric ;
1893
- /* whether the DType can be instantiated (i.e. np.dtype cannot) */
1894
- npy_bool abstract ;
1895
-
1896
- /*
1897
- * The following fields replicate the most important dtype information.
1898
- * In the legacy implementation most of these are stored in the
1899
- * PyArray_Descr struct.
1900
- */
1901
- /* The type object of the scalar instances (may be NULL?) */
1902
- PyTypeObject * scalar_type ;
1903
- /* kind for this type */
1904
- char kind ;
1905
- /* unique-character representing this type */
1906
- char type ;
1907
- /* flags describing data type */
1908
- char flags ;
1909
- /* number representing this type */
1910
- int type_num ;
1911
- /*
1912
- * Point to the original ArrFuncs.
1913
- * NOTE: We could make a copy to detect changes to `f`.
1914
- */
1915
- PyArray_ArrFuncs * f ;
1916
-
1917
- /* DType methods, these could be moved into its own struct */
1918
- discover_descr_from_pyobject_function * discover_descr_from_pyobject ;
1919
- is_known_scalar_type_function * is_known_scalar_type ;
1920
- default_descr_function * default_descr ;
1921
- common_dtype_function * common_dtype ;
1922
- common_instance_function * common_instance ;
1923
- /*
1924
- * Dictionary of ArrayMethods representing most possible casts
1925
- * (structured and object are exceptions).
1926
- * This should potentially become a weak mapping in the future.
1927
- */
1928
- PyObject * castingimpls ;
1929
- };
1930
-
1931
- #endif /* NPY_INTERNAL_BUILD */
1932
-
1933
-
1934
1812
/*
1935
1813
* Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files
1936
1814
* npy_*_*_deprecated_api.h are only included from here and nowhere else.
0 commit comments