repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | "foo" | assert | string_literal | tests/test_observers/test_file_storage_observer.py | test_fs_observer_equality | 308 | null | |
IDSIA/sacred | from __future__ import division, print_function, unicode_literals, absolute_import
import datetime
import os
import tempfile
import io
import pytest
tinydb = pytest.importorskip("tinydb")
hashfs = pytest.importorskip("hashfs")
from tinydb import Query
from sacred.dependencies import get_digest
from sacred.observer... | ["about"] | assert | collection | tests/test_observers/test_tinydb_reader.py | test_fetch_files_function | 290 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | [2] | assert | collection | tests/test_config/test_signature.py | test_construct_arguments_without_options_returns_same_args_kwargs | 276 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | True | assert | bool_literal | tests/test_config/test_config_dict.py | test_conf_scope_contains_presets | 110 | null | |
IDSIA/sacred | import datetime
import pytest
import json
import os
from sacred.observers import S3Observer
moto = pytest.importorskip("moto")
boto3 = pytest.importorskip("boto3")
pytest.importorskip("botocore")
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
BUCKET = "pytest-s3-observ... | _id2 | assert | variable | tests/test_observers/test_s3_observer.py | test_fs_observer_started_event_increments_run_id | 109 | null | |
IDSIA/sacred | from datetime import datetime
import mock
import os
import pytest
import tempfile
import sys
from sacred.run import Run
from sacred.config.config_summary import ConfigSummary
from sacred.utils import (
ObserverError,
SacredInterrupt,
TimeoutInterrupt,
apply_backspaces_and_linefeeds,
)
def run():
c... | "" | assert | string_literal | tests/test_run.py | test_run_state_attributes | 44 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | vararg | assert | variable | tests/test_config/test_signature.py | test_constructor_extract_vararg_name | 148 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | "t" | assert | string_literal | tests/test_config/test_config_dict.py | test_fixing_nested_dicts | 59 | null | |
IDSIA/sacred | import datetime
import mock
import pytest
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
pymongo = pytest.importorskip("pymongo")
mongomock = pytest.importorskip("mongomock")
import gridfs
from mongomock.gridfs import enable_gridfs_integration
enable_gridfs_integration()
import pymongo.err... | 2 | assert | numeric_literal | tests/test_observers/test_queue_mongo_observer.py | test_log_metrics | 244 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config.config_scope import (
ConfigScope,
dedent_function_body,
dedent_line,
get_function_body,
is_empty_or_comment,
)
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_scope():
@ConfigScope
def cfg():
... | "b" | assert | string_literal | tests/test_config/test_config_scope.py | test_fixing_nested_dicts | 92 | null | |
IDSIA/sacred | from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
def test_experiment_run_access_subingredient():
somemod = Ingredient("somemod")
@somemod.config
def cfg():
a = 5
b = "foo"
ex = Experiment("some_experiment", ingredients=[somemod])
... | "foo" | assert | string_literal | tests/test_modules.py | test_experiment_run_access_subingredient | 79 | null | |
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | [_id] | assert | collection | tests/test_observers/test_file_storage_observer.py | test_fs_observer_started_event_creates_rundir_with_filesystem_delay | 108 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | 1 | assert | numeric_literal | tests/test_experiment.py | test_fails_on_nested_unused_config_updates | 104 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict
def test_overwrite_fallback():
d = DogmaticDict(fallback={"a": 23})
d["a"] = 0
assert d["a"] == | 0 | assert | numeric_literal | tests/test_config/test_dogmatic_dict.py | test_overwrite_fallback | 130 | null | |
IDSIA/sacred | import os
import re
import tempfile
import pytest
from sacred.config.config_files import HANDLER_BY_EXT, load_config_file
data = {"foo": 42, "baz": [1, 0.2, "bar", True, {"some_number": -12, "simon": "hugo"}]}
@pytest.mark.parametrize("ext, handler", HANDLER_BY_EXT.items())
def test_load_config_file(ext, handler):
... | data | assert | variable | tests/test_config/test_config_files.py | test_load_config_file | 31 | null | |
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | metrics | assert | variable | tests/test_observers/test_file_storage_observer.py | test_log_metrics | 357 | null | |
IDSIA/sacred | from datetime import datetime
import mock
import os
import pytest
import tempfile
import sys
from sacred.run import Run
from sacred.config.config_summary import ConfigSummary
from sacred.utils import (
ObserverError,
SacredInterrupt,
TimeoutInterrupt,
apply_backspaces_and_linefeeds,
)
def run():
c... | run.info | assert | complex_expr | tests/test_run.py | test_run_heartbeat_event | 129 | null | |
IDSIA/sacred | import os.path
import os
from pathlib import Path
import mock
import pytest
from sacred.dependencies import (
PEP440_VERSION_PATTERN,
PackageDependency,
Source,
gather_sources_and_dependencies,
get_digest,
get_py_file_if_possible,
is_local_source,
)
import sacred.optional as opt
TEST_DIREC... | is_local | assert | variable | tests/test_dependencies.py | test_is_local_source | 245 | null | |
IDSIA/sacred | from __future__ import division, print_function, unicode_literals, absolute_import
import os
import datetime
import tempfile
import io
import pytest
tinydb = pytest.importorskip("tinydb")
hashfs = pytest.importorskip("hashfs")
from tinydb import TinyDB
from hashfs import HashFS
from sacred.dependencies import get_... | 2 | assert | numeric_literal | tests/test_observers/test_tinydb_observer.py | test_tinydb_observer_started_event_saves_given_sources | 132 | null | |
IDSIA/sacred | import datetime
import mock
import random
import sacred.optional as opt
from sacred.config.captured_function import create_captured_function
from sacred.settings import SETTINGS
def test_create_captured_function():
def foo():
"""my docstring"""
return 42
cf = create_captured_function(foo)
... | "foo" | assert | string_literal | tests/test_config/test_captured_functions.py | test_create_captured_function | 19 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict
def test_dict_interface_update_with_kwargs():
d = DogmaticDict()
d["a"] = 12
d["b"] = "foo"
d.update(a=2, b=3)
assert d["a"] == 2
assert d["b"] == | 3 | assert | numeric_literal | tests/test_config/test_dogmatic_dict.py | test_dict_interface_update_with_kwargs | 60 | null | |
IDSIA/sacred | import os
import pytest
import tempfile
from sacred.config import ConfigScope, ConfigDict
from sacred.dependencies import Source, PackageDependency
from sacred.experiment import Experiment
from sacred.ingredient import Ingredient
from sacred.utils import CircularDependencyError
from sacred.serializer import json
def ... | info | assert | variable | tests/test_ingredients.py | test_get_experiment_info | 240 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | 3 | assert | numeric_literal | tests/test_experiment.py | test_fails_on_unused_config_updates | 84 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | 4 | assert | numeric_literal | tests/test_experiment.py | test_considers_captured_functions_for_fail_on_unused_config | 127 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_nested_dict_revelation():
d1 = DogmaticDict({"a": 7, "b": 12})
d2 = DogmaticDict({"c": 7})
l = DogmaticList([d1, 2, d2])
# assert l.revelation() == {'0.a', '0.b', '2.c'}
l.revelation()
assert "a" in... | l[2] | assert | complex_expr | tests/test_config/test_dogmatic_list.py | test_nested_dict_revelation | 142 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_list_interface_getitem():
l = DogmaticList([0, 1, 2])
assert l[0] == 0
assert l[1] == | 1 | assert | numeric_literal | tests/test_config/test_dogmatic_list.py | test_list_interface_getitem | 98 | null | |
IDSIA/sacred | import datetime
import mock
import pytest
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
pymongo = pytest.importorskip("pymongo")
mongomock = pytest.importorskip("mongomock")
import gridfs
from mongomock.gridfs import enable_gridfs_integration
enable_gridfs_integration()
import pymongo.err... | info | assert | variable | tests/test_observers/test_queue_mongo_observer.py | test_mongo_observer_heartbeat_event_updates_run | 117 | null | |
IDSIA/sacred | import pytest
from sacred.host_info import get_host_info, host_info_getter, host_info_gatherers
def test_host_info_decorator():
try:
assert "greeting" not in host_info_gatherers
@host_info_getter
def greeting():
return "hello"
assert "greeting" in host_info_gatherers
... | greeting | assert | variable | tests/test_host_info.py | test_host_info_decorator | 29 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | [1] | assert | collection | tests/test_config/test_signature.py | test_construct_arguments_for_bound_method | 355 | null | |
IDSIA/sacred | import pytest
from sacred.config import ConfigScope, ConfigDict, chain_evaluate_config_scopes
def test_chained_config_scopes_contain_combined_keys():
@ConfigScope
def cfg1():
a = 10
@ConfigScope
def cfg2():
b = 20
final_cfg, summary = chain_evaluate_config_scopes([cfg1, cfg2])
... | {"a", "b"} | assert | collection | tests/test_config/test_config_scope_chain.py | test_chained_config_scopes_contain_combined_keys | 19 | null | |
IDSIA/sacred | import os
import sys
import tempfile
import pprint
import json
from collections import OrderedDict
import pytest
from sacred import Ingredient, Experiment
from sacred.commands import (
COLOR_MODIFIED,
ENDC,
COLOR_DOC,
COLOR_ADDED,
COLOR_TYPECHANGED,
ConfigEntry,
PathEntry,
_format_confi... | lines[1] | assert | complex_expr | tests/test_commands.py | test_format_config | 154 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | "10" | assert | string_literal | tests/test_experiment.py | test_additional_cli_options | 468 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import fallback_dict
def fbdict():
return fallback_dict({"fall1": 7, "fall3": True})
def test_fallback(fbdict):
assert "fall1" in fbdict
assert fbdict["fall1"] == 7
fbdict["fall1"] = 8
assert fbdict["fall1"] == | 8 | assert | numeric_literal | tests/test_config/test_fallback_dict.py | test_fallback | 28 | null | |
IDSIA/sacred | import pytest
from sacred.optional import optional_import, get_tensorflow, modules_exist
def test_optional_import():
has_pytest, pyt = optional_import("pytest")
assert has_pytest
assert pyt == | pytest | assert | variable | tests/test_optional.py | test_optional_import | 11 | null | |
IDSIA/sacred | import os.path
import os
from pathlib import Path
import mock
import pytest
from sacred.dependencies import (
PEP440_VERSION_PATTERN,
PackageDependency,
Source,
gather_sources_and_dependencies,
get_digest,
get_py_file_if_possible,
is_local_source,
)
import sacred.optional as opt
TEST_DIREC... | 3 | assert | numeric_literal | tests/test_dependencies.py | test_gather_sources_and_dependencies | 193 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | "b" | assert | string_literal | tests/test_config/test_config_dict.py | test_fixing_nested_dicts | 58 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | 9 | assert | numeric_literal | tests/test_experiment.py | test_fails_on_unused_config_updates | 82 | null | |
IDSIA/sacred | from sacred import Ingredient
from mock import patch
import pytest
import sys
from sacred import cli_option
from sacred import host_info_gatherer
from sacred.experiment import Experiment
from sacred.utils import apply_backspaces_and_linefeeds, ConfigAddedError, SacredError
def ex():
return Experiment("ator3000")... | 2 | assert | numeric_literal | tests/test_experiment.py | test_fails_on_nested_unused_config_updates | 102 | null | |
IDSIA/sacred | from __future__ import division, print_function, unicode_literals, absolute_import
import os
import datetime
import tempfile
import io
import pytest
tinydb = pytest.importorskip("tinydb")
hashfs = pytest.importorskip("hashfs")
from tinydb import TinyDB
from hashfs import HashFS
from sacred.dependencies import get_... | T2 | assert | variable | tests/test_observers/test_tinydb_observer.py | test_tinydb_observer_heartbeat_event_updates_run | 192 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict
def test_dict_interface_update_with_list_of_items():
d = DogmaticDict()
d["a"] = 12
d["b"] = "foo"
d.update([("b", 9), ("c", 7)])
assert d["a"] == 12
assert d["b"] == | 9 | assert | numeric_literal | tests/test_config/test_dogmatic_dict.py | test_dict_interface_update_with_list_of_items | 69 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_list_interface_len():
l = DogmaticList()
assert len(l) == 0
l = DogmaticList([0, 1, 2])
assert len(l) == | 3 | assert | numeric_literal | tests/test_config/test_dogmatic_list.py | test_list_interface_len | 110 | null | |
IDSIA/sacred | from datetime import datetime
import mock
import os
import pytest
import tempfile
import sys
from sacred.run import Run
from sacred.config.config_summary import ConfigSummary
from sacred.utils import (
ObserverError,
SacredInterrupt,
TimeoutInterrupt,
apply_backspaces_and_linefeeds,
)
def run():
c... | None | assert | none_literal | tests/test_run.py | test_run_state_attributes | 42 | null | |
IDSIA/sacred | import datetime
import pytest
import json
import os
from sacred.observers import S3Observer
moto = pytest.importorskip("moto")
boto3 = pytest.importorskip("boto3")
pytest.importorskip("botocore")
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
BUCKET = "pytest-s3-observ... | "QUEUED" | assert | string_literal | tests/test_observers/test_s3_observer.py | test_queued_event_updates_run_json | 194 | null | |
IDSIA/sacred | import json
import pickle
import pytest
from copy import copy, deepcopy
from sacred.config.custom_containers import make_read_only, ReadOnlyList, ReadOnlyDict
from sacred.utils import SacredError
def _contains_tuple(json_compat_obj):
x = json_compat_obj
if isinstance(x, tuple):
return True
elif is... | copied_l | assert | variable | tests/test_config/test_readonly_containers.py | test_deepcopy_on_nested_readonly_list | 279 | null | |
IDSIA/sacred | import os
import pytest
import tempfile
from sacred.config import ConfigScope, ConfigDict
from sacred.dependencies import Source, PackageDependency
from sacred.experiment import Experiment
from sacred.ingredient import Ingredient
from sacred.utils import CircularDependencyError
from sacred.serializer import json
def ... | foo | assert | variable | tests/test_ingredients.py | test_add_command | 102 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | cfg() | assert | func_call | tests/test_config/test_config_dict.py | test_conf_scope_handles_numpy_bools | 100 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import fallback_dict
def fbdict():
return fallback_dict({"fall1": 7, "fall3": True})
def test_get(fbdict):
fbdict["a"] = "b"
assert fbdict.get("a", 18) == "b"
assert fbdict.get("fall1", 18) == 7
assert fbdict.get("notexisting", 18) == 18
asse... | True | assert | bool_literal | tests/test_config/test_fallback_dict.py | test_get | 36 | null | |
IDSIA/sacred | import pytest
from sacred.serializer import flatten, restore
import sacred.optional as opt
@pytest.mark.skipif(not opt.has_numpy, reason="requires numpy")
def test_serialize_numpy_arrays():
a = opt.np.array([[1, 2, 3], [4, 5, 6]], dtype=opt.np.float32)
b = restore(flatten(a))
assert opt.np.all(b == a)
... | a.shape | assert | complex_expr | tests/test_serializer.py | test_serialize_numpy_arrays | 55 | null | |
IDSIA/sacred | from __future__ import division, print_function, unicode_literals, absolute_import
import os
import datetime
import tempfile
import io
import pytest
tinydb = pytest.importorskip("tinydb")
hashfs = pytest.importorskip("hashfs")
from tinydb import TinyDB
from hashfs import HashFS
from sacred.dependencies import get_... | m | assert | variable | tests/test_observers/test_tinydb_observer.py | test_tinydb_observer_equality | 176 | null | |
IDSIA/sacred | import pytest
import shlex
from docopt import docopt
from sacred.arg_parser import _convert_value, get_config_updates, format_usage
from sacred.experiment import gather_command_line_options
@pytest.mark.parametrize(
"value,expected",
[
("None", None),
("True", True),
("False", False),
... | expected | assert | variable | tests/test_arg_parser.py | test_convert_value | 112 | null | |
IDSIA/sacred | import os
import sys
import tempfile
import pprint
import json
from collections import OrderedDict
import pytest
from sacred import Ingredient, Experiment
from sacred.commands import (
COLOR_MODIFIED,
ENDC,
COLOR_DOC,
COLOR_ADDED,
COLOR_TYPECHANGED,
ConfigEntry,
PathEntry,
_format_confi... | lines[2] | assert | complex_expr | tests/test_commands.py | test_format_config | 155 | null | |
IDSIA/sacred | import os.path
import os
from pathlib import Path
import mock
import pytest
from sacred.dependencies import (
PEP440_VERSION_PATTERN,
PackageDependency,
Source,
gather_sources_and_dependencies,
get_digest,
get_py_file_if_possible,
is_local_source,
)
import sacred.optional as opt
TEST_DIREC... | deps | assert | variable | tests/test_dependencies.py | test_gather_sources_and_dependencies | 187 | null | |
IDSIA/sacred | import os.path
import os
from pathlib import Path
import mock
import pytest
from sacred.dependencies import (
PEP440_VERSION_PATTERN,
PackageDependency,
Source,
gather_sources_and_dependencies,
get_digest,
get_py_file_if_possible,
is_local_source,
)
import sacred.optional as opt
TEST_DIREC... | None | assert | none_literal | tests/test_dependencies.py | test_pep440_version_pattern_invalid | 62 | null | |
IDSIA/sacred | import pytest
from sacred.host_info import get_host_info, host_info_getter, host_info_gatherers
def test_host_info_decorator():
try:
assert "greeting" not in host_info_gatherers
@host_info_getter
def greeting():
return "hello"
assert "greeting" in host_info_gatherers
... | "hello" | assert | string_literal | tests/test_host_info.py | test_host_info_decorator | 30 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_list_interface_getitem():
l = DogmaticList([0, 1, 2])
assert l[0] == 0
assert l[1] == 1
assert l[2] == | 2 | assert | numeric_literal | tests/test_config/test_dogmatic_list.py | test_list_interface_getitem | 99 | null | |
IDSIA/sacred | import datetime
import mock
import random
import sacred.optional as opt
from sacred.config.captured_function import create_captured_function
from sacred.settings import SETTINGS
def test_captured_function_randomness():
def foo(_rnd, _seed):
try:
return _rnd.integers(0, 1000), _seed
exce... | nr2 | assert | variable | tests/test_config/test_captured_functions.py | test_captured_function_randomness | 55 | null | |
IDSIA/sacred | import datetime
import mock
import random
import sacred.optional as opt
from sacred.config.captured_function import create_captured_function
from sacred.settings import SETTINGS
def test_create_captured_function():
def foo():
"""my docstring"""
return 42
cf = create_captured_function(foo)
... | {} | assert | collection | tests/test_config/test_captured_functions.py | test_create_captured_function | 22 | null | |
IDSIA/sacred | import pytest
import datetime
import os
import json
from sacred.observers import GoogleCloudStorageObserver
storage = pytest.importorskip("google.cloud.storage")
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
BASEDIR = "sacred-tests"
def gcs_join(*args):
return "/... | obs_two | assert | variable | tests/test_observers/test_gcs_observer.py | test_gcs_observer_equality | 121 | null | |
IDSIA/sacred | from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
def test_ingredient_command():
m = Ingredient("somemod")
m.add_config(a=42, b="foo{}")
@m.command
def transmogrify(a, b):
return b.format(a)
assert "transmogrify" in m.commands
ass... | "foo42" | assert | string_literal | tests/test_modules.py | test_ingredient_command | 47 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_list_interface_index():
l = DogmaticList([1, 2, 4, 4, 5])
assert l.index(1) == 0
assert l.index(4) == 2
assert l.index(5) == | 4 | assert | numeric_literal | tests/test_config/test_dogmatic_list.py | test_list_interface_index | 124 | null | |
IDSIA/sacred | from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
def test_experiment_named_config_subingredient_overwrite():
somemod = Ingredient("somemod")
@somemod.capture
def get_answer(a):
return a
ex = Experiment("some_experiment", ingredients=[some... | 2 | assert | numeric_literal | tests/test_modules.py | test_experiment_named_config_subingredient_overwrite | 158 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config.config_scope import (
ConfigScope,
dedent_function_body,
dedent_line,
get_function_body,
is_empty_or_comment,
)
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_scope():
@ConfigScope
def cfg():
... | cfg | assert | variable | tests/test_config/test_config_scope.py | test_conf_scope_handles_numpy_bools | 151 | null | |
IDSIA/sacred | import os
import pytest
import tempfile
from sacred.config import ConfigScope, ConfigDict
from sacred.dependencies import Source, PackageDependency
from sacred.experiment import Experiment
from sacred.ingredient import Ingredient
from sacred.utils import CircularDependencyError
from sacred.serializer import json
def ... | None | assert | none_literal | tests/test_ingredients.py | test_capture_function | 34 | null | |
IDSIA/sacred | import datetime
import pytest
from sacred import Experiment
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
def ex():
return Experiment("Test experiment")
def test_log_scalar_metric_with_implicit_step(ex):
messages = {}
@ex.main
def main_function(_run):
for i in rang... | i | assert | variable | tests/test_metrics_logger.py | test_log_scalar_metric_with_implicit_step | 83 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | name | assert | variable | tests/test_config/test_signature.py | test_constructor_extract_function_name | 136 | null | |
IDSIA/sacred | import datetime
import mock
import random
import sacred.optional as opt
from sacred.config.captured_function import create_captured_function
from sacred.settings import SETTINGS
def test_create_captured_function():
def foo():
"""my docstring"""
return 42
cf = create_captured_function(foo)
... | None | assert | none_literal | tests/test_config/test_captured_functions.py | test_create_captured_function | 21 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict
def test_dict_interface_update_with_dict():
d = DogmaticDict()
d["a"] = 12
d["b"] = "foo"
d.update({"a": 1, "c": 2})
assert d["a"] == | 1 | assert | numeric_literal | tests/test_config/test_dogmatic_dict.py | test_dict_interface_update_with_dict | 49 | null | |
IDSIA/sacred | from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
def test_experiment_named_config_subingredient():
somemod = Ingredient("somemod")
@somemod.config
def sub_cfg():
a = 15
@somemod.capture
def get_answer(a):
return a
@somemo... | (1, 16) | assert | collection | tests/test_modules.py | test_experiment_named_config_subingredient | 134 | null | |
IDSIA/sacred | import pytest
from sacred.optional import optional_import, get_tensorflow, modules_exist
def test_optional_import_nonexisting():
has_nonex, nonex = optional_import("clearlynonexistingpackage")
assert not has_nonex
assert nonex is | None | assert | none_literal | tests/test_optional.py | test_optional_import_nonexisting | 17 | null | |
IDSIA/sacred | import datetime
import pytest
import json
import os
from sacred.observers import S3Observer
moto = pytest.importorskip("moto")
boto3 = pytest.importorskip("boto3")
pytest.importorskip("botocore")
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
BUCKET = "pytest-s3-observ... | obs_two | assert | variable | tests/test_observers/test_s3_observer.py | test_s3_observer_equality | 117 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | kwargs | assert | variable | tests/test_config/test_signature.py | test_constructor_extract_kwargs | 166 | null | |
IDSIA/sacred | import pytest
from sacred.utils import (
PATHCHANGE,
convert_to_nested_dict,
get_by_dotted_path,
is_prefix,
iter_prefixes,
iterate_flattened,
iterate_flattened_separately,
join_paths,
recursive_update,
set_by_dotted_path,
get_inheritors,
convert_camel_case_to_snake_case,... | {B, C, D} | assert | collection | tests/test_utils.py | test_get_inheritors | 132 | null | |
IDSIA/sacred | import datetime
import mock
import pytest
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
pymongo = pytest.importorskip("pymongo")
mongomock = pytest.importorskip("mongomock")
import gridfs
from mongomock.gridfs import enable_gridfs_integration
enable_gridfs_integration()
import pymongo.err... | m | assert | variable | tests/test_observers/test_queue_mongo_observer.py | test_mongo_observer_equality | 99 | null | |
IDSIA/sacred | import datetime
import pytest
from sacred.serializer import json
sqlalchemy = pytest.importorskip("sqlalchemy")
from sacred.observers.sql import SqlObserver
from sacred.observers.sql_bases import Host, Experiment, Run, Source, Resource
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5... | 2 | assert | numeric_literal | tests/test_observers/test_sql_observer.py | test_fs_observer_doesnt_duplicate_sources | 229 | null | |
IDSIA/sacred | import pytest
from sacred.serializer import flatten, restore
import sacred.optional as opt
def test_serialize_non_str_keys():
d = {1: "one", 2: "two"}
assert restore(flatten(d)) == | d | assert | variable | tests/test_serializer.py | test_serialize_non_str_keys | 46 | null | |
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | "2" | assert | string_literal | tests/test_observers/test_file_storage_observer.py | test_fs_observer_started_event_creates_rundir_with_filesystem_delay | 113 | null | |
IDSIA/sacred | import os.path
import os
from pathlib import Path
import mock
import pytest
from sacred.dependencies import (
PEP440_VERSION_PATTERN,
PackageDependency,
Source,
gather_sources_and_dependencies,
get_digest,
get_py_file_if_possible,
is_local_source,
)
import sacred.optional as opt
TEST_DIREC... | 2 | assert | numeric_literal | tests/test_dependencies.py | test_gather_sources_and_dependencies | 195 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | "string" | assert | string_literal | tests/test_config/test_config_dict.py | test_config_dict_result_contains_keys | 36 | null | |
IDSIA/sacred | import json
import pickle
import pytest
from copy import copy, deepcopy
from sacred.config.custom_containers import make_read_only, ReadOnlyList, ReadOnlyDict
from sacred.utils import SacredError
def _contains_tuple(json_compat_obj):
x = json_compat_obj
if isinstance(x, tuple):
return True
elif is... | obj | assert | variable | tests/test_config/test_readonly_containers.py | _check_serializable | 33 | null | |
IDSIA/sacred | from __future__ import division, print_function, unicode_literals, absolute_import
import datetime
import os
import tempfile
import io
import pytest
tinydb = pytest.importorskip("tinydb")
hashfs = pytest.importorskip("hashfs")
from tinydb import Query
from sacred.dependencies import get_digest
from sacred.observer... | ["setup.py"] | assert | collection | tests/test_observers/test_tinydb_reader.py | test_fetch_files_function | 297 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_append():
l = DogmaticList([1, 2])
l.append(3)
l.append(4)
assert l == | [1, 2] | assert | collection | tests/test_config/test_dogmatic_list.py | test_append | 25 | null | |
IDSIA/sacred | import pytest
from sacred.utils import (
PATHCHANGE,
convert_to_nested_dict,
get_by_dotted_path,
is_prefix,
iter_prefixes,
iterate_flattened,
iterate_flattened_separately,
join_paths,
recursive_update,
set_by_dotted_path,
get_inheritors,
convert_camel_case_to_snake_case,... | "6.2.3" | assert | string_literal | tests/test_utils.py | test_parse_version | 198 | null | |
IDSIA/sacred | import os
import sys
import tempfile
import pprint
import json
from collections import OrderedDict
import pytest
from sacred import Ingredient, Experiment
from sacred.commands import (
COLOR_MODIFIED,
ENDC,
COLOR_DOC,
COLOR_ADDED,
COLOR_TYPECHANGED,
ConfigEntry,
PathEntry,
_format_confi... | lines[5] | assert | complex_expr | tests/test_commands.py | test_format_config | 158 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict
def test_dict_interface_set_item():
d = DogmaticDict()
d["a"] = 12
d["b"] = "foo"
assert "a" in | d | assert | variable | tests/test_config/test_dogmatic_dict.py | test_dict_interface_set_item | 25 | null | |
IDSIA/sacred | from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
def test_experiment_run_access_subingredient():
somemod = Ingredient("somemod")
@somemod.config
def cfg():
a = 5
b = "foo"
ex = Experiment("some_experiment", ingredients=[somemod])
... | 5 | assert | numeric_literal | tests/test_modules.py | test_experiment_run_access_subingredient | 78 | null | |
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | 2 | assert | numeric_literal | tests/test_observers/test_file_storage_observer.py | test_log_metrics | 356 | null | |
IDSIA/sacred | import datetime
import mock
import pytest
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
pymongo = pytest.importorskip("pymongo")
mongomock = pytest.importorskip("mongomock")
import gridfs
from mongomock.gridfs import enable_gridfs_integration
enable_gridfs_integration()
import pymongo.err... | 1 | assert | numeric_literal | tests/test_observers/test_queue_mongo_observer.py | test_mongo_observer_started_event_creates_run | 63 | null | |
IDSIA/sacred | import datetime
import os
from copy import copy
import pytest
import json
from pathlib import Path
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics
T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5... | "1" | assert | string_literal | tests/test_observers/test_file_storage_observer.py | test_fs_observer_started_event_creates_rundir_with_filesystem_delay | 107 | null | |
IDSIA/sacred | import pytest
from sacred.config import ConfigScope, ConfigDict, chain_evaluate_config_scopes
def test_chained_config_scopes_cannot_modify_fixed():
@ConfigScope
def cfg1():
c = 10
a = c * 2
@ConfigScope
def cfg2(c):
b = 4 * c
c *= 3
final_cfg, summary = chain_evalu... | 5 | assert | numeric_literal | tests/test_config/test_config_scope_chain.py | test_chained_config_scopes_cannot_modify_fixed | 83 | null | |
IDSIA/sacred | from __future__ import division, print_function
import re
import pytest
from sacred.config.signature import Signature
from sacred.utils import MissingConfigError
def foo() -> None:
return
def bariza(a: int, b: float, c: str):
return a, b, c
def complex_function_name(a: int = 5, b: str = "fo", c: float = ... | [] | assert | collection | tests/test_config/test_signature.py | test_get_free_parameters | 171 | null | |
IDSIA/sacred | import pytest
import sacred.optional as opt
from sacred.config import ConfigDict
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def conf_dict():
cfg = ConfigDict(
{
"a": 1,
"b": 2.0,
"c": True,
"d": "string",
"e": [1, 2, 3]... | value | assert | variable | tests/test_config/test_config_dict.py | test_config_dict_accepts_special_types | 53 | null | |
IDSIA/sacred | import pytest
from sacred.config.custom_containers import DogmaticDict, DogmaticList
def test_list_interface_getitem():
l = DogmaticList([0, 1, 2])
assert l[0] == | 0 | assert | numeric_literal | tests/test_config/test_dogmatic_list.py | test_list_interface_getitem | 97 | null | |
IDSIA/sacred | import pytest
from sacred.utils import (
PATHCHANGE,
convert_to_nested_dict,
get_by_dotted_path,
is_prefix,
iter_prefixes,
iterate_flattened,
iterate_flattened_separately,
join_paths,
recursive_update,
set_by_dotted_path,
get_inheritors,
convert_camel_case_to_snake_case,... | {"a": 12} | assert | collection | tests/test_utils.py | test_get_by_dotted_path | 74 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime, timezone
from pprint import pformat
from typing import (
TYPE_CHECKING,
Any,
Literal,
)
from decorator import decorator
from . import warnings
from .error import R... | pd.DataFrame(columns=['x', 'error'])) | assert_* | func_call | src/my/core/pandas.py | test_as_dataframe | 230 | null | |
karlicoss/HPI | from __future__ import annotations
import datetime
import warnings
from collections.abc import Callable
from dataclasses import asdict, is_dataclass
from decimal import Decimal
from functools import cache
from pathlib import Path
from typing import Any, NamedTuple
from .error import error_to_json
from .pytest import ... | {"x": 10, "y": 10.0} | assert | collection | src/my/core/serialize.py | test_dumps | 241 | null | |
karlicoss/HPI | from ..cfg import tmp_config
def _init_default_config() -> None:
import my.config
class default_config:
count = 5
my.config.simple = default_config # type: ignore[assignment,misc]
def test_tmp_config() -> None:
## ugh. ideally this would be on the top level (would be a better test)
## b... | 3 | assert | numeric_literal | src/my/core/tests/test_tmp_config.py | test_tmp_config | 27 | null | |
karlicoss/HPI | from collections.abc import Iterator
import pytest
from more_itertools import one
from my.bluemaestro import Measurement, measurements
from my.core.cfg import tmp_config
from .common import testdata
def ok_measurements() -> Iterator[Measurement]:
for m in measurements():
assert not isinstance(m, Excepti... | 0 | assert | numeric_literal | src/my/tests/bluemaestro.py | test | 22 | null | |
karlicoss/HPI | import json
import warnings
from collections.abc import Iterator
from datetime import datetime
from pathlib import Path
from typing import NamedTuple
from ..denylist import DenyList
def data() -> Iterator[IP]:
# random IP addresses
yield IP(addr="67.98.113.0", dt=datetime(2020, 1, 1))
yield IP(addr="59.40... | 1 | assert | numeric_literal | src/my/core/tests/denylist.py | test_denylist | 53 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import traceback
from collections.abc import Callable, Iterable, Iterator
from datetime import date, datetime
from itertools import tee
from typing import Any, Literal, cast
from .types import Json
from .warnings import medium
ErrorPolicy = Literal["yield", "raise", "drop... | [] | assert | collection | src/my/core/error.py | test_sort_res_by | 150 | null | |
karlicoss/HPI | import os
import sys
from pathlib import Path
import pytest
import pytz
import my.config
from my.core import notnone
from my.demo import items, make_config
from .common import tmp_environ_set
@pytest.mark.parametrize('run_id', ['1', '2'])
def test_my_config_env_variable(tmp_path: Path, run_id: str) -> None:
"""... | f'xxx_{run_id}' | assert | string_literal | src/my/core/tests/test_config.py | test_my_config_env_variable | 155 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.