python scripts now pack "a a-1 a-2 ... a-n" to "a to a-n"

This commit is contained in:
Martin Diehl 2016-10-29 10:49:40 +02:00
parent aa3dc56949
commit 8eb93a3274
2 changed files with 6 additions and 3 deletions

View File

@ -600,8 +600,11 @@ class ASCIItable():
while i < N and self.data_read():
items = self.data
if len(items) > 2:
if items[1].lower() == 'of': items = np.ones(datatype(items[0]))*datatype(items[2])
elif items[1].lower() == 'to': items = np.arange(datatype(items[0]),1+datatype(items[2]))
if items[1].lower() == 'of':
items = np.ones(datatype(items[0]))*datatype(items[2])
elif items[1].lower() == 'to':
items = np.linspace(datatype(items[0]),datatype(items[2]),
abs(datatype(items[2])-datatype(items[0]))+1,dtype=int)
else: items = list(map(datatype,items))
else: items = list(map(datatype,items))

View File

@ -81,7 +81,7 @@ for name in filenames:
else: items = map(int,items)
for current in items:
if current == former+1 and start+reps == former+1:
if abs(current - former) == 1 and abs(start-former) == reps - 1:
compressType = 'to'
reps += 1
elif current == former and start == former: