Set MetaArray._info after modifications during MetaArray.checkInfo().
Update MetaArray.prettyInfo() to print empty axes. Also fixed some spacing issues when number of elements had more digits in some axes than others (up to 5 digits).
This commit is contained in:
parent
70626624ca
commit
2eca4ed775
@ -152,7 +152,7 @@ class MetaArray(object):
|
|||||||
if self._data is None:
|
if self._data is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self._info = [{} for i in range(self.ndim)]
|
self._info = [{} for i in range(self.ndim+1)]
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -175,12 +175,15 @@ class MetaArray(object):
|
|||||||
elif type(info[i]['values']) is not np.ndarray:
|
elif type(info[i]['values']) is not np.ndarray:
|
||||||
raise Exception("Axis values must be specified as list or ndarray")
|
raise Exception("Axis values must be specified as list or ndarray")
|
||||||
if info[i]['values'].ndim != 1 or info[i]['values'].shape[0] != self.shape[i]:
|
if info[i]['values'].ndim != 1 or info[i]['values'].shape[0] != self.shape[i]:
|
||||||
raise Exception("Values array for axis %d has incorrect shape. (given %s, but should be %s)" % (i, str(info[i]['values'].shape), str((self.shape[i],))))
|
raise Exception("Values array for axis %d has incorrect shape. (given %s, but should be %s)" %\
|
||||||
|
(i, str(info[i]['values'].shape), str((self.shape[i],))))
|
||||||
if i < self.ndim and 'cols' in info[i]:
|
if i < self.ndim and 'cols' in info[i]:
|
||||||
if not isinstance(info[i]['cols'], list):
|
if not isinstance(info[i]['cols'], list):
|
||||||
info[i]['cols'] = list(info[i]['cols'])
|
info[i]['cols'] = list(info[i]['cols'])
|
||||||
if len(info[i]['cols']) != self.shape[i]:
|
if len(info[i]['cols']) != self.shape[i]:
|
||||||
raise Exception('Length of column list for axis %d does not match data. (given %d, but should be %d)' % (i, len(info[i]['cols']), self.shape[i]))
|
raise Exception('Length of column list for axis %d does not match data. (given %d, but should be %d)' %\
|
||||||
|
(i, len(info[i]['cols']), self.shape[i]))
|
||||||
|
self._info = info
|
||||||
|
|
||||||
def implements(self, name=None):
|
def implements(self, name=None):
|
||||||
## Rather than isinstance(obj, MetaArray) use object.implements('MetaArray')
|
## Rather than isinstance(obj, MetaArray) use object.implements('MetaArray')
|
||||||
@ -647,11 +650,18 @@ class MetaArray(object):
|
|||||||
for i in range(min(self.ndim, len(self._info)-1)):
|
for i in range(min(self.ndim, len(self._info)-1)):
|
||||||
ax = self._info[i]
|
ax = self._info[i]
|
||||||
axs = titles[i]
|
axs = titles[i]
|
||||||
axs += '%s[%d] :' % (' ' * (maxl + 2 - len(axs)), self.shape[i])
|
axs += '%s[%d] :' % (' ' * (maxl - len(axs) + 5 - len(str(self.shape[i]))), self.shape[i])
|
||||||
if 'values' in ax:
|
if 'values' in ax:
|
||||||
|
if self.shape[i] > 0:
|
||||||
v0 = ax['values'][0]
|
v0 = ax['values'][0]
|
||||||
|
axs += " values: [%g" % (v0)
|
||||||
|
if self.shape[i] > 1:
|
||||||
v1 = ax['values'][-1]
|
v1 = ax['values'][-1]
|
||||||
axs += " values: [%g ... %g] (step %g)" % (v0, v1, (v1-v0)/(self.shape[i]-1))
|
axs += " ... %g] (step %g)" % (v1, (v1-v0)/(self.shape[i]-1))
|
||||||
|
else:
|
||||||
|
axs += "]"
|
||||||
|
else:
|
||||||
|
axs+= " values: []"
|
||||||
if 'cols' in ax:
|
if 'cols' in ax:
|
||||||
axs += " columns: "
|
axs += " columns: "
|
||||||
colstrs = []
|
colstrs = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user