Skip to content

Commit

Permalink
Warn if a profile is inialized with affine and transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Gillies committed Jul 7, 2016
1 parent 7d09f2c commit cc175b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rasterio/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def __init__(self, data={}, **kwds):
initdata.update(**kwds)

if 'affine' in initdata and 'transform' in initdata:
raise TypeError("affine and transform cannot both be specified")
warnings.warn("affine item is deprecated, use transform only",
DeprecationWarning)
del initdata['affine']
elif 'affine' in initdata:
warnings.warn("affine item is deprecated, use transform instead",
DeprecationWarning)
Expand Down
12 changes: 8 additions & 4 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ def test_profile_affine_stashing(recwarn):
assert profile['transform'] == 'foo'


def test_profile_mixed_error():
"""Passing both affine and transform raises TypeError"""
with pytest.raises(TypeError):
Profile(affine='foo', transform='bar')
def test_profile_mixed_error(recwarn):
"""Warn if both affine and transform are passed"""
warnings.simplefilter('always')
profile = Profile(affine='foo', transform='bar')
assert len(recwarn) == 1
assert recwarn.pop(DeprecationWarning)
assert 'affine' not in profile
assert profile['transform'] == 'bar'


def test_profile_affine_alias(recwarn):
Expand Down

0 comments on commit cc175b6

Please sign in to comment.