Skip to content

Commit

Permalink
test for overzoom
Browse files Browse the repository at this point in the history
  • Loading branch information
martham93 committed Jun 24, 2020
1 parent db9611f commit 6721177
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 3 deletions.
3 changes: 1 addition & 2 deletions test/fixtures/integration/config_3way.integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
"ml_type": "classification",
"seed": 19,
"split_names": ["train", "test", "val"],
"split_vals": [0.7, 0.2, 0.1]
}
"split_vals": [0.7, 0.2, 0.1]}
24 changes: 24 additions & 0 deletions test/fixtures/integration/config_overzoom.integration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{"country": "portugal",
"bounding_box": [
-9.4575,
38.8467,
-9.4510,
38.8513
],
"zoom": 17,
"classes": [
{ "name": "Water Tower", "filter": ["==", "man_made", "water_tower"] },
{ "name": "Building", "filter": ["has", "building"] },
{ "name": "Farmland", "filter": ["==", "landuse", "farmland"] },
{ "name": "Ruins", "filter": ["==", "historic", "ruins"] },
{ "name": "Parking", "filter": ["==", "amenity", "parking"] },
{ "name": "Roads", "filter": ["has", "highway"] }
],
"imagery": "https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=TOKEN",
"background_ratio": 1,
"ml_type": "classification",
"seed": 19,
"split_names": ["train", "test", "val"],
"split_vals": [0.7, 0.2, 0.1],
"over_zoom": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion test/integration/test_classification_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ def setUpClass(cls):
copyfile('test/fixtures/integration/labels-cl.npz', 'integration-cl-split/labels.npz')
copytree('test/fixtures/integration/tiles', 'integration-cl-split/tiles')

makedirs('integration-cl-overzoom')
copyfile('test/fixtures/integration/labels-cl.npz', 'integration-cl-overzoom/labels.npz')
copytree('test/fixtures/integration/tiles_overzoom', 'integration-cl-overzoom/tiles')

@classmethod
def tearDownClass(cls):
rmtree('integration-cl')
rmtree('integration-cl-split')
rmtree('integration-cl-overzoom')

def test_cli(self):
"""Verify data.npz produced by CLI"""
Expand Down Expand Up @@ -73,4 +78,16 @@ def test_cli_3way_split(self):
# validate label data with shapes
self.assertEqual(data['y_train'].shape, (5, 7))
self.assertEqual(data['y_test'].shape, (2, 7))
self.assertEqual(data['y_val'].shape, (1, 7))
self.assertEqual(data['y_val'].shape, (1, 7))

def test_overzoom(self):
"""Verify data.npz produced by CLI when overzoom is used"""
cmd = 'label-maker package --dest integration-cl-overzoom --config test/fixtures/integration/config_overzoom.integration.json'
cmd = cmd.split(' ')
subprocess.run(cmd, universal_newlines=True)

data = np.load('integration-cl-overzoom/data.npz')

self.assertEqual(data['x_train'].shape, (6, 512, 512, 3))
self.assertEqual(data['x_test'].shape, (2, 512, 512, 3))
self.assertEqual(data['x_val'].shape, (1, 512, 512, 3))

0 comments on commit 6721177

Please sign in to comment.