aboutsummaryrefslogtreecommitdiff
path: root/make_valid.py
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-04-28 16:41:46 -0400
committerAlex Auvolat <alex.auvolat@ens.fr>2015-04-28 16:41:46 -0400
commitc195fd437b76d00ee780cef49903266165f001a7 (patch)
tree6010785da83baa49f7f89dc230e4ef0b0f1994f3 /make_valid.py
parentd58b121de641c0122652bc3d6096a9d0e1048391 (diff)
downloadtaxi-c195fd437b76d00ee780cef49903266165f001a7.tar.gz
taxi-c195fd437b76d00ee780cef49903266165f001a7.zip
Support polylines with <5 points
Diffstat (limited to 'make_valid.py')
-rw-r--r--make_valid.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/make_valid.py b/make_valid.py
index ffaa352..d5e147d 100644
--- a/make_valid.py
+++ b/make_valid.py
@@ -14,8 +14,8 @@ with open("valid-full.csv") as f:
def make_valid_item(l):
polyline = ast.literal_eval(l[-1])
last = polyline[-1]
- cut_idx = random.randrange(len(polyline)-5)
- cut = polyline[:cut_idx+6]
+ cut_idx = random.randrange(len(polyline)+1)
+ cut = polyline[:cut_idx]
return l[:-1] + [
cut.__str__(),
last[0],
@@ -23,7 +23,7 @@ def make_valid_item(l):
15 * (len(polyline)-1),
]
-vlines = map(make_valid_item, filter(lambda l: (len(ast.literal_eval(l[-1])) > 5), vlines))
+vlines = map(make_valid_item, filter(lambda l: (len(ast.literal_eval(l[-1])) > 0), vlines))
with open("valid.csv", "w") as f:
wr = csv.writer(f)
@@ -32,5 +32,6 @@ with open("valid.csv", "w") as f:
with open("valid-solution.csv", "w") as f:
wr = csv.writer(f)
+ wr.writerow(["TRIP_ID", "LATITUDE", "LONGITUDE"])
for r in vlines:
wr.writerow([r[0], r[-2], r[-3]])