From 159ef14fb9e198bb0066ea14e6b980f065de63dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Tue, 31 Jul 2018 16:22:25 +0200 Subject: New upstream version 0.8.0+dfsg --- silx/gui/data/TextFormatter.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'silx/gui/data/TextFormatter.py') diff --git a/silx/gui/data/TextFormatter.py b/silx/gui/data/TextFormatter.py index 332625c..8440509 100644 --- a/silx/gui/data/TextFormatter.py +++ b/silx/gui/data/TextFormatter.py @@ -27,7 +27,7 @@ data module to format data as text in the same way.""" __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "13/12/2017" +__date__ = "25/06/2018" import numpy import numbers @@ -204,7 +204,7 @@ class TextFormatter(qt.QObject): def __formatBinary(self, data): if isinstance(data, numpy.void): if six.PY2: - data = [ord(d) for d in data.item()] + data = [ord(d) for d in data.data] else: data = data.item().astype(numpy.uint8) elif six.PY2: @@ -266,6 +266,8 @@ class TextFormatter(qt.QObject): elif vlen == six.binary_type: # HDF5 ASCII return self.__formatCharString(data) + elif isinstance(vlen, numpy.dtype): + return self.toString(data, vlen) return None def toString(self, data, dtype=None): @@ -291,11 +293,17 @@ class TextFormatter(qt.QObject): else: text = [self.toString(d, dtype) for d in data] return "[" + " ".join(text) + "]" + if dtype is not None and dtype.kind == 'O': + text = self.__formatH5pyObject(data, dtype) + if text is not None: + return text elif isinstance(data, numpy.void): if dtype is None: dtype = data.dtype - if data.dtype.fields is not None: - text = [self.toString(data[f], dtype) for f in dtype.fields] + if dtype.fields is not None: + text = [] + for index, field in enumerate(dtype.fields.items()): + text.append(field[0] + ":" + self.toString(data[index], field[1][0])) return "(" + " ".join(text) + ")" return self.__formatBinary(data) elif isinstance(data, (numpy.unicode_, six.text_type)): @@ -340,7 +348,7 @@ class TextFormatter(qt.QObject): elif isinstance(data, (numbers.Real, numpy.floating)): # It have to be done before complex checking return self.__floatFormat % data - elif isinstance(data, (numpy.complex_, numbers.Complex)): + elif isinstance(data, (numpy.complexfloating, numbers.Complex)): text = "" if data.real != 0: text += self.__floatFormat % data.real -- cgit v1.2.3