Skip to content

Commit

Permalink
Merge pull request fabioz#6 from Amarchuk/development
Browse files Browse the repository at this point in the history
improve ndarray resolver for work with string arrays
  • Loading branch information
fabioz committed Aug 22, 2014
2 parents d53fc05 + 21dac36 commit 1750b00
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions pydevd_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,24 @@ class NdArrayResolver:
This resolves a numpy ndarray returning some metadata about the NDArray
'''

def is_numeric(self, obj):
if not hasattr(obj, 'dtype'):
return False
return obj.dtype.kind in 'biufc'

def resolve(self, obj, attribute):
if attribute == '__internals__':
return defaultResolver.getDictionary(obj)
if attribute == 'min':
return obj.min()
if self.is_numeric(obj):
return obj.min()
else:
return None
if attribute == 'max':
return obj.max()
if self.is_numeric(obj):
return obj.max()
else:
return None
if attribute == 'shape':
return obj.shape
if attribute == 'dtype':
Expand All @@ -407,8 +418,12 @@ def getDictionary(self, obj):
ret['min'] = 'ndarray too big, calculating min would slow down debugging'
ret['max'] = 'ndarray too big, calculating max would slow down debugging'
else:
ret['min'] = obj.min()
ret['max'] = obj.max()
if self.is_numeric(obj):
ret['min'] = obj.min()
ret['max'] = obj.max()
else:
ret['min'] = 'not a numeric object'
ret['max'] = 'not a numeric object'
ret['shape'] = obj.shape
ret['dtype'] = obj.dtype
ret['size'] = obj.size
Expand Down

0 comments on commit 1750b00

Please sign in to comment.