Skip to content

Commit

Permalink
[nixexplore] fix dump_oned for AliasRangeDimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrewe committed Aug 5, 2020
1 parent dd2330d commit 7f9bd2a
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions nixio/cmd/nixexplore.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
""".strip()


def progress(count, total, status=''):
def progress(count, total, status='', bar_len=60):
"""
modified after https://gist.github.com/vladignatyev/06860ec2040cb497f0f3
by Vladimir Ignatev published under MIT License
"""
bar_len = 60
percents = count / total
filled_len = int(percents * bar_len)
bar = '=' * filled_len + '-' * (bar_len - filled_len)
Expand Down Expand Up @@ -352,16 +351,27 @@ def dump_oned(data, dimension, label, unit, format="%.6f"):
dim_label = getattr(dimension, "label") if hasattr(dimension, "label") else ""
dim_unit = getattr(dimension, "unit") if hasattr(dimension, "unit") else ""
max_tick_len = max([len(format % ticks[-1]), len(dim_label)])
padding = " " * (max_tick_len - len(dim_label))
print("# %s%s%s" % (dim_label, padding, label))
padding = " " * (max_tick_len - len(dim_unit))
print("# %s%s%s" % (dim_unit, padding, unit))

if dimension.dimension_type == nix.DimensionType.Range and dimension.is_alias:
print("# %s" % dim_label)
print("# %s" % dim_unit)
for i, t in enumerate(ticks):
print(format % t)
if i % 1000 == 0:
progress(i, data.shape[0], status='Dumping ...')
else:
padding = " " * (max_tick_len - len(dim_label))
print("# %s%s%s" % (dim_label, padding, label))
padding = " " * (max_tick_len - len(dim_unit))
print("# %s%s%s" % (dim_unit, padding, unit))

for i in range(data.shape[0]):
if i % 1000 == 0:
progress(i, data.shape[0], status='Dumping ...')

for i in range(data.shape[0]):
if i % 1000 == 0:
progress(i, data.shape[0], status='Dumping ...')
print(format % ticks[i] + " " + format % data[i])
print("\n\n")

print(format % ticks[i] + " " + format % data[i])


def dump_data_array(array, filename):
Expand Down

0 comments on commit 7f9bd2a

Please sign in to comment.