Skip to content

Commit

Permalink
bugfix default makemetadict
Browse files Browse the repository at this point in the history
more scalar types
  • Loading branch information
Daniel Manson committed Apr 27, 2015
1 parent 541d763 commit 227c271
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions spyderlib/make_meta_dict_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ def make_meta_dict(value):
the caller, and a default empty dict will be returned. The exception
stacktrace will be printed.
"""
if isinstance(value, (bool, int, float, tuple, list, set, dict)):
if isinstance(value, (bool, int, float, tuple, list, set, dict,
basestring)):
return {}

meta = OrderedDict()
class DudObject():
pass

try:
from numpy import ndarray
from numpy import ndarray, ScalarType
from numpy.ma import MaskedArray
except ImportError:
ndarray = MaskedArray = DudObject # analysis:ignore
ScalarType = () # analysis:ignore

try:
from pandas import DataFrame, TimeSeries
Expand All @@ -53,7 +55,14 @@ class DudObject():
except ImportError:
Image = DudObject # analysis:ignore

if isinstance(value, (ndarray, MaskedArray)):
try:
from datetime import date
except ImportError:
datetime = DudObject # analysis:ignore

if isinstance(value, ScalarType + (date,)):
pass # dont try html or docstring
elif isinstance(value, (ndarray, MaskedArray)):
meta.update(make_numpy_meta_dict(value))
elif isinstance(value, DataFrame):
meta['html'] = value.describe().to_html()
Expand Down

0 comments on commit 227c271

Please sign in to comment.