def test_profile_affine_alias(recwarn): """affine is an alias for transform, with a warning""" profile = Profile(transform='foo') warnings.simplefilter('always') assert profile['affine'] == 'foo' assert len(recwarn) == 1 assert recwarn.pop(DeprecationWarning)
def test_profile_affine_stashing(recwarn): """Passing affine sets transform, with a warning""" warnings.simplefilter('always') profile = Profile(affine='foo') assert len(recwarn) == 1 assert recwarn.pop(DeprecationWarning) assert 'affine' not in profile assert profile['transform'] == 'foo'
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 _get_cleaned_write_profile(profile: rio_profiles.Profile) -> Union[dict, rio_profiles.Profile]: # Depending on the driver, different profile keys are supported if profile['driver'] == 'JPEG': # Don't copy profile keys to cleaned version that are not supported for JPEG profile_cleaned = {} for profile_key in profile: if profile_key not in ['tiled', 'compress', 'interleave', 'photometric']: profile_cleaned[profile_key] = profile[profile_key] elif profile['driver'] == 'PNG': # Don't copy profile keys to cleaned version that are not supported for JPEG profile_cleaned = {} for profile_key in profile: if profile_key not in ['tiled', 'interleave']: profile_cleaned[profile_key] = profile[profile_key] else: profile_cleaned = profile.copy() return profile_cleaned
def test_profile_affine_set(): """TypeError is raised on set of affine item""" profile = Profile() profile['transform'] = 'foo' with pytest.raises(TypeError): profile['affine'] = 'bar'
def test_base_profile_kwarg(): assert Profile(foo='bar')['foo'] == 'bar'
def test_base_profile(): assert 'driver' not in Profile()
def test_base_profile(): assert Profile()()['driver'] is None
def test_profile_affine_alias(): """affine is an alias for transform, with a warning""" profile = Profile(transform='foo') with pytest.warns(RasterioDeprecationWarning): assert profile['affine'] == 'foo'
def test_profile_mixed_error(): """Warn if both affine and transform are passed""" with pytest.warns(RasterioDeprecationWarning): profile = Profile(affine='foo', transform='bar') assert 'affine' not in profile assert profile['transform'] == 'bar'
def test_profile_affine_stashing(): """Passing affine sets transform, with a warning""" with pytest.warns(RasterioDeprecationWarning): profile = Profile(affine='foo') assert 'affine' not in profile assert profile['transform'] == 'foo'