fixed buggy query-by-label-index
This commit is contained in:
parent
0d93a47c71
commit
73640587d5
|
@ -272,7 +272,7 @@ class ASCIItable():
|
||||||
for label in labels:
|
for label in labels:
|
||||||
if label is not None:
|
if label is not None:
|
||||||
try:
|
try:
|
||||||
idx.append(int(label)) # column given as integer number?
|
idx.append(int(label)-1) # column given as integer number?
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
idx.append(self.labels.index(label)) # locate string in label list
|
idx.append(self.labels.index(label)) # locate string in label list
|
||||||
|
@ -283,7 +283,7 @@ class ASCIItable():
|
||||||
idx.append(-1) # not found...
|
idx.append(-1) # not found...
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
idx = int(labels)
|
idx = int(labels)-1 # offset for python array indexing
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
idx = self.labels.index(labels)
|
idx = self.labels.index(labels)
|
||||||
|
@ -293,7 +293,7 @@ class ASCIItable():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
idx = None if labels is None else -1
|
idx = None if labels is None else -1
|
||||||
|
|
||||||
return np.array(idx) if isinstance(idx,list) else idx
|
return np.array(idx) if isinstance(idx,Iterable) else idx
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def label_dimension(self,
|
def label_dimension(self,
|
||||||
|
@ -312,7 +312,7 @@ class ASCIItable():
|
||||||
if label is not None:
|
if label is not None:
|
||||||
myDim = -1
|
myDim = -1
|
||||||
try: # column given as number?
|
try: # column given as number?
|
||||||
idx = int(label)
|
idx = int(label)-1
|
||||||
myDim = 1 # if found has at least dimension 1
|
myDim = 1 # if found has at least dimension 1
|
||||||
if self.labels[idx].startswith('1_'): # column has multidim indicator?
|
if self.labels[idx].startswith('1_'): # column has multidim indicator?
|
||||||
while idx+myDim < len(self.labels) and self.labels[idx+myDim].startswith("%i_"%(myDim+1)):
|
while idx+myDim < len(self.labels) and self.labels[idx+myDim].startswith("%i_"%(myDim+1)):
|
||||||
|
@ -331,7 +331,7 @@ class ASCIItable():
|
||||||
dim = -1 # assume invalid label
|
dim = -1 # assume invalid label
|
||||||
idx = -1
|
idx = -1
|
||||||
try: # column given as number?
|
try: # column given as number?
|
||||||
idx = int(labels)
|
idx = int(labels)-1
|
||||||
dim = 1 # if found has at least dimension 1
|
dim = 1 # if found has at least dimension 1
|
||||||
if self.labels[idx].startswith('1_'): # column has multidim indicator?
|
if self.labels[idx].startswith('1_'): # column has multidim indicator?
|
||||||
while idx+dim < len(self.labels) and self.labels[idx+dim].startswith("%i_"%(dim+1)):
|
while idx+dim < len(self.labels) and self.labels[idx+dim].startswith("%i_"%(dim+1)):
|
||||||
|
@ -345,7 +345,7 @@ class ASCIItable():
|
||||||
while idx+dim < len(self.labels) and self.labels[idx+dim].startswith("%i_"%(dim+1)):
|
while idx+dim < len(self.labels) and self.labels[idx+dim].startswith("%i_"%(dim+1)):
|
||||||
dim += 1 # keep adding while going through object
|
dim += 1 # keep adding while going through object
|
||||||
|
|
||||||
return np.array(dim) if isinstance(dim,list) else dim
|
return np.array(dim) if isinstance(dim,Iterable) else dim
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def label_indexrange(self,
|
def label_indexrange(self,
|
||||||
|
|
Loading…
Reference in New Issue