Skip to content

fix linter on master #2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions integration-test/1999-keep-n-gridded.py

Large diffs are not rendered by default.

118 changes: 59 additions & 59 deletions test/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def test_short_name(self):


class KeepNGriddedTest(unittest.TestCase):
longMessage=True
longMessage = True

def test_not_points(self):
from tilequeue.process import Context
Expand All @@ -407,8 +407,8 @@ def test_not_points(self):
test_shape_2 = shapely.geometry.Polygon(
[(10, 10), (20, 20), (10, 20), (10, 10)])
features = [
(test_shape_1, {"foo": "bar"}, "test_shape_1"),
(test_shape_2, {"foo": "bar"}, "test_shape_2"),
(test_shape_1, {'foo': 'bar'}, 'test_shape_1'),
(test_shape_2, {'foo': 'bar'}, 'test_shape_2'),
]
feature_layer = dict(
features=features,
Expand All @@ -421,12 +421,12 @@ def test_not_points(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=1,
grid_width=2,
sorting_keys=[
{"sort_key": "foo"},
{'sort_key': 'foo'},
],
),
resources=None,
Expand All @@ -435,7 +435,7 @@ def test_not_points(self):
from vectordatasource.transform import keep_n_features_gridded
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEquals(features, output_features, "Non-point features should pass through without modification")
self.assertEquals(features, output_features, 'Non-point features should pass through without modification')

def test_points_keep_1(self):
from tilequeue.process import Context
Expand All @@ -444,8 +444,8 @@ def test_points_keep_1(self):
test_shape_1 = shapely.geometry.Point((1.1, 1.0))
test_shape_2 = shapely.geometry.Point((1.1, 1.0))
features = [
(test_shape_1, {"foo": "bar"}, "test_shape_1"),
(test_shape_2, {"foo": "bar"}, "test_shape_2"),
(test_shape_1, {'foo': 'bar'}, 'test_shape_1'),
(test_shape_2, {'foo': 'bar'}, 'test_shape_2'),
]
feature_layer = dict(
features=features,
Expand All @@ -458,12 +458,12 @@ def test_points_keep_1(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=1,
grid_width=2,
sorting_keys=[
{"sort_key": "foo"},
{'sort_key': 'foo'},
],
),
resources=None,
Expand All @@ -472,8 +472,8 @@ def test_points_keep_1(self):
from vectordatasource.transform import keep_n_features_gridded
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEqual(1, len(output_features), "Should consolidate to a single point in the bucket")
self.assertEqual("test_shape_1", output_features[0][2], "All values equal, should pick first one")
self.assertEqual(1, len(output_features), 'Should consolidate to a single point in the bucket')
self.assertEqual('test_shape_1', output_features[0][2], 'All values equal, should pick first one')

def test_points_keep_1_multisort_second(self):
from tilequeue.process import Context
Expand All @@ -482,8 +482,8 @@ def test_points_keep_1_multisort_second(self):
test_shape_1 = shapely.geometry.Point((1.1, 1.0))
test_shape_2 = shapely.geometry.Point((1.1, 1.0))
features = [
(test_shape_2, {"foo": "bar", "min_zoom": 12.0, "population": 20000}, "test_shape_2"),
(test_shape_1, {"foo": "bar", "min_zoom": 12.0, "population": 10000}, "test_shape_1"),
(test_shape_2, {'foo': 'bar', 'min_zoom': 12.0, 'population': 20000}, 'test_shape_2'),
(test_shape_1, {'foo': 'bar', 'min_zoom': 12.0, 'population': 10000}, 'test_shape_1'),
]
feature_layer = dict(
features=features,
Expand All @@ -496,13 +496,13 @@ def test_points_keep_1_multisort_second(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=1,
grid_width=2,
sorting_keys=[
{"sort_key": "min_zoom"},
{"sort_key": "population", "reverse": True},
{'sort_key': 'min_zoom'},
{'sort_key': 'population', 'reverse': True},
],
),
resources=None,
Expand All @@ -511,8 +511,8 @@ def test_points_keep_1_multisort_second(self):
from vectordatasource.transform import keep_n_features_gridded
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEqual(1, len(output_features), "Should consolidate to a single point in the bucket")
self.assertEqual("test_shape_2", output_features[0][2], "Should pick the shape with higher population")
self.assertEqual(1, len(output_features), 'Should consolidate to a single point in the bucket')
self.assertEqual('test_shape_2', output_features[0][2], 'Should pick the shape with higher population')

def test_points_keep_1_multisort_minzoom(self):
from tilequeue.process import Context
Expand All @@ -521,8 +521,8 @@ def test_points_keep_1_multisort_minzoom(self):
test_shape_1 = shapely.geometry.Point((1.1, 1.0))
test_shape_2 = shapely.geometry.Point((1.1, 1.0))
features = [
(test_shape_2, {"foo": "bar", "min_zoom": 12.0, "population": 20000}, "test_shape_2"),
(test_shape_1, {"foo": "bar", "min_zoom": 10.0, "population": 10000}, "test_shape_1"),
(test_shape_2, {'foo': 'bar', 'min_zoom': 12.0, 'population': 20000}, 'test_shape_2'),
(test_shape_1, {'foo': 'bar', 'min_zoom': 10.0, 'population': 10000}, 'test_shape_1'),
]
feature_layer = dict(
features=features,
Expand All @@ -535,13 +535,13 @@ def test_points_keep_1_multisort_minzoom(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=1,
grid_width=2,
sorting_keys=[
{"sort_key": "min_zoom"},
{"sort_key": "population", "reverse": True},
{'sort_key': 'min_zoom'},
{'sort_key': 'population', 'reverse': True},
],
),
resources=None,
Expand All @@ -550,8 +550,8 @@ def test_points_keep_1_multisort_minzoom(self):
from vectordatasource.transform import keep_n_features_gridded
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEqual(1, len(output_features), "Should consolidate to a single point in the bucket")
self.assertEqual("test_shape_1", output_features[0][2], "Should pick the shape with lower min_zoom")
self.assertEqual(1, len(output_features), 'Should consolidate to a single point in the bucket')
self.assertEqual('test_shape_1', output_features[0][2], 'Should pick the shape with lower min_zoom')

def test_points_keep_1_different_buckets(self):
from tilequeue.process import Context
Expand All @@ -562,10 +562,10 @@ def test_points_keep_1_different_buckets(self):
test_shape_3 = shapely.geometry.Point((75.0, 75.0))
test_shape_4 = shapely.geometry.Point((25.0, 75.0))
features = [
(test_shape_1, {"foo": "bar", "population": 1000}, "test_shape_1"),
(test_shape_2, {"foo": "bar", "population": 2000}, "test_shape_2"),
(test_shape_3, {"foo": "bar", "population": 3000}, "test_shape_3"),
(test_shape_4, {"foo": "bar", "population": 4000}, "test_shape_4"),
(test_shape_1, {'foo': 'bar', 'population': 1000}, 'test_shape_1'),
(test_shape_2, {'foo': 'bar', 'population': 2000}, 'test_shape_2'),
(test_shape_3, {'foo': 'bar', 'population': 3000}, 'test_shape_3'),
(test_shape_4, {'foo': 'bar', 'population': 4000}, 'test_shape_4'),
]
feature_layer = dict(
features=features,
Expand All @@ -578,12 +578,12 @@ def test_points_keep_1_different_buckets(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=1,
grid_width=2,
sorting_keys=[
{"sort_key": "population", "reverse": True},
{'sort_key': 'population', 'reverse': True},
],
),
resources=None,
Expand All @@ -592,10 +592,10 @@ def test_points_keep_1_different_buckets(self):
from vectordatasource.transform import keep_n_features_gridded
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEqual(3, len(output_features), "Should consolidate to 3 points")
self.assertEqual("test_shape_4", output_features[0][2])
self.assertEqual("test_shape_2", output_features[1][2])
self.assertEqual("test_shape_3", output_features[2][2])
self.assertEqual(3, len(output_features), 'Should consolidate to 3 points')
self.assertEqual('test_shape_4', output_features[0][2])
self.assertEqual('test_shape_2', output_features[1][2])
self.assertEqual('test_shape_3', output_features[2][2])

def test_points_keep_more_than_in_one_bucket(self):
from tilequeue.process import Context
Expand All @@ -606,10 +606,10 @@ def test_points_keep_more_than_in_one_bucket(self):
test_shape_3 = shapely.geometry.Point((75.0, 75.0))
test_shape_4 = shapely.geometry.Point((25.0, 75.0))
features = [
(test_shape_1, {"foo": "bar", "population": 1000}, "test_shape_1"),
(test_shape_2, {"foo": "bar", "population": 2000}, "test_shape_2"),
(test_shape_3, {"foo": "bar", "population": 3000}, "test_shape_3"),
(test_shape_4, {"foo": "bar", "population": 4000}, "test_shape_4"),
(test_shape_1, {'foo': 'bar', 'population': 1000}, 'test_shape_1'),
(test_shape_2, {'foo': 'bar', 'population': 2000}, 'test_shape_2'),
(test_shape_3, {'foo': 'bar', 'population': 3000}, 'test_shape_3'),
(test_shape_4, {'foo': 'bar', 'population': 4000}, 'test_shape_4'),
]
feature_layer = dict(
features=features,
Expand All @@ -622,13 +622,13 @@ def test_points_keep_more_than_in_one_bucket(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=5,
grid_width=2,
sorting_keys=[
{"sort_key": "min_zoom", "reverse": True},
{"sort_key": "population"},
{'sort_key': 'min_zoom', 'reverse': True},
{'sort_key': 'population'},
],
),
resources=None,
Expand All @@ -638,10 +638,10 @@ def test_points_keep_more_than_in_one_bucket(self):
layer = keep_n_features_gridded(ctx)
output_features = layer['features']
self.assertEqual(4, len(output_features), "Should not consolidate because we're keeping top 5")
self.assertEqual("test_shape_4", output_features[0][2])
self.assertEqual("test_shape_1", output_features[1][2])
self.assertEqual("test_shape_2", output_features[2][2])
self.assertEqual("test_shape_3", output_features[3][2])
self.assertEqual('test_shape_4', output_features[0][2])
self.assertEqual('test_shape_1', output_features[1][2])
self.assertEqual('test_shape_2', output_features[2][2])
self.assertEqual('test_shape_3', output_features[3][2])

def test_fail_on_non_integer_reverse_sort_key(self):
from tilequeue.process import Context
Expand All @@ -650,8 +650,8 @@ def test_fail_on_non_integer_reverse_sort_key(self):
test_shape_1 = shapely.geometry.Point((1.0, 1.0))
test_shape_2 = shapely.geometry.Point((1.0, 1.0))
features = [
(test_shape_1, {"foo": "bar", "population": 1000}, "test_shape_1"),
(test_shape_2, {"foo": "bar", "population": 'error'}, "test_shape_2"),
(test_shape_1, {'foo': 'bar', 'population': 1000}, 'test_shape_1'),
(test_shape_2, {'foo': 'bar', 'population': 'error'}, 'test_shape_2'),
]
feature_layer = dict(
features=features,
Expand All @@ -664,12 +664,12 @@ def test_fail_on_non_integer_reverse_sort_key(self):
nominal_zoom=0,
unpadded_bounds=bounds,
params=dict(
source_layer="test_layer",
items_matching=dict(foo="bar"),
source_layer='test_layer',
items_matching=dict(foo='bar'),
max_items=5,
grid_width=2,
sorting_keys=[
{"sort_key": "population", "reverse": True},
{'sort_key': 'population', 'reverse': True},
],
),
resources=None,
Expand All @@ -678,7 +678,7 @@ def test_fail_on_non_integer_reverse_sort_key(self):
from vectordatasource.transform import keep_n_features_gridded
with self.assertRaises(ValueError):
keep_n_features_gridded(ctx)
self.fail("Should raise an exception when reverse-sorting a non-numeric property")
self.fail('Should raise an exception when reverse-sorting a non-numeric property')


class TagsPriorityI18nTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion vectordatasource/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ def sorting_values_for_feature(f):
if k.get('reverse'):
v *= -1
if v == '':
raise ValueError("Cannot reverse string value %s" % props.get(k['sort_key']))
raise ValueError('Cannot reverse string value %s' % props.get(k['sort_key']))

values.append(v)
return values
Expand Down