summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-12-30 03:57:33 +0000
committerDavid Cournapeau <cournape@gmail.com>2008-12-30 03:57:33 +0000
commitf6f9ac09ac060d7430abf51510eb84cc4c57c08b (patch)
treef32c6d6d55d11c185118a4d4ccb705cc57ba60a6 /numpy
parent2fcb366d49db8ffbe248f30e9d25775653d24407 (diff)
downloadnumpy-f6f9ac09ac060d7430abf51510eb84cc4c57c08b.tar.gz
Start working on tp_print implementation for scalar types: add the C functions.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/scalartypes.inc.src40
1 files changed, 40 insertions, 0 deletions
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src
index 996d6be22..8b1d08254 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.inc.src
@@ -774,6 +774,46 @@ c@name@type_@kind@(PyObject *self)
/**end repeat1**/
/**end repeat**/
+/*
+ * float type print (control print a, where a is a float type instance)
+ */
+/**begin repeat
+ * #name=float, double, longdouble#
+ * #Name=Float, Double, LongDouble#
+ * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
+ */
+
+static int
+@name@type_print(PyObject *v, FILE *fp, int flags)
+{
+ char buf[100];
+ @name@ val = ((Py@Name@ScalarObject *)v)->obval;
+
+ format_@name@(buf, sizeof(buf), val,
+ (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
+ Py_BEGIN_ALLOW_THREADS
+ fputs(buf, fp);
+ Py_END_ALLOW_THREADS
+ return 0;
+}
+
+static int
+c@name@type_print(PyObject *v, FILE *fp, int flags)
+{
+ /* Size of buf: twice sizeof(real) + 2 (for the parenthesis) */
+ char buf[202];
+ c@name@ val = ((PyC@Name@ScalarObject *)v)->obval;
+
+ format_c@name@(buf, sizeof(buf), val,
+ (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
+ Py_BEGIN_ALLOW_THREADS
+ fputs(buf, fp);
+ Py_END_ALLOW_THREADS
+ return 0;
+}
+
+/**end repeat**/
+
/*
* Could improve this with a PyLong_FromLongDouble(longdouble ldval)