From 76869bf8d65e58673f0ed5752a42fd6e52f5fc9e Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 24 Feb 2023 00:27:06 -0500 Subject: [PATCH] Update generate test data script --- docs/DESIGN.adoc | 2 +- .../00-generate-test-data.py | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) rename docs/generate-test-data.py => test-data/00-generate-test-data.py (50%) mode change 100644 => 100755 diff --git a/docs/DESIGN.adoc b/docs/DESIGN.adoc index f497709..0ef2861 100644 --- a/docs/DESIGN.adoc +++ b/docs/DESIGN.adoc @@ -759,7 +759,7 @@ All of these cases are generated with this code: [source,python] ---- -include::./generate-test-data.py[] +include::../test-data/00-generate-test-data.py[] ---- == Interfaces [[interfaces]] diff --git a/docs/generate-test-data.py b/test-data/00-generate-test-data.py old mode 100644 new mode 100755 similarity index 50% rename from docs/generate-test-data.py rename to test-data/00-generate-test-data.py index 4320255..f68de99 --- a/docs/generate-test-data.py +++ b/test-data/00-generate-test-data.py @@ -1,27 +1,30 @@ +#!/usr/bin/env python3 from random import random -with open("00-sample-latlon.csv", "w") as f: +with open("./00-sample-latlon.csv", "w") as f: f.write("lat,lon\n") - # Edge cases - # Do both positive and negative - for neg in ("-", ""): - # Add a little bit of variation - for dec in ("0", "00000001", "5", "05", "9999"): - # Possibly strange latitudes - for lat_i in (0, 1, 90): - # Possibly strong longitudes - for lon_i in (0, 1, 90, 180): - f.write(f"{neg}{lat_i}.{dec},") - f.write(f"{neg}{lon_i}.{dec}\n") - # Normalized for i in range(10000): lat = (random() - .5) * 2 * 90 lon = (random() - .5) * 2 * 180 f.write(f"{lat},{lon}\n") - # Non-normalized - for i in range(10000): - lat = (random() - .5) * 2 * 1000 - lon = (random() - .5) * 2 * 1000 - f.write(f"{lat},{lon}\n") + # Edge cases + # Do both positive and negative + for neg in (1, -1): + # Add a little bit of variation + for dec in (0, .1, .5, .05, .9999): + # Possibly strange latitudes + for lat_i in (0, 1, 90): + # Possibly strong longitudes + for lon_i in (0, 1, 90, 180): + lat = neg * (lat_i - dec) + lon = neg * (lon_i - dec) + + f.write(f"{lat:f},{lon:f}\n") + + # # Non-normalized + # for i in range(10000): + # lat = (random() - .5) * 2 * 1000 + # lon = (random() - .5) * 2 * 1000 + # f.write(f"{lat},{lon}\n")