Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:CxAalto/gtfspy into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jweckstr committed Jul 7, 2017
2 parents 18233ee + 5c6d1de commit fdf7c47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions gtfspy/routing/node_profile_analyzer_time_and_veh_legs.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ def plot_temporal_distance_pdf_horizontal(self, use_minutes=True, ax=None, durat

journey_counts = numpy.zeros(len(temporal_distance_split_widths))
for block_now in blocks_now:
start_index = numpy.searchsorted(distance_split_points_ordered, block_now.distance_start)
end_index = numpy.searchsorted(distance_split_points_ordered, block_now.distance_end)
journey_counts[start_index:end_index] += 1
first_index = numpy.searchsorted(distance_split_points_ordered, block_now.distance_end)
last_index = numpy.searchsorted(distance_split_points_ordered, block_now.distance_start)
journey_counts[first_index:last_index] += 1

part_pdf = journey_counts / (self.end_time_dep - self.start_time_dep)
pdf_areas[n_boardings] = sum(part_pdf * temporal_distance_split_widths)
Expand Down
17 changes: 13 additions & 4 deletions gtfspy/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ def write_stats_as_csv(gtfs, path_to_csv, re_write=False):
if re_write:
os.remove(path_to_csv)

if not os.path.isfile(path_to_csv):
is_new = True
else:
is_new = False
#if not os.path.isfile(path_to_csv):
# is_new = True
#else:
# is_new = False

is_new = True
mode = 'r' if os.path.exists(path_to_csv) else 'w+'
with open(path_to_csv, mode) as csvfile:
for line in csvfile:
if line:
is_new = False
else:
is_new = True

with open(path_to_csv, 'a') as csvfile:
if (sys.version_info > (3, 0)):
delimiter = u","
Expand Down

0 comments on commit fdf7c47

Please sign in to comment.