Skip to content

Commit

Permalink
Merge from 3.x: PR #3653
Browse files Browse the repository at this point in the history
Fixes #3638
  • Loading branch information
ccordoba12 committed Nov 21, 2016
2 parents 7776b51 + 7f80cd3 commit f834b69
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spyder/widgets/variableexplorer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ class FakeObject(object):


#==============================================================================
# Numpy arrays support
# Numpy arrays and numeric types support
#==============================================================================
try:
from numpy import ndarray, array, matrix, recarray
from numpy import (ndarray, array, matrix, recarray,
int64, int32, float64, float32,
complex64, complex128)
from numpy.ma import MaskedArray
from numpy import savetxt as np_savetxt
from numpy import set_printoptions as np_set_printoptions
except ImportError:
ndarray = array = matrix = recarray = MaskedArray = np_savetxt = \
np_set_printoptions = FakeObject
np_set_printoptions = int64 = int32 = float64 = float32 = \
complex64 = complex128 = FakeObject

def get_numpy_dtype(obj):
"""Return NumPy data type associated to obj
Expand Down Expand Up @@ -244,6 +247,8 @@ def unsorted_unique(lista):
def value_to_display(value, minmax=False):
"""Convert value for display purpose"""
try:
numeric_numpy_types = (int64, int32, float64, float32,
complex128, complex64)
if isinstance(value, recarray):
fields = value.names
display = 'Field names: ' + ', '.join(fields)
Expand Down Expand Up @@ -288,7 +293,8 @@ def value_to_display(value, minmax=False):
elif is_text_string(value):
display = value
elif isinstance(value, NUMERIC_TYPES) or isinstance(value, bool) or \
isinstance(value, datetime.date):
isinstance(value, datetime.date) or \
isinstance(value, numeric_numpy_types):
display = repr(value)
else:
# Note: Don't trust on repr's. They can be inefficient and
Expand Down

0 comments on commit f834b69

Please sign in to comment.