Skip to content

Commit 47301be

Browse files
authored
Merge pull request #330 from snowman2/stickler
added stickler yaml file
2 parents 0221652 + 4114080 commit 47301be

File tree

5 files changed

+182
-67
lines changed

5 files changed

+182
-67
lines changed

.gitignore

Lines changed: 112 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,117 @@
1-
build/
2-
nad2bin*
3-
*.obj
4-
*.o
5-
*.pyc
1+
pyproj/proj_dir/
2+
pyproj/*.c
3+
proj-*/
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
611
*.so
7-
*.c*
8-
!*.css
9-
.coverage
12+
13+
# Distribution / packaging
14+
wheelhouse/
15+
.Python
16+
env/
17+
build/
18+
develop-eggs/
1019
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
wheels/
29+
*.egg-info/
30+
.installed.cfg
31+
*.egg
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
.hypothesis/
53+
.pytest_cache/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
target/
75+
76+
# Jupyter Notebook
77+
.ipynb_checkpoints
78+
79+
# pyenv
80+
.python-version
81+
82+
# celery beat schedule file
83+
celerybeat-schedule
84+
85+
# SageMath parsed files
86+
*.sage.py
87+
88+
# dotenv
89+
.env
90+
91+
# virtualenv
92+
.venv
1193
venv/
12-
pyproj.egg-info/
13-
pyproj/proj_dir/
14-
pyproj/datadir.py.save
15-
docs/_build
94+
ENV/
95+
96+
# Spyder project settings
97+
.spyderproject
98+
.spyproject
99+
100+
# Rope project settings
101+
.ropeproject
102+
103+
# mkdocs documentation
104+
/site
105+
106+
# mypy
107+
.mypy_cache/
108+
109+
# pycharm
16110
.idea/
111+
112+
# pytest
113+
.pytest_cache/
114+
115+
# vscode
17116
.vscode/
117+

.stickler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
linters:
2+
black:
3+
flake8:
4+
python: 3
5+
max-line-length: 88

