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
commaai/opendbc
import random import unittest import numpy as np from opendbc.car.lateral import get_max_angle_delta_vm, get_max_angle_vm from opendbc.car.tesla.teslacan import get_steer_ctrl_type from opendbc.car.tesla.values import CarControllerParams, TeslaSafetyFlags, TeslaFlags from opendbc.car.tesla.carcontroller import get_saf...
self._rx(lkas_msg_cam))
self.assertEqual
func_call
opendbc/safety/tests/test_tesla.py
test_stock_lkas_passthrough
TestTeslaSafetyBase
292
null
commaai/opendbc
import os import abc import math import unittest import importlib import numpy as np from collections.abc import Callable from opendbc.can import CANPacker from opendbc.safety import ALTERNATIVE_EXPERIENCE from opendbc.safety.tests.libsafety import libsafety_py MAX_WRONG_COUNTERS = 5 MAX_SAMPLE_VALS = 6 VEHICLE_SPEED...
3
assert
numeric_literal
opendbc/safety/tests/common.py
add_regen_tests
57
null
commaai/opendbc
import unittest import numpy as np from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety from opendbc.car.volkswagen.values import VolkswagenSafetyFlags MAX_ACCEL = 2.0 MIN_A...
self.safety.get_torque_driver_min())
self.assertEqual
func_call
opendbc/safety/tests/test_volkswagen_mqb.py
test_torque_measurements
TestVolkswagenMqbSafetyBase
118
null
commaai/opendbc
import copy from opendbc.can import CANPacker, CANParser class TestCanChecksums: def verify_checksum(self, subtests, dbc_file: str, msg_name: str, msg_addr: int, test_messages: list[bytes], checksum_field: str = 'CHECKSUM', counter_field = 'COUNTER'): """ Verify that opendbc calculates...
3
assert
numeric_literal
opendbc/can/tests/test_checksums.py
verify_fca_giorgio_crc
TestCanChecksums
32
null
commaai/opendbc
import pytest import random from opendbc.can import CANPacker, CANParser from opendbc.can.tests import TEST_DBC MAX_BAD_COUNTER = 5 class TestCanParserPacker: def test_packer(self): packer = CANPacker(TEST_DBC) for b in range(6): for i in range(256): values = {"COUNTER": i} addr, dat...
b
assert
variable
opendbc/can/tests/test_packer_parser.py
test_packer
TestCanParserPacker
19
null
commaai/opendbc
import unittest from opendbc.car.structs import CarParams import opendbc.safety.tests.common as common from opendbc.safety.tests.libsafety import libsafety_py from opendbc.safety.tests.common import CANPackerSafety class TestBody(common.SafetyTest): TX_MSGS = [[0x250, 0], [0x251, 0], [0x1, 0], [0x1, 1]...
self._tx(self._torque_cmd_msg(0, 0)))
self.assertFalse
func_call
opendbc/safety/tests/test_body.py
test_tx_hook
TestBody
44
null
commaai/opendbc
import random import unittest from opendbc.car.hyundai.values import HyundaiSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety from opendbc.safety.tests.hyunda...
self._tx(self._accel_msg(0)))
self.assertTrue
func_call
opendbc/safety/tests/test_hyundai.py
test_no_aeb_scc12
TestHyundaiLongitudinalSafety
236
null
commaai/opendbc
import os import abc import math import unittest import importlib import numpy as np from collections.abc import Callable from opendbc.can import CANPacker from opendbc.safety import ALTERNATIVE_EXPERIENCE from opendbc.safety.tests.libsafety import libsafety_py MAX_WRONG_COUNTERS = 5 MAX_SAMPLE_VALS = 6 VEHICLE_SPEED...
self.MIN_BRAKE)
self.assertGreater
complex_expr
opendbc/safety/tests/common.py
test_gas_brake_limits_correct
LongitudinalGasBrakeSafetyTest
193
null
commaai/opendbc
import unittest from opendbc.car.volkswagen.values import VolkswagenSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety MSG_LENKHILFE_3 = 0x0D0 # RX from...
self.safety.get_torque_driver_min())
self.assertEqual
func_call
opendbc/safety/tests/test_volkswagen_pq.py
test_torque_measurements
TestVolkswagenPqSafetyBase
100
null
commaai/opendbc
from hypothesis import settings, given, strategies as st import pytest from opendbc.car import gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.hyundai.interface import CarInterface from opendbc.car.hyundai.hyundaicanfd import CanBus fr...
platform
assert
variable
opendbc/car/hyundai/tests/test_hyundai.py
test_fuzzy_excluded_platforms
TestHyundaiFingerprint
243
null
commaai/opendbc
import pytest import random from opendbc.can import CANPacker, CANParser from opendbc.can.tests import TEST_DBC MAX_BAD_COUNTER = 5 class TestCanParserPacker: def test_subaru(self): # Subaru is little endian dbc_file = "subaru_global_2017_generated" msgs = [("ES_LKAS", 50)] parser = CANParser(d...
active)
pytest.approx
variable
opendbc/can/tests/test_packer_parser.py
test_subaru
TestCanParserPacker
215
null
commaai/opendbc
import pytest import random import time from collections import defaultdict from opendbc.car.can_definitions import CanData from opendbc.car.car_helpers import interfaces from opendbc.car.structs import CarParams from opendbc.car.fingerprints import FW_VERSIONS from opendbc.car.fw_versions import FW_QUERY_CONFIGS, FUZ...
brand_matches['toyota']
assert
complex_expr
opendbc/car/tests/test_fw_fingerprint.py
test_brand_ecu_matches
TestFwFingerprint
188
null
commaai/opendbc
from hypothesis import settings, given, strategies as st import pytest from opendbc.car import gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.hyundai.interface import CarInterface from opendbc.car.hyundai.hyundaicanfd import CanBus fr...
1
assert
numeric_literal
opendbc/car/hyundai/tests/test_hyundai.py
test_expected_platform_codes
TestHyundaiFingerprint
143
null
commaai/opendbc
import unittest from opendbc.car.volkswagen.values import VolkswagenSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety MSG_LENKHILFE_3 = 0x0D0 # RX from...
self.safety.get_controls_allowed())
self.assertFalse
func_call
opendbc/safety/tests/test_volkswagen_pq.py
test_cancel_button
TestVolkswagenPqLongSafety
174
null
commaai/opendbc
import pytest import random from opendbc.can import CANPacker, CANParser from opendbc.can.tests import TEST_DBC MAX_BAD_COUNTER = 5 class TestCanParserPacker: def test_parser_updated_list(self): msgs = [("CAN_FD_MESSAGE", 10), ] parser = CANParser(TEST_DBC, msgs, 0) packer = CANPacker(TEST_DBC) m...
0
assert
numeric_literal
opendbc/can/tests/test_packer_parser.py
test_parser_updated_list
TestCanParserPacker
80
null
commaai/opendbc
import unittest import numpy as np from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety from opendbc.car.volkswagen.values import VolkswagenSafetyFlags MAX_ACCEL = 2.0 MIN_A...
self._tx(self._gra_acc_01_msg(_set=1)))
self.assertFalse
func_call
opendbc/safety/tests/test_volkswagen_mqb.py
test_spam_cancel_safety_check
TestVolkswagenMqbStockSafety
144
null
commaai/opendbc
import os import abc import math import unittest import importlib import numpy as np from collections.abc import Callable from opendbc.can import CANPacker from opendbc.safety import ALTERNATIVE_EXPERIENCE from opendbc.safety.tests.libsafety import libsafety_py MAX_WRONG_COUNTERS = 5 MAX_SAMPLE_VALS = 6 VEHICLE_SPEED...
self._tx(msg))
self.assertFalse
func_call
opendbc/safety/tests/common.py
test_tx_hook_on_wrong_safety_mode
SafetyTest
938
null
commaai/opendbc
import unittest from opendbc.car.gm.values import GMSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety class TestGmCameraSafety(TestGmCameraSafetyBase): TX_...
self._tx(self._button_msg(Buttons.CANCEL)))
self.assertEqual
func_call
opendbc/safety/tests/test_gm.py
test_buttons
TestGmCameraSafety
201
null
commaai/opendbc
import copy from opendbc.can import CANPacker, CANParser class TestCanChecksums: def verify_checksum(self, subtests, dbc_file: str, msg_name: str, msg_addr: int, test_messages: list[bytes], checksum_field: str = 'CHECKSUM', counter_field = 'COUNTER'): """ Verify that opendbc calculates...
16
assert
numeric_literal
opendbc/can/tests/test_checksums.py
verify_volkswagen_mqb_crc
TestCanChecksums
95
null
commaai/opendbc
from hypothesis import settings, given, strategies as st import pytest from opendbc.car import gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.hyundai.interface import CarInterface from opendbc.car.hyundai.hyundaicanfd import CanBus fr...
{b"OE", b"OS"}
assert
collection
opendbc/car/hyundai/tests/test_hyundai.py
test_expected_platform_codes
TestHyundaiFingerprint
141
null
commaai/opendbc
from collections import defaultdict import pytest from opendbc.car.car_helpers import interfaces from opendbc.car.docs import get_all_car_docs from opendbc.car.docs_definitions import Cable, Column, PartType, Star, SupportType from opendbc.car.honda.values import CAR as HONDA from opendbc.car.values import PLATFORMS ...
car.model
assert
complex_expr
opendbc/car/tests/test_docs.py
test_naming_conventions
TestCarDocs
43
null
commaai/opendbc
import numpy as np import random import unittest import itertools from opendbc.car.toyota.values import ToyotaSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafet...
self._tx(self._lta_msg(1, 1, angle, 100)))
self.assertEqual
func_call
opendbc/safety/tests/test_toyota.py
test_lta_steer_cmd
TestToyotaSafetyAngle
218
null
commaai/opendbc
import unittest import numpy as np from opendbc.car.honda.values import HondaSafetyFlags from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.car.structs import CarParams from opendbc.safety.tests.common import CANPackerSafety, MAX_WRONG_COUNTERS HONDA_N_CO...
(controls_allowed, gas, accel))
self.assertEqual
collection
opendbc/safety/tests/test_honda.py
test_gas_safety_check
TestHondaBoschLongSafety
491
null
commaai/opendbc
import sys import time import struct from enum import IntEnum, Enum from dataclasses import dataclass class CcpClient: def __init__(self, panda, tx_addr: int, rx_addr: int, bus: int=0, byte_order: BYTE_ORDER=BYTE_ORDER.BIG_ENDIAN, debug=False): self.tx_addr = tx_addr self.rx_addr = rx_addr self.can_bus =...
4
assert
numeric_literal
opendbc/car/ccp.py
build_checksum
CcpClient
311
null
commaai/opendbc
import random import unittest import numpy as np from opendbc.car.lateral import get_max_angle_delta_vm, get_max_angle_vm from opendbc.car.tesla.teslacan import get_steer_ctrl_type from opendbc.car.tesla.values import CarControllerParams, TeslaSafetyFlags, TeslaFlags from opendbc.car.tesla.carcontroller import get_saf...
self._rx(aeb_msg_cam))
self.assertEqual
func_call
opendbc/safety/tests/test_tesla.py
test_stock_aeb_no_cancel
TestTeslaStockSafety
398
null
commaai/opendbc
import numpy as np import random import unittest import opendbc.safety.tests.common as common from opendbc.car.ford.carcontroller import MAX_LATERAL_ACCEL from opendbc.car.ford.values import FordSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py from opendbc.s...
round(curvature * self.DEG_TO_CAN))
self.assertEqual
func_call
opendbc/safety/tests/test_ford.py
test_angle_measurements
TestFordSafetyBase
232
null
commaai/opendbc
import unittest from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety from opendbc.car.rivian.values import RivianSafetyFlags from opendbc.car.rivian.riviancan import checksu...
self.safety.get_controls_allowed())
self.assertFalse
func_call
opendbc/safety/tests/test_rivian.py
test_rx_hook
TestRivianSafetyBase
110
null
commaai/opendbc
import os import math import hypothesis.strategies as st import pytest from functools import cache from hypothesis import Phase, given, settings from collections.abc import Callable from typing import Any from opendbc.car import DT_CTRL, CanData, structs from opendbc.car.car_helpers import interfaces from opendbc.car....
len(car_params.longitudinalTuning.kpBP)
assert
func_call
opendbc/car/tests/test_car_interfaces.py
test_car_interfaces
TestCarInterfaces
82
null
commaai/opendbc
from hypothesis import given, settings, strategies as st from opendbc.car import Bus from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.toyota.fingerprints import FW_VERSIONS from opendbc.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, RADAR_ACC...
len(list(result.values())[0])
assert
func_call
opendbc/car/toyota/tests/test_toyota.py
test_fw_format
TestToyotaFingerprint
110
null
commaai/opendbc
import pytest from opendbc.car.can_definitions import CanData from opendbc.car.car_helpers import FRAME_FINGERPRINT, can_fingerprint from opendbc.car.fingerprints import _FINGERPRINTS as FINGERPRINTS class TestCanFingerprint: @pytest.mark.parametrize("car_model, fingerprints", FINGERPRINTS.items()) def test_can_fi...
fingerprint
assert
variable
opendbc/car/tests/test_can_fingerprint.py
test_can_fingerprint
TestCanFingerprint
20
null
commaai/opendbc
import os import abc import math import unittest import importlib import numpy as np from collections.abc import Callable from opendbc.can import CANPacker from opendbc.safety import ALTERNATIVE_EXPERIENCE from opendbc.safety.tests.libsafety import libsafety_py MAX_WRONG_COUNTERS = 5 MAX_SAMPLE_VALS = 6 VEHICLE_SPEED...
val)
self.assertAlmostEqual
variable
opendbc/safety/tests/common.py
_common_measurement_test
SafetyTestBase
127
null
commaai/opendbc
import enum import unittest from opendbc.car.subaru.values import SubaruSafetyFlags from opendbc.car.structs import CarParams from opendbc.safety.tests.libsafety import libsafety_py import opendbc.safety.tests.common as common from opendbc.safety.tests.common import CANPackerSafety from functools import partial def l...
self._tx(self._es_uds_msg(msg)))
self.assertFalse
func_call
opendbc/safety/tests/test_subaru.py
test_es_uds_message
TestSubaruGen2LongitudinalSafety
233
null
commaai/opendbc
from opendbc.can import CANDefine from opendbc.can.tests import ALL_DBCS class TestCANDefine: def test_civic(self): dbc_file = "honda_civic_touring_2016_can_generated" defs = CANDefine(dbc_file) assert defs.dv[399] ==
defs.dv['STEER_STATUS']
assert
complex_expr
opendbc/can/tests/test_define.py
test_civic
TestCANDefine
11
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[4]
assert
complex_expr
tests/test_commands.py
test_format_config
157
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.dtype
assert
complex_expr
tests/test_serializer.py
test_serialize_numpy_arrays
54
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" i...
l[0]
assert
complex_expr
tests/test_config/test_dogmatic_list.py
test_nested_dict_revelation
140
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]...
1
assert
numeric_literal
tests/test_config/test_config_dict.py
test_config_dict_result_contains_keys
33
null
IDSIA/sacred
from sacred.config.config_scope import ConfigScope from sacred.experiment import Experiment, Ingredient def test_ingredient_config(): m = Ingredient("somemod") @m.config def cfg(): a = 5 b = "foo" assert len(m.configurations) ==
1
assert
numeric_literal
tests/test_modules.py
test_ingredient_config
16
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...
lst
assert
variable
tests/test_config/test_readonly_containers.py
_check_read_only_list
89
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_call_doesnt_modify_kwargs(): def foo(a, _log): if _log is not None: return a cf = cre...
{"a": 7}
assert
collection
tests/test_config/test_captured_functions.py
test_captured_function_call_doesnt_modify_kwargs
128
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( "update,expected", [ (None, {}), (["a=5"], {"a": 5}), (["foo.bar=6"], ...
(expected, [])
assert
collection
tests/test_arg_parser.py
test_get_config_updates
76
null
IDSIA/sacred
from sacred.stflow.internal import ContextMethodDecorator def test_context_method_decorator(): """ Ensure that ContextMethodDecorator can intercept method calls. """ class FooClass: def __init__(self, x): self.x = x def do_foo(self, y, z): print("foo") ...
5 * 10 + 6
assert
complex_expr
tests/test_stflow/test_internal.py
test_context_method_decorator
30
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 ...
"bar"
assert
string_literal
tests/test_ingredients.py
test_capture_function_with_prefix
43
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_magic_config_argument(): def foo(_config): return _config cf = create_captured_function(foo) ...
cf.config
assert
complex_expr
tests/test_config/test_captured_functions.py
test_captured_function_magic_config_argument
103
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_...
1
assert
numeric_literal
tests/test_observers/test_tinydb_observer.py
test_tinydb_observer_started_event_creates_run
66
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...
None
assert
none_literal
tests/test_observers/test_file_storage_observer.py
test_fs_observer_queued_event_creates_rundir
60
null
IDSIA/sacred
import pytest from sacred.config.custom_containers import DogmaticDict, DogmaticList def test_init(): l = DogmaticList() assert l ==
[]
assert
collection
tests/test_config/test_dogmatic_list.py
test_init
15
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[3]
assert
complex_expr
tests/test_commands.py
test_format_config
156
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_linearize_metrics(): entries = [ ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 100), ...
2
assert
numeric_literal
tests/test_metrics_logger.py
test_linearize_metrics
128
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...
tuple
assert
variable
tests/test_config/test_readonly_containers.py
test_nested_readonly_containers
176
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...
"testmod"
assert
string_literal
tests/test_dependencies.py
test_package_dependency_create_no_version
115
null
IDSIA/sacred
import datetime import os import sys from glob import glob 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 e...
T2
assert
variable
tests/test_observers/test_mongo_observer.py
test_mongo_observer_heartbeat_event_updates_run
174
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") @ex.main def main_function(_run): # First, make sure the queue is empty: assert len(ex.current_run._metrics....
0
assert
numeric_literal
tests/test_metrics_logger.py
main_function
24
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 "/...
"QUEUED"
assert
string_literal
tests/test_observers/test_gcs_observer.py
test_queued_event_updates_run_json
194
null
IDSIA/sacred
import pytest from sacred.serializer import flatten, restore import sacred.optional as opt def test_serialize_tuples(): t = (1, "two") assert restore(flatten(t)) ==
t
assert
variable
tests/test_serializer.py
test_serialize_tuples
60
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 = ...
args
assert
variable
tests/test_config/test_signature.py
test_constructor_extracts_all_arguments
142
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,...
res
assert
variable
tests/test_utils.py
test_recursive_update
31
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_linearize_metrics(): entries = [ ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 100), ...
4
assert
numeric_literal
tests/test_metrics_logger.py
test_linearize_metrics
134
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...
T2
assert
variable
tests/test_observers/test_queue_mongo_observer.py
test_mongo_observer_heartbeat_event_updates_run
115
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,...
""
assert
string_literal
tests/test_utils.py
test_join_paths
84
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
string_literal
tests/test_config/test_fallback_dict.py
test_get
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...
"1234"
assert
string_literal
tests/test_observers/test_tinydb_reader.py
test_fetch_metadata_function_with_indices
164
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 "/...
"FAILED"
assert
string_literal
tests/test_observers/test_gcs_observer.py
test_failed_event_updates_run_json
184
null
IDSIA/sacred
import pytest from sacred.serializer import flatten, restore import sacred.optional as opt @pytest.mark.parametrize( "obj", [ 12, 3.14, "mystring", "αβγδ", [1, 2.0, "3", [4]], {"foo": "bar", "answer": 42}, None, True, ], ) def test_flatten_on...
obj
assert
variable
tests/test_serializer.py
test_flatten_on_json_is_noop
24
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")...
7
assert
numeric_literal
tests/test_experiment.py
test_considers_captured_functions_for_fail_on_unused_config
126
null
IDSIA/sacred
import pytest pymongo = pytest.importorskip("pymongo") from sacred.observers.mongo import parse_mongo_db_arg, DEFAULT_MONGO_PRIORITY def test_parse_mongo_db_arg(): assert parse_mongo_db_arg("foo") ==
{"db_name": "foo"}
assert
collection
tests/test_observers/test_mongo_option.py
test_parse_mongo_db_arg
13
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...
0
assert
numeric_literal
tests/test_observers/test_tinydb_reader.py
test_fetch_metadata_function_with_exp_name
215
null
IDSIA/sacred
import pytest from sacred.config.custom_containers import fallback_dict def fbdict(): return fallback_dict({"fall1": 7, "fall3": True}) def test_getitem(fbdict): assert "foo" not in
fbdict
assert
variable
tests/test_config/test_fallback_dict.py
test_getitem
18
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(): ...
2
assert
numeric_literal
tests/test_config/test_config_scope.py
test_fixed_subentry_of_preset
258
null
IDSIA/sacred
from collections import OrderedDict from sacred.observers.queue import QueueObserver from sacred import Experiment import mock import pytest def queue_observer(): return QueueObserver(mock.MagicMock(), interval=0.01, retry_interval=0.01) def test_started_event(queue_observer): queue_observer.started_event("a...
("args",)
assert
collection
tests/test_observers/test_queue_observer.py
test_started_event
19
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_magic_logger_argument(): def foo(_log): return _log cf = create_captured_function(foo) cf.log...
cf.logger
assert
complex_expr
tests/test_config/test_captured_functions.py
test_captured_function_magic_logger_argument
92
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...
expected
assert
variable
tests/test_commands.py
test_format_entry
121
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
collection
tests/test_ingredients.py
test_capture_function_twice
51
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]...
2
assert
numeric_literal
tests/test_config/test_config_dict.py
test_fixed_subentry_of_preset
129
null
IDSIA/sacred
from sacred.config.config_scope import ConfigScope from sacred.experiment import Experiment, Ingredient def test_experiment_double_named_config(): ex = Experiment() @ex.config def config(): a = 0 d = {"e": 0, "f": 0} @ex.named_config def A(): a = 2 d = {"e": 2, "f"...
(0, 0, 0)
assert
collection
tests/test_modules.py
test_experiment_double_named_config
185
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...
i
assert
variable
tests/test_observers/test_file_storage_observer.py
test_fs_observer_heartbeat_event_updates_run
173
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,...
"foo"
assert
string_literal
tests/test_utils.py
test_join_paths
85
null
IDSIA/sacred
import datetime import os import sys from glob import glob 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 e...
2
assert
numeric_literal
tests/test_observers/test_mongo_observer.py
test_log_metrics
364
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( "argv,expected", [ ("", {}), ("run", {"COMMAND": "run"}), ("with 1 2",...
plain
assert
variable
tests/test_arg_parser.py
test_parse_individual_arguments
57
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 = ...
kw_wc
assert
variable
tests/test_config/test_signature.py
test_constructor_extract_kwargs_wildcard_name
154
null
IDSIA/sacred
import pytest from sacred.config import ConfigScope, ConfigDict, chain_evaluate_config_scopes def test_empty_chain_contains_preset_and_fixed(): final_cfg, summary = chain_evaluate_config_scopes( [], fixed={"a": 0}, preset={"a": 1, "b": 2} ) assert set(final_cfg.keys()) == {"a", "b"} assert fina...
2
assert
numeric_literal
tests/test_config/test_config_scope_chain.py
test_empty_chain_contains_preset_and_fixed
140
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 ...
True
assert
bool_literal
tests/test_ingredients.py
test_add_unobserved_command
123
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,...
"baz"
assert
string_literal
tests/test_utils.py
test_rel_path
216
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, 15)
assert
collection
tests/test_modules.py
test_experiment_named_config_subingredient
133
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 ...
1
assert
numeric_literal
tests/test_ingredients.py
test_add_config_dict
164
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]...
{"a", "b"}
assert
collection
tests/test_config/test_config_dict.py
test_fixed_subentry_of_preset
127
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,...
"7.1.2"
assert
string_literal
tests/test_utils.py
test_get_package_version
193
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...
v_copied
assert
variable
tests/test_config/test_readonly_containers.py
test_deepcopy_on_nested_readonly_list
281
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 d["c"] ==
7
assert
numeric_literal
tests/test_config/test_dogmatic_dict.py
test_dict_interface_update_with_list_of_items
70
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...
"FAILED"
assert
string_literal
tests/test_observers/test_s3_observer.py
test_failed_event_updates_run_json
181
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_call_doesnt_modify_kwargs(): def foo(a, _log): if _log is not None: return a cf = cre...
7
assert
numeric_literal
tests/test_config/test_captured_functions.py
test_captured_function_call_doesnt_modify_kwargs
127
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...
2
assert
numeric_literal
tests/test_observers/test_tinydb_reader.py
test_fetch_metadata_function_with_indices
159
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...
d
assert
variable
tests/test_config/test_readonly_containers.py
_check_read_only_dict
40
null
IDSIA/sacred
from sacred.config.config_scope import ConfigScope from sacred.experiment import Experiment, Ingredient def test_experiment_double_named_config(): ex = Experiment() @ex.config def config(): a = 0 d = {"e": 0, "f": 0} @ex.named_config def A(): a = 2 d = {"e": 2, "f"...
(2, 2, 2)
assert
collection
tests/test_modules.py
test_experiment_double_named_config
186
null
IDSIA/sacred
import pytest from sacred.config import ConfigScope, ConfigDict, chain_evaluate_config_scopes def test_chained_config_scopes_fix_subentries(): @ConfigScope def cfg1(): d = {"a": 10, "b": 20} @ConfigScope def cfg2(): pass final_cfg, summary = chain_evaluate_config_scopes( [...
0
assert
numeric_literal
tests/test_config/test_config_scope_chain.py
test_chained_config_scopes_fix_subentries
130
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_run(ex): START = 10 END = 100 STEP_SIZE = 5 messages = {} @ex.main def main_...
None
assert
none_literal
tests/test_metrics_logger.py
test_log_scalar_metric_with_run
35
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...
1
assert
numeric_literal
tests/test_observers/test_tinydb_reader.py
test_fetch_metadata_function_with_indices
162
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...
(2, 16)
assert
collection
tests/test_modules.py
test_experiment_named_config_subingredient
136
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_...
3
assert
numeric_literal
tests/test_observers/test_tinydb_observer.py
test_tinydb_observer_started_event_saves_given_sources
125
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, 4]
assert
collection
tests/test_config/test_signature.py
test_construct_arguments_completes_kwargs_from_options
288
null