Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

53 subphase support #54

Merged
merged 10 commits into from
Oct 1, 2020
27 changes: 21 additions & 6 deletions src/IO/lbsLoadReaderVT.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,22 @@ def read(self, node_id, time_step=-1, comm=False):
# Iterate over rows of input file
for row in log:
n_entries = len(row)

# Handle three-entry case that corresponds to an object load
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer accurate

if n_entries == 3:
if '[' in row[4]:
# Parsing the three-entry case, thus this format:
# <time_step/phase>, <object-id>, <time>
# <time_step/phase>, <object-id>, <time>, <#-subphases> '['
# [<subphase-time-1>] ... [<subphase-time-N>] ']'
# Converting these into integers and floats before using them or
# inserting the values in the dictionary
try:
phase, o_id = map(int, row[:2])
time = float(row[2])
Nsubphases = int(row[3])
subphase_times = row[4:]
assert len(subphase_times) == Nsubphases
subphase_times[0] = subphase_times[0][1:]
subphase_times[1] = subphase_times[-1][:-1]
subphase_times = map(float, subphase_times)
except:
print(bcolors.ERR
+ "* ERROR: [LoadReaderVT] Incorrect row format:".format(row)
Expand All @@ -169,13 +175,22 @@ def read(self, node_id, time_step=-1, comm=False):
print(bcolors.HEADER
+ "[LoadReaderVT] "
+ bcolors.END
+ "iteration = {}, object id = {}, time = {}".format(
+ "iteration = {}, object id = {}, time = {}, subphases = {}".format(
phase,
o_id,
time))
time,
Nsubphases,
end=''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the fault of this PR, but this entire print is questionable - we failed at parsing and hence assigning these variables, so try printing the variables that we didn't parse? The print should be of the (ideally unmodified) row


for i in range(0,Nsubphases):
print("subphase-time-" + str(i) + "= {}".format(
row[4 + i],
end=''))

print()

# Handle four-entry case that corresponds to a communication weight
elif n_entries == 5:
elif '[' not in row[4]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if and elif cover all possibilities. This elif should keep itself more narrowly tailored to the case it actually handles, so that the else still gets run for lines that aren't ever going to be parsed correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My latest commit addresses this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue
# Parsing the five-entry case, thus this format:
# <time_step/phase>, <to-object-id>, <from-object-id>, <weight>, <comm-type>
Expand Down