repo_id stringclasses 400
values | commit_sha stringclasses 400
values | commit_index int32 0 951 | in_repo_split stringclasses 1
value | cross_repo_split stringclasses 1
value | test_file stringlengths 7 121 | test_function stringlengths 1 108 | assertion_type stringclasses 32
values | difficulty stringclasses 8
values | context_lines int32 3 600 | prefix large_stringlengths 44 113k | target large_stringlengths 1 498 | anchor_sha stringclasses 400
values | anchor_index int32 0 951 | qna_source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_repr | assert | func_call | 16 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
@pytest.mark.parametrize('provider', TESTABLE_DRIVERS)
def test_repr(driver_path... | repr(db) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_invalid_key_types | assert | func_call | 28 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
@pytest.mark.parametrize('provider', TESTABLE_DRIVERS)
def test_invalid_key_type... | str(exc) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_normalize_filepath | assert | variable | 28 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
@pytest.mark.parametrize('provider', ['sqlite'])
def test_normalize_filepath(pro... | first_path | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_normalize_base | assert | func_call | 15 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
def test_normalize_base(tmpdir):
from terracotta.drivers import MetaStore
... | str(tmpdir) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_get_driver_invalid | pytest.raises | variable | 14 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
def test_get_driver_invalid():
from terracotta import drivers
with pyte... | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_version_match | assert | complex_expr | 21 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
@pytest.mark.parametrize('provider', TESTABLE_DRIVERS)
def test_version_match(dr... | db.db_version | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_drivers.py | test_broken_connection | pytest.raises | variable | 28 | import pytest
TESTABLE_DRIVERS = ['sqlite', 'mysql', 'postgresql']
DRIVER_CLASSES = {
'sqlite': 'SQLiteMetaStore',
'sqlite-remote': 'SQLiteRemoteMetaStore',
'mysql': 'MySQLMetaStore',
'postgresql': 'PostgreSQLMetaStore'
}
@pytest.mark.parametrize('provider', TESTABLE_DRIVERS)
def test_broken_connectio... | RuntimeError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_paths.py | test_invalid_paths | pytest.raises | variable | 34 | import pytest
TEST_CASES = {
'{provider}://root@localhost:5000/test': dict(
username='root', password=None, host='localhost', port=5000, database='test'
),
'root@localhost:5000/test': dict(
username='root', password=None, host='localhost', port=5000, database='test'
),
'{provider}:/... | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_paths.py | test_path_parsing | assert | func_call | 38 | import pytest
TEST_CASES = {
'{provider}://root@localhost:5000/test': dict(
username='root', password=None, host='localhost', port=5000, database='test'
),
'root@localhost:5000/test': dict(
username='root', password=None, host='localhost', port=5000, database='test'
),
'{provider}:/... | TEST_CASES[case].get(attr, None) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_where | assert | numeric_literal | 40 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | 3 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_where | assert | numeric_literal | 43 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | 2 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_pagination | assert | numeric_literal | 46 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | 1 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_raster_cache | assert | numeric_literal | 49 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_where | assert | collection | 50 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | {} | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_raster_drivers.py | test_raster_retrieval | assert_* | variable | 58 | import pytest
import platform
import time
import numpy as np
from terracotta import exceptions
DRIVERS = ['sqlite'] # A single MetaStore suffices for testing the RasterStore
METADATA_KEYS = ('bounds', 'range', 'mean', 'stdev', 'percentiles', 'metadata')
def dynamic_non_writable_db(monkeypatch, driver_path, provid... | data2) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_remote_database_cache | assert | collection | 63 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | {} | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_remote_database | assert | variable | 59 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | keys | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_invalid_url | pytest.raises | variable | 54 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_destructor | assert | complex_expr | 65 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | captured.err | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_remote_database_cache | assert | variable | 70 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | modification_date | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_nonexisting_url | pytest.raises | complex_expr | 55 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | exceptions.InvalidDatabaseError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/drivers/test_sqlite_remote.py | test_immutability | pytest.raises | complex_expr | 60 | import os
import tempfile
import time
import uuid
from pathlib import Path
import pytest
from terracotta import exceptions
boto3 = pytest.importorskip('boto3')
moto = pytest.importorskip('moto')
def mock_aws_env(monkeypatch):
with monkeypatch.context() as m:
m.setenv('AWS_DEFAULT_REGION', 'us-east-1')
... | exceptions.DatabaseNotWritableError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_colormap.py | test_colormap_handler | assert | numeric_literal | 12 | import numpy as np
from PIL import Image
import pytest
def test_colormap_handler():
from terracotta.handlers import colormap
cmap = colormap.colormap(colormap='jet', stretch_range=[0., 1.], num_values=50)
assert cmap
assert len(cmap) == 50
assert len(cmap[0]['rgba']) == | 4 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_colormap.py | test_colormap_handler | assert | numeric_literal | 11 | import numpy as np
from PIL import Image
import pytest
def test_colormap_handler():
from terracotta.handlers import colormap
cmap = colormap.colormap(colormap='jet', stretch_range=[0., 1.], num_values=50)
assert cmap
assert len(cmap) == | 50 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_colormap.py | test_colormap_range | assert_* | variable | 18 | import numpy as np
from PIL import Image
import pytest
@pytest.mark.parametrize('stretch_range', [[0, 0.1], [20000, 30000], [-50000, 50000]])
def test_colormap_range(stretch_range):
"""Ensure that all colors from colormap file are present in returned data"""
from terracotta.cmaps import get_cmap
from terr... | cmap_out_arr) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_compute.py | test_compute_handler | assert | complex_expr | 18 | from PIL import Image
import numpy as np
def test_compute_handler(use_testdb, raster_file_xyz):
import terracotta
from terracotta.handlers import compute
settings = terracotta.get_settings()
raw_img = compute.compute(
'v1 + v2',
['val21', 'x'],
{'v1': 'val22', 'v2': 'val23'},
... | settings.DEFAULT_TILE_SIZE | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_compute.py | test_compute_consistency | assert_* | func_call | 29 | from PIL import Image
import numpy as np
def test_compute_consistency(use_testdb, testdb, raster_file_xyz):
import terracotta
from terracotta.xyz import get_tile_data
from terracotta.handlers import compute
from terracotta.image import to_uint8
settings = terracotta.get_settings()
raw_img = c... | to_uint8(v1 + v2, 0, 10000)) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_compute.py | test_compute_transparency_nan | assert_* | func_call | 25 | from PIL import Image
import numpy as np
def test_compute_transparency_nan(use_testdb, testdb, raster_file_xyz):
import terracotta
from terracotta.xyz import get_tile_data
from terracotta.handlers import compute
raw_img = compute.compute(
'where(v1 > 0, nan, v1 + v2)',
['val21', 'x'],
... | np.where(v1.mask | (v1 > 0), 0, 255)) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_datasets.py | test_datasets_handler | assert | collection | 8 | def test_datasets_handler(testdb, use_testdb):
import terracotta
from terracotta.handlers import datasets
driver = terracotta.get_driver(str(testdb))
keys = driver.key_names
assert datasets.datasets()
assert datasets.datasets() == | [dict(zip(keys, pair)) for pair in driver.get_datasets().keys()] | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_keys.py | test_key_handler | assert | complex_expr | 10 | def test_key_handler(testdb, use_testdb):
import terracotta
from terracotta.handlers import keys
driver = terracotta.get_driver(str(testdb))
handler_response = keys.keys()
assert handler_response
assert tuple(row['key'] for row in handler_response) == | driver.key_names | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_metadata.py | test_metadata_handler | assert | collection | 7 | def test_metadata_handler(use_testdb):
from terracotta.handlers import metadata, datasets
ds = datasets.datasets()[0]
md = metadata.metadata(ds)
assert md
assert md['metadata'] == | ['extra_data'] | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_rgb.py | test_rgb_tile_size | assert | collection | 12 | from PIL import Image
import numpy as np
import pytest
def test_rgb_tile_size(use_testdb, raster_file, raster_file_xyz):
from terracotta.handlers import rgb
raw_img = rgb.rgb(['val21', 'x'], ['val22', 'val23', 'val24'], raster_file_xyz,
tile_size=(100, 100))
img_data = np.asarray(Ima... | (100, 100, 3) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_rgb.py | test_rgb_out_of_bounds | assert | func_call | 13 | from PIL import Image
import numpy as np
import pytest
def test_rgb_out_of_bounds(use_testdb, raster_file):
import terracotta
from terracotta.handlers import rgb
with pytest.raises(terracotta.exceptions.TileOutOfBoundsError) as excinfo:
rgb.rgb(['val21', 'x'], ['val22', 'val23', 'val24'], (10, 0,... | str(excinfo.value) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_rgb.py | test_rgb_invalid_keys | pytest.raises | complex_expr | 11 | from PIL import Image
import numpy as np
import pytest
def test_rgb_invalid_keys(use_testdb, raster_file_xyz):
from terracotta import exceptions
from terracotta.handlers import rgb
with pytest.raises( | exceptions.InvalidArgumentsError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_rgb.py | test_rgb_out_of_bounds | pytest.raises | complex_expr | 11 | from PIL import Image
import numpy as np
import pytest
def test_rgb_out_of_bounds(use_testdb, raster_file):
import terracotta
from terracotta.handlers import rgb
with pytest.raises( | terracotta.exceptions.TileOutOfBoundsError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_rgb.py | test_rgb_handler | assert | collection | 12 | from PIL import Image
import numpy as np
import pytest
def test_rgb_handler(use_testdb, raster_file, raster_file_xyz):
import terracotta
from terracotta.handlers import rgb
raw_img = rgb.rgb(['val21', 'x'], ['val22', 'val23', 'val24'], raster_file_xyz)
img_data = np.asarray(Image.open(raw_img))
a... | (*terracotta.get_settings().DEFAULT_TILE_SIZE, 3) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_singleband.py | test_singleband_tile_size | assert | variable | 16 | from PIL import Image
import numpy as np
import pytest
def test_singleband_tile_size(use_testdb, raster_file_xyz):
from terracotta.handlers import datasets, singleband
ds = datasets.datasets()
test_tile_size = (16, 32)
for keys in ds:
raw_img = singleband.singleband(keys, raster_file_xyz, ti... | test_tile_size | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_singleband.py | test_singleband_noxyz | assert | complex_expr | 17 | from PIL import Image
import numpy as np
import pytest
def test_singleband_noxyz(use_testdb):
from terracotta import get_settings
from terracotta.handlers import singleband
settings = get_settings()
ds_keys = ['val21', 'x', 'val22']
raw_img = singleband.singleband(ds_keys)
img_data = np.asar... | settings.DEFAULT_TILE_SIZE | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/handlers/test_singleband.py | test_singleband_out_of_bounds | pytest.raises | complex_expr | 13 | from PIL import Image
import numpy as np
import pytest
def test_singleband_out_of_bounds(use_testdb):
import terracotta
from terracotta.handlers import datasets, singleband
ds = datasets.datasets()
for keys in ds:
with pytest.raises( | terracotta.exceptions.TileOutOfBoundsError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_logging_visible | assert | numeric_literal | 19 | import pytest
from click.testing import CliRunner
@pytest.mark.parametrize('level', ['debug', 'info'])
def test_logging_visible(level):
from terracotta.scripts.cli import cli
@cli.command('dummy')
def dummy():
import logging
logger = logging.getLogger('terracotta')
logger.info('tes... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_entrypoint_exception | assert | numeric_literal | 19 | import pytest
from click.testing import CliRunner
def test_entrypoint_exception(monkeypatch, capsys):
import sys
from terracotta.scripts.cli import cli, entrypoint
dummy_error_message = 'Dummy error message'
@cli.command('dummy')
def dummy():
raise RuntimeError(dummy_error_message)
w... | 1 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_entrypoint | pytest.raises | variable | 11 | import pytest
from click.testing import CliRunner
def test_entrypoint(monkeypatch, capsys):
import sys
from terracotta.scripts.cli import entrypoint
with monkeypatch.context() as m:
m.setattr(sys, 'argv', ['terracotta'])
with pytest.raises( | SystemExit) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_entrypoint | assert | complex_expr | 16 | import pytest
from click.testing import CliRunner
def test_entrypoint(monkeypatch, capsys):
import sys
from terracotta.scripts.cli import entrypoint
with monkeypatch.context() as m:
m.setattr(sys, 'argv', ['terracotta'])
with pytest.raises(SystemExit) as exc:
entrypoint()
... | captured.out | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_entrypoint_exception | assert | complex_expr | 22 | import pytest
from click.testing import CliRunner
def test_entrypoint_exception(monkeypatch, capsys):
import sys
from terracotta.scripts.cli import cli, entrypoint
dummy_error_message = 'Dummy error message'
@cli.command('dummy')
def dummy():
raise RuntimeError(dummy_error_message)
w... | captured.err | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_cli.py | test_logging_visible | assert | complex_expr | 20 | import pytest
from click.testing import CliRunner
@pytest.mark.parametrize('level', ['debug', 'info'])
def test_logging_visible(level):
from terracotta.scripts.cli import cli
@cli.command('dummy')
def dummy():
import logging
logger = logging.getLogger('terracotta')
logger.info('tes... | result.output | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_connect.py | test_connect | assert | numeric_literal | 9 | from click.testing import CliRunner
def test_connect(test_server):
from terracotta.scripts import cli
runner = CliRunner()
result = runner.invoke(cli.cli, ['connect', test_server, '--no-browser'])
assert result.exit_code == | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_connect.py | test_connect_invalid_port | assert | complex_expr | 10 | from click.testing import CliRunner
def test_connect_invalid_port():
from terracotta.scripts import cli
runner = CliRunner()
result = runner.invoke(cli.cli, ['connect', 'localhost:5556', '--no-browser'])
assert result.exit_code != 0
assert 'Could not connect' in | result.output | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest | assert | numeric_literal | 119 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | _assert_datasets_equal | assert | numeric_literal | 115 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | 1 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | _assert_datasets_equal | assert | variable | 116 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | datasets | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest | assert | collection | 124 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | ('name',) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest_append_invalid | assert | complex_expr | 128 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | result.output | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest_rgb_key | assert | collection | 126 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | ('foo', 'rgb') | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest_invalid_pattern | assert | func_call | 126 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | result.output.lower() | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_ingest.py | test_ingest | assert | collection | 125 | import pytest
from click.testing import CliRunner
import os
import shutil
TEST_CASES = (
{ # basic
'filenames': ['foo.tif'],
'input_pattern': '{name}.tif',
'expected_keys': ['name'],
'expected_datasets': [('foo',)]
},
{ # two keys
'filenames': ['S2_20180101_B04.ti... | {('img',): str(raster_file)} | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_optimize_rasters | assert | numeric_literal | 60 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_reoptimize | assert | numeric_literal | 61 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | 2 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_reoptimize | assert | variable | 56 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | ctime | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_optimize_rasters | assert_* | func_call | 74 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | src2.read()) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_optimize_rasters_nofiles | assert | complex_expr | 41 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | result.output | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_optimize_rasters.py | test_exception_in_subprocess | assert | func_call | 53 | import os
import warnings
import traceback
import rasterio
import numpy as np
from click.testing import CliRunner
import pytest
def format_exception(result):
return ''.join(traceback.format_exception(*result.exc_info))
def tiny_raster_file(unoptimized_raster_file, tmpdir_factory):
tmpdir = tmpdir_factory.m... | str(result.exception) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_serve.py | test_serve_from_pattern | assert | numeric_literal | 23 | import pytest
from click.testing import CliRunner
def toml_file(tmpdir_factory):
content = """
DEFAULT_TILE_SIZE = [64, 64]
"""
outfile = tmpdir_factory.mktemp('config').join('tc-config.toml')
with open(outfile, 'w') as f:
f.write(content)
return outfile
def test_serve_from_pattern(r... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/scripts/test_serve.py | test_serve_find_socket | assert | complex_expr | 35 | import pytest
from click.testing import CliRunner
def toml_file(tmpdir_factory):
content = """
DEFAULT_TILE_SIZE = [64, 64]
"""
outfile = tmpdir_factory.mktemp('config').join('tc-config.toml')
with open(outfile, 'w') as f:
f.write(content)
return outfile
def test_serve_find_socket(ra... | result.output | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_cors.py | test_cors | assert | numeric_literal | 33 | import json
import pytest
def get_client(metadata_origins=None, tile_origins=None):
from terracotta.server import create_app
import terracotta
if metadata_origins is not None:
terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins)
if tile_origins is not None:
terracott... | 200 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_cors.py | test_cors | assert | string_literal | 39 | import json
import pytest
def get_client(metadata_origins=None, tile_origins=None):
from terracotta.server import create_app
import terracotta
if metadata_origins is not None:
terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins)
if tile_origins is not None:
terracott... | '*' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_cors.py | test_cors | assert | variable | 44 | import json
import pytest
def get_client(metadata_origins=None, tile_origins=None):
from terracotta.server import create_app
import terracotta
if metadata_origins is not None:
terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins)
if tile_origins is not None:
terracott... | expected | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets | assert | numeric_literal | 32 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 4 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets_pagination | assert | numeric_literal | 33 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 2 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets_pagination | assert | numeric_literal | 34 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 0 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets_pagination | assert | numeric_literal | 45 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 1 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets_selective | assert | numeric_literal | 31 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 3 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_keys | assert | numeric_literal | 36 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 200 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_metadata_lazily_nonwritable_db | assert | numeric_literal | 30 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 403 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_metadata_nonexisting | assert | numeric_literal | 30 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 404 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/server/test_flask_api.py | test_get_datasets_unknown_key | assert | numeric_literal | 30 | from io import BytesIO
import json
import urllib.parse
from collections import OrderedDict
from PIL import Image
import numpy as np
import pytest
def flask_app():
from terracotta.server import create_app
return create_app()
def client(flask_app):
with flask_app.test_client() as client:
yield cli... | 400 | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_cache.py | test_get_size | assert | variable | 12 | import zlib
import numpy as np
def test_get_size():
from terracotta.cache import CompressedLFUCache
tile_shape = (256, 256)
data = zlib.compress(np.ones(tile_shape), 9)
mask = zlib.compress(np.zeros(tile_shape), 9)
size = CompressedLFUCache._get_size((data, mask, 'float64', tile_shape))
asser... | size | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_deprecation_behaviour | assert | string_literal | 16 | import json
import pytest
def test_deprecation_behaviour(monkeypatch):
from terracotta import config, exceptions, get_settings, update_settings
for deprecated_field, new_field in config.DEPRECATION_MAP.items():
with monkeypatch.context() as m:
m.setenv(f'TC_{deprecated_field}', 'foo')
... | 'foo' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_deprecation_behaviour | assert | string_literal | 26 | import json
import pytest
def test_deprecation_behaviour(monkeypatch):
from terracotta import config, exceptions, get_settings, update_settings
for deprecated_field, new_field in config.DEPRECATION_MAP.items():
with monkeypatch.context() as m:
m.setenv(f'TC_{deprecated_field}', 'foo')
... | 'bar' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_update_config | assert | string_literal | 10 | import json
import pytest
def test_update_config():
from terracotta import get_settings, update_settings
update_settings(DRIVER_PATH='test')
new_settings = get_settings()
assert new_settings.DRIVER_PATH == | 'test' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_env_config | assert | collection | 19 | import json
import pytest
def test_env_config(monkeypatch):
from terracotta import config
with monkeypatch.context() as m:
m.setenv('TC_DRIVER_PATH', 'test')
assert config.parse_config().DRIVER_PATH == 'test'
with monkeypatch.context() as m:
m.setenv('TC_DRIVER_PATH', 'test2')
... | (1, 2) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_dict_config | assert | string_literal | 10 | import json
import pytest
def test_dict_config():
from terracotta import config
settings = config.parse_config({'DRIVER_PATH': 'test3'})
assert settings.DRIVER_PATH == | 'test3' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_env_config | assert | string_literal | 15 | import json
import pytest
def test_env_config(monkeypatch):
from terracotta import config
with monkeypatch.context() as m:
m.setenv('TC_DRIVER_PATH', 'test')
assert config.parse_config().DRIVER_PATH == 'test'
with monkeypatch.context() as m:
m.setenv('TC_DRIVER_PATH', 'test2')
... | 'test2' | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_dict_config | assert | collection | 13 | import json
import pytest
def test_dict_config():
from terracotta import config
settings = config.parse_config({'DRIVER_PATH': 'test3'})
assert settings.DRIVER_PATH == 'test3'
settings = config.parse_config({'DEFAULT_TILE_SIZE': [100, 100]})
assert settings.DEFAULT_TILE_SIZE == | (100, 100) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_env_config_invalid | pytest.raises | variable | 11 | import json
import pytest
def test_env_config_invalid(monkeypatch):
from terracotta import config
with monkeypatch.context() as m:
m.setenv('TC_DEFAULT_TILE_SIZE', '[1') # unbalanced bracket
with pytest.raises( | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_terracotta_settings | pytest.raises | variable | 12 | import json
import pytest
def test_terracotta_settings():
from terracotta import config
settings = config.parse_config()
assert settings.DEFAULT_TILE_SIZE
with pytest.raises( | AttributeError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_deprecation_behaviour | assert | func_call | 14 | import json
import pytest
def test_deprecation_behaviour(monkeypatch):
from terracotta import config, exceptions, get_settings, update_settings
for deprecated_field, new_field in config.DEPRECATION_MAP.items():
with monkeypatch.context() as m:
m.setenv(f'TC_{deprecated_field}', 'foo')
... | str(warning[0]) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_config.py | test_schema_integrity | assert | func_call | 10 | import json
import pytest
def test_schema_integrity():
from terracotta import config
settings_fields = config.TerracottaSettings._fields
schema_fields = config.SettingSchema._declared_fields
assert set(settings_fields) == | set(schema_fields) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_expressions.py | test_valid_expression | assert_* | variable | 203 | import pytest
import sys
from textwrap import dedent
import numpy as np
OPERANDS = {
'v1': np.ma.masked_array(np.arange(1, 6), dtype='float64'),
'v2': np.ma.masked_array(2 * np.arange(1, 6), dtype='float64', mask=np.array([1, 1, 1, 0, 0])),
}
VALID_EXPR = (
# identity
('v1', OPERANDS['v1']),
# ... | result) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_expressions.py | test_invalid_expression | pytest.raises | variable | 201 | import pytest
import sys
from textwrap import dedent
import numpy as np
OPERANDS = {
'v1': np.ma.masked_array(np.arange(1, 6), dtype='float64'),
'v2': np.ma.masked_array(2 * np.arange(1, 6), dtype='float64', mask=np.array([1, 1, 1, 0, 0])),
}
VALID_EXPR = (
# identity
('v1', OPERANDS['v1']),
# ... | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_expressions.py | test_timeout | pytest.raises | variable | 198 | import pytest
import sys
from textwrap import dedent
import numpy as np
OPERANDS = {
'v1': np.ma.masked_array(np.arange(1, 6), dtype='float64'),
'v2': np.ma.masked_array(2 * np.arange(1, 6), dtype='float64', mask=np.array([1, 1, 1, 0, 0])),
}
VALID_EXPR = (
# identity
('v1', OPERANDS['v1']),
# ... | RuntimeError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_expressions.py | test_out_dtype | assert | func_call | 201 | import pytest
import sys
from textwrap import dedent
import numpy as np
OPERANDS = {
'v1': np.ma.masked_array(np.arange(1, 6), dtype='float64'),
'v2': np.ma.masked_array(2 * np.arange(1, 6), dtype='float64', mask=np.array([1, 1, 1, 0, 0])),
}
VALID_EXPR = (
# identity
('v1', OPERANDS['v1']),
# ... | np.dtype('int64') | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_expressions.py | test_invalid_expression | assert | func_call | 204 | import pytest
import sys
from textwrap import dedent
import numpy as np
OPERANDS = {
'v1': np.ma.masked_array(np.arange(1, 6), dtype='float64'),
'v2': np.ma.masked_array(2 * np.arange(1, 6), dtype='float64', mask=np.array([1, 1, 1, 0, 0])),
}
VALID_EXPR = (
# identity
('v1', OPERANDS['v1']),
# ... | str(raised_exc.value) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_singleband_invalid | pytest.raises | variable | 18 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_singleband_invalid():
from terracotta import image, exceptions
with pytest.raises(exceptions.InvalidArgumentsError) as exc:
image.array_to_png(np.zeros((20, 20)), colormap='unknown')
assert 'invalid color map' in str(exc... | ValueError) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_singleband | assert | complex_expr | 13 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_singleband():
from terracotta import image
testdata = np.random.randint(0, 256, size=(256, 512), dtype='uint8')
out_img = Image.open(image.array_to_png(testdata)).convert('RGBA')
out_data = np.asarray(out_img)
assert ou... | testdata.shape | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_singleband_invalid | assert | func_call | 12 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_singleband_invalid():
from terracotta import image, exceptions
with pytest.raises(exceptions.InvalidArgumentsError) as exc:
image.array_to_png(np.zeros((20, 20)), colormap='unknown')
assert 'invalid color map' in | str(exc.value) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_singleband | assert_* | complex_expr | 16 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_singleband():
from terracotta import image
testdata = np.random.randint(0, 256, size=(256, 512), dtype='uint8')
out_img = Image.open(image.array_to_png(testdata)).convert('RGBA')
out_data = np.asarray(out_img)
assert out... | out_data[..., 0]) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_contrast_stretch | assert_* | func_call | 11 | import pytest
from PIL import Image
import numpy as np
def test_contrast_stretch():
from terracotta import image
data = np.arange(0, 10)
np.t | np.arange(10, 20)) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_rgb | assert | complex_expr | 13 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_rgb():
from terracotta import image
testdata = np.random.randint(0, 256, size=(256, 512, 3), dtype='uint8')
out_img = Image.open(image.array_to_png(testdata)).convert('RGBA')
out_data = np.asarray(out_img)
assert out_da... | testdata.shape[:-1] | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_array_to_png_rgb | assert_* | complex_expr | 16 | import pytest
from PIL import Image
import numpy as np
def test_array_to_png_rgb():
from terracotta import image
testdata = np.random.randint(0, 256, size=(256, 512, 3), dtype='uint8')
out_img = Image.open(image.array_to_png(testdata)).convert('RGBA')
out_data = np.asarray(out_img)
assert out_dat... | out_data[..., :-1]) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
DHI/terracotta | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | train | train | tests/test_image.py | test_label | assert_* | func_call | 11 | import pytest
from PIL import Image
import numpy as np
def test_label():
from terracotta import image
data = np.array([15, 16, 17])
np.testing.assert_array_equal(image.label(data, [17, 15]), | np.array([2, 0, 1])) | 9897c84639f721589be21ffd94721c53f656f2b0 | 62 | v2_extractor_at_anchor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.