test/test.py

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Rewrite part of test.py in pyproj in the form of unittests."""
33

44
import math
5+
import re
56
import sys
67
import unittest
78

@@ -12,20 +13,19 @@
1213
class BasicTest(unittest.TestCase):
1314
def testProj4Version(self):
1415
awips221 = Proj(proj="lcc", R=6371200, lat_1=50, lat_2=50, lon_0=-107)
15-
# self.assertEqual(awips221.proj_version, 4.9)
16+
assert re.match(r"\d+\.\d+", awips221.proj_version)
1617

1718
def testInitWithBackupString4(self):
1819
# this fails unless backup of to_string(4) is used
1920
pj = Proj(
20-
"+proj=merc +a=6378137.0 +b=6378137.0 +nadgrids=@null +lon_0=0.0 +x_0=0.0 +y_0=0.0 +units=m +no_defs"
21+
"+proj=merc +a=6378137.0 +b=6378137.0 +nadgrids=@null "
22+
"+lon_0=0.0 +x_0=0.0 +y_0=0.0 +units=m +no_defs"
2123
)
2224
assert pj.crs.is_valid
2325

2426
def testProjAwips221(self):
2527
# AWIPS is Advanced Weather Interactive Processing System
2628
params = {"proj": "lcc", "R": 6371200, "lat_1": 50, "lat_2": 50, "lon_0": -107}
27-
nx = 349
28-
ny = 277
2929
awips221 = Proj(
3030
proj=params["proj"],
3131
R=params["R"],
@@ -73,27 +73,30 @@ def testProjAwips221(self):
7373

7474
def test_from_dict_with_bool(self):
7575
# issue #183
76-
p_d = {'proj': 'omerc',
77-
'lat_2': 80.27942,
78-
'lat_0': 62.87671,
79-
'lat_1': 42.751232,
80-
'ellps': 'WGS84',
81-
'no_rot': True,
82-
'lon_1': 33.793186,
83-
'lon_2': -18.374414}
84-
p=Proj(p_d)
85-
self.assertTrue('+no_rot' in p.srs.split())
86-
p_d = {'proj': 'omerc',
87-
'lat_2': 80.27942,
88-
'lat_0': 62.87671,
89-
'lat_1': 42.751232,
90-
'ellps': 'WGS84',
91-
'no_rot': False,
92-
'lon_1': 33.793186,
93-
'lon_2': -18.374414}
94-
p=Proj(p_d)
95-
self.assertFalse('+no_rot' in p.srs.split())
96-
76+
p_d = {
77+
"proj": "omerc",
78+
"lat_2": 80.27942,
79+
"lat_0": 62.87671,
80+
"lat_1": 42.751232,
81+
"ellps": "WGS84",
82+
"no_rot": True,
83+
"lon_1": 33.793186,
84+
"lon_2": -18.374414,
85+
}
86+
p = Proj(p_d)
87+
self.assertTrue("+no_rot" in p.srs.split())
88+
p_d = {
89+
"proj": "omerc",
90+
"lat_2": 80.27942,
91+
"lat_0": 62.87671,
92+
"lat_1": 42.751232,
93+
"ellps": "WGS84",
94+
"no_rot": False,
95+
"lon_1": 33.793186,
96+
"lon_2": -18.374414,
97+
}
98+
p = Proj(p_d)
99+
self.assertFalse("+no_rot" in p.srs.split())
97100

98101

99102
class InverseHammerTest(unittest.TestCase):
@@ -136,7 +139,8 @@ def test_tranform_none_2nd_parmeter(self):
136139

137140
class Geod_NoDefs_Issue22_Test(unittest.TestCase):
138141
# Test for Issue #22, Geod with "+no_defs" in initstring
139-
# Before PR #23 merged 2015-10-07, having +no_defs in the initstring would result in a ValueError
142+
# Before PR #23 merged 2015-10-07, having +no_defs in the
143+
# initstring would result in a ValueError
140144
def test_geod_nodefs(self):
141145
Geod("+a=6378137 +b=6378137 +no_defs")
142146

@@ -151,16 +155,19 @@ def test_latlong_typeerror(self):
151155
lon, lat = transform(p, p.to_latlong(), 200000, 400000)
152156

153157

154-
@unittest.skipIf(sys.version_info < (3, 4), "Python 3.4 or newer required for subTest()")
158+
@unittest.skipIf(
159+
sys.version_info < (3, 4), "Python 3.4 or newer required for subTest()"
160+
)
155161
class ForwardInverseTest(unittest.TestCase):
156162
def test_fwd_inv(self):
157163
for pj in pj_list.keys():
158164
with self.subTest(pj=pj):
159165
try:
160166
p = Proj(proj=pj)
161167
x, y = p(-30, 40)
162-
# note, for proj 4.9.2 or before the inverse projection may be missing
163-
# and pyproj 1.9.5.1 or before does not test for this and will
168+
# note, for proj 4.9.2 or before the inverse projection
169+
# may be missing and pyproj 1.9.5.1 or before does not
170+
# test for this and will
164171
# give a segmentation fault at this point:
165172
lon, lat = p(x, y, inverse=True)
166173
except RuntimeError:
@@ -188,7 +195,8 @@ def test_not_shared_memory(self):
188195
self.assertNotEqual(self.g.initstring, self.mercury.initstring)
189196

190197
def test_distances(self):
191-
# note calculated distance was not an issue with #64, but it still a shared memory test
198+
# note calculated distance was not an issue with #64,
199+
# but it still a shared memory test
192200
boston_lat = 42.0 + (15.0 / 60.0)
193201
boston_lon = -71.0 - (7.0 / 60.0)
194202
portland_lat = 45.0 + (31.0 / 60.0)

test/test_crs.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_from_proj4__invalid():
3232
with pytest.raises(CRSError):
3333
assert CRS.from_proj4(CRS(3857).to_wkt())
3434

35+
3536
def test_from_proj4_json():
3637
json_str = '{"proj": "longlat", "ellps": "WGS84", "datum": "WGS84"}'
3738
proj = CRS.from_string(json_str)
@@ -773,25 +774,32 @@ def test_crs_init_user_input():
773774

774775
def test_to_string__no_auth():
775776
proj = CRS("+proj=latlong +ellps=GRS80 +towgs84=-199.87,74.79,246.62")
776-
assert proj.to_string() == \
777-
"+proj=latlong +ellps=GRS80 +towgs84=-199.87,74.79,246.62 +type=crs"
777+
assert (
778+
proj.to_string()
779+
== "+proj=latlong +ellps=GRS80 +towgs84=-199.87,74.79,246.62 +type=crs"
780+
)
778781

779782

780783
def test_to_string__auth():
781784
assert CRS(("IGNF", "ETRS89UTM28")).to_string() == "IGNF:ETRS89UTM28"
782785

783786

784787
def test_srs__no_plus():
785-
assert CRS("proj=longlat datum=WGS84 no_defs").srs == \
786-
"proj=longlat datum=WGS84 type=crs"
788+
assert (
789+
CRS("proj=longlat datum=WGS84 no_defs").srs
790+
== "proj=longlat datum=WGS84 type=crs"
791+
)
787792

788793

789-
@pytest.mark.parametrize("init_string, expected_srs", [
790-
("+init=epsg:4326 +no_defs=True", "+init=epsg:4326 +type=crs"),
791-
("init=epsg:4326 no_defs=True", "init=epsg:4326 type=crs"),
792-
("+init=epsg:4326 +no_defs", "+init=epsg:4326 +type=crs"),
793-
("init=epsg:4326 no_defs", "init=epsg:4326 type=crs"),
794-
])
794+
@pytest.mark.parametrize(
795+
"init_string, expected_srs",
796+
[
797+
("+init=epsg:4326 +no_defs=True", "+init=epsg:4326 +type=crs"),
798+
("init=epsg:4326 no_defs=True", "init=epsg:4326 type=crs"),
799+
("+init=epsg:4326 +no_defs", "+init=epsg:4326 +type=crs"),
800+
("init=epsg:4326 no_defs", "init=epsg:4326 type=crs"),
801+
],
802+
)
795803
def test_removing_nodefs(init_string, expected_srs):
796804
assert CRS(init_string).srs == expected_srs
797805

test/test_transformer.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,14 @@ def test_str():
404404

405405

406406
def test_repr():
407-
assert repr(Transformer.from_crs(7789, 8401)) == \
408-
(
409-
"<Transformation Transformer: helmert>\n"
410-
"ITRF2014 to ETRF2014 (1)"
411-
)
407+
assert repr(Transformer.from_crs(7789, 8401)) == (
408+
"<Transformation Transformer: helmert>\n" "ITRF2014 to ETRF2014 (1)"
409+
)
412410

413-
assert repr(Transformer.from_crs(4326, 3857)) == \
414-
(
415-
"<Conversion Transformer: pipeline>\n"
416-
"Popular Visualisation Pseudo-Mercator"
417-
)
411+
assert repr(Transformer.from_crs(4326, 3857)) == (
412+
"<Conversion Transformer: pipeline>\n" "Popular Visualisation Pseudo-Mercator"
413+
)
418414

419-
assert repr(Transformer.from_crs(4326, 26917)) == \
420-
(
421-
"<Unknown Transformer: unknown>\n"
422-
"unavailable until proj_trans is called"
423-
)
415+
assert repr(Transformer.from_crs(4326, 26917)) == (
416+
"<Unknown Transformer: unknown>\n" "unavailable until proj_trans is called"
417+
)

0 commit comments

Comments
 (0)