From 437373456fd0444b246b25f456b16bd6f535fbd2 Mon Sep 17 00:00:00 2001 From: Ankit Daftery Date: Fri, 5 Aug 2011 17:04:29 +0000 Subject: [PATCH] Added example for custom dtype --- libs/numpy/example/dtype.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/numpy/example/dtype.cpp b/libs/numpy/example/dtype.cpp index 33e040d4..2674ef8f 100644 --- a/libs/numpy/example/dtype.cpp +++ b/libs/numpy/example/dtype.cpp @@ -4,7 +4,7 @@ * * @todo Add an example to show type conversion. * Add an example to show use of user-defined types - * Doesn't work for char. Works for int, long int, short int, float, double + * */ #include @@ -29,5 +29,12 @@ int main(int argc, char **argv) std::cout << "Original array:\n" << p::extract(p::str(a)) << std::endl; // Print the datatype of the elements std::cout << "Datatype is:\n" << p::extract(p::str(a.get_dtype())) << std::endl ; - + // Roundabout way of creating a user defined dtype. Fix this if possible +/* + p::tuple for_custom_dtype = p::make_tuple("ha",dtype) ; + p::list list_for_dtype ; + list_for_dtype.append(for_custom_dtype) ; + np::dtype custom_dtype = np::dtype(list_for_dtype) ; + np::ndarray new_array = np::zeros(shape,z); +*/ }