I have the following list comprehension:
cd.impending_events = [cd.priority_queue.pop(i) for i, x in enumerate(cd.priority_queue) if round(x[0], cd.precision) == round(cd.simulation_time, cd.precision)]
It's pulling values out based on the current time. I believe I should never see old time values in my priority queue.
Here is a snippet from my log file:
2.69
[2.7, 1, 'hwall', 1]
[2.7, 1, 'hwall', 2]
[2.7, 0, 'vwall', 5]
[2.73, 0, 'vwall', 0]
[2.73, 0, 'vwall', 1]
[2.73, 0, 'vwall', 2]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
2.7
[2.7, 1, 'hwall', 2]
[2.73, 0, 'vwall', 0]
[2.73, 0, 'vwall', 1]
[2.73, 0, 'vwall', 2]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[3.56, 0, 'hwall', 6]
[4.36, 0, 'vwall', 6]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
2.71
[2.7, 1, 'hwall', 2]
[2.73, 0, 'vwall', 0]
[2.73, 0, 'vwall', 1]
[2.73, 0, 'vwall', 2]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[3.56, 0, 'hwall', 6]
[4.36, 0, 'vwall', 6]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
The current time is printed and then the priority queue at the current time is printed in the log file. At time 2.7, one of the elements was left behind.
The same thing happens at 2.73:
2.72
[2.7, 1, 'hwall', 2]
[2.73, 0, 'vwall', 0]
[2.73, 0, 'vwall', 1]
[2.73, 0, 'vwall', 2]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[3.56, 0, 'hwall', 6]
[4.36, 0, 'vwall', 6]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
2.73
[2.7, 1, 'hwall', 2]
[2.73, 0, 'vwall', 1]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[3.56, 0, 'hwall', 6]
[4.36, 0, 'vwall', 6]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
2.74
[2.7, 1, 'hwall', 2]
[2.73, 0, 'vwall', 1]
[2.78, 1, 'vwall', 5]
[3.27, 0, 'vwall', 4]
[3.5, 1, 'hwall', 4]
[3.56, 0, 'hwall', 5]
[3.56, 0, 'hwall', 6]
[4.36, 0, 'vwall', 6]
[5.75, 1, 'vwall', 3]
[5.75, 1, 'vwall', 4]
[12.1, 1, 'hwall', 5]
I think it only happens when there are 3 elements available. I see nothing special about these particular elements.
Why is my list comprehension skipping the third element?