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
Delgan/loguru
import pickle import re import sys import time import pytest from loguru import logger from .conftest import default_threading_excepthook def test_enqueue(): x = [] def sink(message): time.sleep(0.1) x.append(message) logger.add(sink, format="{message}", enqueue=True) logger.debug(...
0
assert
numeric_literal
tests/test_add_option_enqueue.py
test_enqueue
61
null
Delgan/loguru
import pytest from loguru import logger def test_multiple_activations(): def n(): return len(logger._core.activation_list) assert n() ==
0
assert
numeric_literal
tests/test_activation.py
test_multiple_activations
83
null
Delgan/loguru
import asyncio import contextlib import datetime import logging import pickle import pytest from loguru import logger from .conftest import parse def print_(message): print(message, end="") async def async_print(msg): print_(msg) def copied_logger_though_pickle(logger): pickled = pickle.dumps(logger) ...
""
assert
string_literal
tests/test_pickling.py
test_pickling_function_handler
109
null
Delgan/loguru
import gc import pickle import sys import threading import time import pytest from loguru import logger def _remove_cyclic_references(): """Prevent cyclic isolate finalizers bleeding into other tests.""" try: yield finally: gc.collect() def test_no_deadlock_if_logger_used_inside_sink_wit...
err
assert
variable
tests/test_locks.py
test_no_deadlock_if_logger_used_inside_sink_with_catch
81
null
Delgan/loguru
import itertools import time from threading import Barrier, Thread from loguru import logger def test_safe_adding_while_logging(writer): barrier = Barrier(2) counter = itertools.count() sink_1 = NonSafeSink(1) sink_2 = NonSafeSink(1) logger.add(sink_1, format="{message}", catch=False) def th...
"ccc1ddd\n"
assert
string_literal
tests/test_threading.py
test_safe_adding_while_logging
82
null
Delgan/loguru
import sys import _init from somelib import assertionerror from loguru import logger def test(*, backtrace, colorize, diagnose): logger.remove() logger.add(sys.stderr, format="", colorize=colorize, backtrace=backtrace, diagnose=diagnose) try: a, b = 1, 2 assert a ==
b
assert
variable
tests/exceptions/source/ownership/assertion_from_local.py
test
15
null
Delgan/loguru
import os import sys import threading import time from unittest.mock import Mock import pytest from loguru import logger from .conftest import check_dir @pytest.mark.parametrize("delay", [True, False]) def test_exception_during_compression_at_rotation_not_caught(freeze_time, tmp_path, capsys, delay): with freez...
OSError, match="^Compression error$")
pytest.raises
complex_expr
tests/test_filesink_compression.py
test_exception_during_compression_at_rotation_not_caught
222
null
Delgan/loguru
import sys import pytest from loguru import logger def test_extra(writer): extra = {"a": 1, "b": 9} logger.add(writer, format="{extra[a]} {extra[b]}") logger.configure(extra=extra) logger.debug("") assert writer.read() ==
"1 9\n"
assert
string_literal
tests/test_configure.py
test_extra
46
null
Delgan/loguru
import json import re import sys from loguru import logger def test_serialize_with_record_option(): sink = JsonSink() logger.add(sink, format="{message}", serialize=True, catch=False) logger.opt(record=True).info("Test", foo=123) assert sink.json["text"] == "Test\n" assert sink.dict["extra"] ==...
{"foo": 123}
assert
collection
tests/test_add_option_serialize.py
test_serialize_with_record_option
134
null
Delgan/loguru
import pytest from colorama import Back, Fore, Style from .conftest import parse @pytest.mark.parametrize( ("text", "expected"), [ ("<bg red>1</bg red>", Back.RED + "1" + Style.RESET_ALL), ("<bg BLACK>1</bg BLACK>", Back.BLACK + "1" + Style.RESET_ALL), ("<bg light-green>1</bg light-gre...
expected
assert
variable
tests/test_ansimarkup_extended.py
test_background_colors
17
null
Delgan/loguru
import copy from loguru import logger def print_(message): print(message, end="") def test_remove_from_copy(capsys): logger.add(print_, format="{message}", catch=False) logger_ = copy.deepcopy(logger) logger_.remove() logger_.info("A") logger.info("B") out, err = capsys.readouterr() ...
"B\n"
assert
string_literal
tests/test_deepcopy.py
test_remove_from_copy
60
null
Delgan/loguru
import datetime import os import sys from time import strftime from unittest.mock import Mock import freezegun import pytest import loguru from loguru import logger def _expected_fallback_time_zone(): # For some reason, Python versions and interepreters return different time zones here. return strftime("%Z")...
""
assert
string_literal
tests/test_datetime.py
test_stdout_formatting
172
null
Delgan/loguru
from loguru import logger import asyncio import sys logger.remove() logger.add(lambda m: None, format="", diagnose=True, backtrace=True, colorize=True) def test_decorate_async_generator(): @logger.catch(reraise=True) async def generator(x, y): yield x yield y async def coro(): ou...
[1, 2]
assert
collection
tests/exceptions/source/modern/decorate_async_generator.py
test_decorate_async_generator
24
null
Delgan/loguru
import pytest from loguru import logger def test_log_before_enable(writer): logger.add(writer, format="{message}") logger.disable("") logger.debug("nope") logger.enable("tests") logger.debug("yes") result = writer.read() assert result ==
"yes\n"
assert
string_literal
tests/test_activation.py
test_log_before_enable
66
null
Delgan/loguru
import re import sys import time import pytest from loguru import logger from .conftest import default_threading_excepthook def broken_sink(m): raise ValueError("Error!") def test_catch_is_false(capsys): logger.add(broken_sink, catch=False) with pytest.raises(ValueError, match="Error!"): logger...
err
assert
variable
tests/test_add_option_catch.py
test_catch_is_false
29
null
Delgan/loguru
import asyncio import logging import os import pathlib import sys import pytest from loguru import logger message = "test message" expected = message + "\n" repetitions = pytest.mark.parametrize("rep", [0, 1, 2]) def log(sink, rep=1): logger.debug("This shouldn't be printed.") i = logger.add(sink, format="...
"Test\n"
assert
string_literal
tests/test_add_sinks.py
test_custom_sink_invalid_flush
194
null
Delgan/loguru
import re import pytest from loguru import logger @pytest.mark.parametrize( "filter", [ None, lambda _: True, {}, {None: 0}, {"": False}, {"tests": False, None: True}, {"unrelated": 100}, {None: "INFO", "": "WARNING"}, ], ) def test_filtered...
"It's ok\n"
assert
string_literal
tests/test_add_option_filter.py
test_filtered_in_incomplete_frame_context
74
null
Delgan/loguru
import datetime import time from loguru import logger from .conftest import check_dir def test_file_delayed(tmp_path): file = tmp_path / "test.log" logger.add(file, format="{message}", delay=True) assert not file.exists() logger.debug("Delayed") assert file.read_text() ==
"Delayed\n"
assert
string_literal
tests/test_filesink_delay.py
test_file_delayed
22
null
Delgan/loguru
import sys import loguru from loguru._get_frame import load_get_frame_function def test_without_sys_getframe(monkeypatch): with monkeypatch.context() as context: context.delattr(sys, "_getframe") assert load_get_frame_function() ==
loguru._get_frame.get_frame_fallback
assert
complex_expr
tests/test_get_frame.py
test_without_sys_getframe
19
null
Delgan/loguru
import sys from unittest.mock import MagicMock import pytest from loguru import logger from .conftest import parse def test_before_bind(writer): logger.add(writer, format="{message}") logger.opt(record=True).bind(key="value").info("{record[level]}") assert writer.read() ==
"INFO\n"
assert
string_literal
tests/test_opt.py
test_before_bind
578
null
Delgan/loguru
import os from stat import S_IMODE import pytest from loguru import logger def set_umask(): default = os.umask(0) yield os.umask(default) @pytest.mark.parametrize("permissions", [0o777, 0o766, 0o744, 0o700, 0o611]) def test_rotation_permissions(tmp_path, permissions, set_umask): def file_permission_...
2
assert
numeric_literal
tests/test_filesink_permissions.py
test_rotation_permissions
40
null
Delgan/loguru
import io import pathlib import re from datetime import datetime import pytest from loguru import logger TEXT = "This\nIs\nRandom\nText\n123456789\nABC!DEF\nThis Is The End\n" def fileobj(): with io.StringIO(TEXT) as file: yield file def test_parse_file(tmp_path): file = tmp_path / "test.log" f...
dict(num="123456789")
assert
func_call
tests/test_parse.py
test_parse_file
23
null
Delgan/loguru
import json import re import sys from loguru import logger def test_serialize_exception_without_context(): sink = JsonSink() logger.add(sink, format="{message}", serialize=True, catch=False) logger.exception("No Error") lines = sink.json["text"].splitlines() assert lines[0] ==
"No Error"
assert
string_literal
tests/test_add_option_serialize.py
test_serialize_exception_without_context
67
null
Delgan/loguru
import sys from unittest.mock import MagicMock import pytest from loguru import logger from .conftest import parse def test_logging_within_lazy_function(writer): logger.add(writer, level=20, format="{message}") def laziness(): logger.trace("Nope") logger.warning("Yes Warn") logger.opt(...
""
assert
string_literal
tests/test_opt.py
test_logging_within_lazy_function
181
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def test_copy_no...
1
assert
numeric_literal
tests/theseus_tests/core/test_objective.py
test_copy_no_duplicate_cost_weights
451
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
f"ManifoldGaussian__{t._id}"
assert
string_literal
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_init
54
null
facebookresearch/theseus
import pytest import torch import theseus as th from tests.theseus_tests.decorators import run_if_baspacho from theseus.utils import numeric_grad torch.manual_seed(0) @run_if_baspacho() @pytest.mark.parametrize( "linear_solver_cls", [ th.CholeskyDenseSolver, th.CholmodSparseSolver, t...
1.5
assert
numeric_literal
tests/theseus_tests/optimizer/nonlinear/test_backwards.py
test_backwards_quartic
214
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
new_var.mean[j]
assert
complex_expr
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_copy
93
null
facebookresearch/theseus
import pytest # noqa: F401 import torch import theseus as th @pytest.mark.parametrize("batch_size", [1, 10]) def test_track_best_solution_matrix_vars(batch_size): x = th.SO3(name="x") y = th.SO3(name="y") objective = th.Objective() objective.add(th.Difference(x, y, th.ScaleCostWeight(1.0), name="cf")...
(batch_size, 3, 3)
assert
collection
tests/theseus_tests/optimizer/nonlinear/test_info.py
test_track_best_solution_matrix_vars
49
null
facebookresearch/theseus
import numpy as np import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.theseus_layer import _DLMPerturbation from theseus.utils import numeric_jacobian def _original_dlm_perturbation(optim_vars, aux_vars): v = optim_vars[0] g = aux_vars[0] epsilon...
original_jac[0])
assert_*
complex_expr
tests/theseus_tests/test_dlm_perturbation.py
test_dlm_perturbation_jacobian
72
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
ValueError)
pytest.raises
variable
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_update
125
null
facebookresearch/theseus
import pytest import torch import torchlie as lie import torchlie.functional.se3_impl as se3_impl import torchlie.functional.so3_impl as so3_impl from .functional.common import get_test_cfg, sample_inputs def rng(): rng_ = torch.Generator(device="cuda:0" if torch.cuda.is_available() else "cpu") rng_.manual_se...
[impl_jac, impl_out])
assert_*
collection
tests/torchlie_tests/test_lie_tensor.py
test_op
118
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def test_to_dtyp...
dtype
assert
variable
tests/theseus_tests/core/test_objective.py
test_to_dtype
547
null
facebookresearch/theseus
import torch import theseus as th from theseus.utils.examples.bundle_adjustment.util import random_small_quaternion def test_residual(): # unit test for Cost term torch.manual_seed(0) batch_size = 4 cam_rot = torch.cat( [ random_small_quaternion(max_degrees=20).unsqueeze(0) ...
5e-5
assert
numeric_literal
tests/theseus_tests/embodied/measurements/test_reprojection.py
test_residual
94
null
facebookresearch/theseus
import pytest # noqa import torch import theseus as th from tests.theseus_tests.core.common import ( BATCH_SIZES_TO_TEST, check_another_theseus_function_is_copy, check_another_theseus_tensor_is_copy, check_another_torch_tensor_is_copy, ) from theseus.utils import numeric_jacobian from .utils import r...
cost_function2
assert
variable
tests/theseus_tests/embodied/collision/test_collision_factor.py
test_collision2d_copy
63
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
out_expand_flat.reshape(broadcast_size + t2_size))
assert_*
func_call
tests/torchlie_tests/functional/common.py
check_binary_op_broadcasting
301
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.constants import EPS from tests.theseus_tests.core.common import check_copy_var from .common import ( BATCH_SIZES_TO_TEST, check_jacobian_for_local, check_projection_for_exp_map, check_projection_for_log_map,...
(i, k)
assert
collection
tests/theseus_tests/geometry/test_vector.py
test_matmul
86
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.core.cost_function import AutogradMode from theseus.core.cost_weight import ScaleCostWeight from .common import ( MockCostFunction, MockCostWeight, MockVar, check_another_theseus_function_is_copy...
reps
assert
variable
tests/theseus_tests/core/test_cost_function.py
test_default_name_and_ids
57
null
facebookresearch/theseus
import numpy as np import torch import theseus as th from tests.theseus_tests.core.common import ( BATCH_SIZES_TO_TEST, check_another_theseus_function_is_copy, check_another_theseus_tensor_is_copy, ) from theseus.utils import numeric_jacobian def evaluate_numerical_jacobian_local_cost_fn(Group, tol): ...
"new_name"
assert
string_literal
tests/theseus_tests/embodied/misc/test_variable_difference.py
test_copy_local_cost_fn
53
null
facebookresearch/theseus
from unittest import mock import numpy as np import pytest # noqa: F401 import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.core.vectorizer import _CostFunctionWrapper def test_correct_schemas_and_shared_vars(): v1 = th.Vector(1) v2 = th.Vector(1) ...
2
assert
numeric_literal
tests/theseus_tests/core/test_vectorizer.py
test_correct_schemas_and_shared_vars
128
null
facebookresearch/theseus
import numpy as np import pytest # noqa import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from tests.theseus_tests.embodied.collision.utils import ( random_origin, random_scalar, random_sdf_data, ) from tests.theseus_tests.geometry.test_se2 import create_ran...
eff_radius
assert
variable
tests/theseus_tests/embodied/collision/test_eff_obj_contact.py
test_eff_obj_variable_type
175
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
dtype
assert
variable
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_to
80
null
facebookresearch/theseus
from unittest import mock import numpy as np import pytest # noqa: F401 import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.core.vectorizer import _CostFunctionWrapper def _check_vectorized_wrappers(vectorization, objective): for w in vectorization._cos...
objective.error())
assert_*
func_call
tests/theseus_tests/core/test_vectorizer.py
test_vectorized_error
256
null
facebookresearch/theseus
import copy import torch import theseus as th BATCH_SIZES_TO_TEST = (1, 10) def create_mock_cost_functions(tensor=None, cost_weight=NullCostWeight()): len_data = 1 if tensor is None else tensor.shape[1] var1 = MockVar(len_data, tensor=tensor, name="var1") var2 = MockVar(len_data, tensor=tensor, name="va...
"new"
assert
string_literal
tests/theseus_tests/core/common.py
check_copy_var
216
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.core.cost_function import AutogradMode from theseus.core.cost_weight import ScaleCostWeight from .common import ( MockCostFunction, MockCostWeight, MockVar, check_another_theseus_function_is_copy...
(batch_size, err_dim, 3)
assert
collection
tests/theseus_tests/core/test_cost_function.py
test_autodiff_cost_function_error_and_jacobians_shape_on_SO3
326
null
facebookresearch/theseus
import pytest # noqa import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.utils import numeric_jacobian from .utils import random_sdf def test_sdf_2d_shapes(): generator = torch.Generator() generator.manual_seed(0) for batch_size in BATCH_SIZES_T...
(batch_size, num_points)
assert
collection
tests/theseus_tests/embodied/collision/test_signed_distance_field.py
test_sdf_2d_shapes
26
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import MockVar def test_update(): for _ in range(10): for length in range(1, 10): var = MockVar(length) batch_size = np.random.randint(1, 10) # check update from torch tensor ...
new_data_good
assert
variable
tests/theseus_tests/core/test_variable.py
test_update
54
null
facebookresearch/theseus
import pytest import torch import theseus as th from tests.theseus_tests.decorators import run_if_baspacho from theseus.utils import numeric_grad torch.manual_seed(0) @pytest.mark.parametrize( "linear_solver_cls", [th.CholeskyDenseSolver, th.CholmodSparseSolver] ) def test_backwards_quad_fit(linear_solver_cls):...
da_dx_truncated)
assert_*
variable
tests/theseus_tests/optimizer/nonlinear/test_backwards.py
test_backwards_quad_fit
128
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.constants import TEST_EPS from tests.theseus_tests.core.common import check_copy_var from theseus.utils import numeric_jacobian from .common import ( BATCH_SIZES_TO_TEST, check_adjoint, check_compose, check_e...
expected_jac[1].shape
assert
complex_expr
tests/theseus_tests/geometry/test_se2.py
test_transform_from_and_to
159
null
facebookresearch/theseus
import pytest # noqa import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.utils import numeric_jacobian from .utils import random_sdf def test_signed_distance_2d_jacobian(): for batch_size in BATCH_SIZES_TO_TEST: sdf = random_sdf(batch_size, 10, ...
1e-5
assert
numeric_literal
tests/theseus_tests/embodied/collision/test_signed_distance_field.py
test_signed_distance_2d_jacobian
111
null
facebookresearch/theseus
from unittest import mock import numpy as np import pytest # noqa: F401 import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.core.vectorizer import _CostFunctionWrapper def _check_vectorized_wrappers(vectorization, objective): for w in vectorization._cos...
exp_jac)
assert_*
variable
tests/theseus_tests/core/test_vectorizer.py
_check_vectorized_wrappers
211
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import scipy.sparse import torch import torch.nn as nn import theseus as th import theseus.utils as thutils def _check_sparse_mv_and_mtv(batch_size, num_rows, num_cols, fill, device): A_col_ind, A_row_ptr, A_val, _ = thutils.random_sparse_matrix( batch_size, ...
1e-8
assert
numeric_literal
tests/theseus_tests/utils/test_utils.py
_check_sparse_mv_and_mtv
140
null
facebookresearch/theseus
import pytest # noqa: F401 import torch import theseus as th def _check_info(info, batch_size, max_iterations, initial_error, objective): assert info.err_history.shape == (batch_size, max_iterations + 1) assert info.err_history[:, 0].allclose(initial_error) assert info.err_history.argmin(dim=1).allclose(...
RuntimeError)
pytest.raises
variable
tests/theseus_tests/optimizer/nonlinear/common.py
_check_optimizer_returns_fail_status_on_singular
272
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch # needed for import of Torch C++ extensions to work from scipy.sparse import csr_matrix from theseus.utils import random_sparse_matrix def check_lu_solver( init_batch_size, batch_size, num_rows, num_cols, fill, verbose=False ): # this is necessary a...
num_cols
assert
variable
tests/theseus_tests/extlib/test_cusolver_lu_solver.py
check_lu_solver
20
null
facebookresearch/theseus
import warnings import pytest # noqa: F401 import torch import theseus as th from theseus.constants import EPS from .common import ( BATCH_SIZES_TO_TEST, check_jacobian_for_local, check_projection_for_exp_map, check_projection_for_log_map, ) def test_operations_mypy_cast(): # mypy is optional i...
0
assert
numeric_literal
tests/theseus_tests/geometry/test_point_types.py
test_operations_mypy_cast
80
null
facebookresearch/theseus
import pytest import torch from omegaconf import OmegaConf import examples.pose_graph.pose_graph_synthetic as pgo from tests.theseus_tests.decorators import run_if_baspacho def default_cfg(): cfg = OmegaConf.load("examples/configs/pose_graph/pose_graph_synthetic.yaml") cfg.outer_optim.num_epochs = 1 cfg....
pytest.approx(expected_loss, rel=1e-10, abs=1e-10)
assert
func_call
tests/theseus_tests/test_pgo_benchmark.py
test_pgo_losses
60
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def _check_v...
v1_data
assert
variable
tests/theseus_tests/core/test_objective.py
_check_variables
259
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import MockCostFunction, MockCostWeight def test_theseus_function_init(): all_ids = [] variables = [th.Variable(torch.ones(1, 1), name="var_1")] aux_vars = [th.Variable(torch.ones(1, 1), name="aux_1")] for i...
cost_function.name
assert
complex_expr
tests/theseus_tests/core/test_theseus_function.py
test_theseus_function_init
28
null
facebookresearch/theseus
import pytest # noqa: F401 import torch import theseus as th def _create_linear_system(batch_size=32, matrix_size=10): A = torch.randn((batch_size, matrix_size, matrix_size)) AtA = torch.empty((batch_size, matrix_size, matrix_size)) Atb = torch.empty((batch_size, matrix_size, 1)) x = torch.randn((bat...
0
assert
numeric_literal
tests/theseus_tests/optimizer/linear/test_dense_solver.py
test_handle_singular
103
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
log_map_ref)
assert_*
variable
tests/torchlie_tests/functional/common.py
check_log_map_passt
342
null
facebookresearch/theseus
import pytest # noqa: F401 import torch import theseus as th @pytest.mark.parametrize( "var_type", [(th.Vector, 1), (th.Vector, 2), (th.SE2, None), (th.SE3, None)] ) @pytest.mark.parametrize("batch_size", [1, 10]) def test_state_history(var_type, batch_size): cls_, dof = var_type rand_args = (batch_size...
info.state_history
assert
complex_expr
tests/theseus_tests/optimizer/nonlinear/test_info.py
test_state_history
34
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import MockVar def test_variable_init(): all_ids = [] for i in range(100): if np.random.random() < 0.5: name = f"name_{i}" else: name = None data = torch.rand(1, 1) ...
t.name
assert
complex_expr
tests/theseus_tests/core/test_variable.py
test_variable_init
26
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
grad_ref)
assert_*
variable
tests/torchlie_tests/functional/common.py
check_log_map_passt
344
null
facebookresearch/theseus
import pytest import torch from torchlie import reset_global_params, set_global_params from torchlie.functional import SE3, SO3, enable_checks @pytest.mark.parametrize("dtype", ["float32", "float64"]) def test_global_options(dtype): rng = torch.Generator() rng.manual_seed(0) g = SE3.rand(1, generator=rng,...
ValueError)
pytest.raises
variable
tests/torchlie_tests/test_misc.py
test_global_options
27
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
flattened_out.reshape(*batch_size, *out.shape[lb:]))
assert_*
func_call
tests/torchlie_tests/functional/common.py
check_lie_group_function
166
null
facebookresearch/theseus
import pytest # noqa: F401 import torch # noqa: F401 import theseus as th from tests.theseus_tests.optimizer.linearization_test_utils import ( build_test_objective_and_linear_system, ) def test_sparse_linearization(): objective, ordering, A, b = build_test_objective_and_linear_system() linearization = ...
atb_out)
assert_*
variable
tests/theseus_tests/optimizer/test_sparse_linearization.py
test_sparse_linearization
35
null
facebookresearch/theseus
import torch from torch.autograd import grad, gradcheck def check_grad(solve_func, inputs, eps, atol, rtol): assert gradcheck(solve_func, inputs, eps=eps, atol=atol) A_val, b = inputs[0], inputs[1] # Check that the gradient works correctly for floating point data out = solve_func(*inputs).sum() gA...
gb_float.double())
assert_*
func_call
tests/theseus_tests/optimizer/autograd/common.py
check_grad
35
null
facebookresearch/theseus
import pytest import torch from omegaconf import OmegaConf import examples.pose_graph.pose_graph_synthetic as pgo from tests.theseus_tests.decorators import run_if_baspacho def default_cfg(): cfg = OmegaConf.load("examples/configs/pose_graph/pose_graph_synthetic.yaml") cfg.outer_optim.num_epochs = 1 cfg....
expected_loss, rel=1e-10, abs=1e-10)
pytest.approx
complex_expr
tests/theseus_tests/test_pgo_benchmark.py
test_pgo_losses
60
null
facebookresearch/theseus
import pytest # noqa: F401 import torch from sksparse.cholmod import analyze_AAt import theseus as th def _build_sparse_mat(batch_size): all_cols = list(range(10)) col_ind = [] row_ptr = [0] for i in range(12): start = max(0, i - 2) end = min(i + 1, 10) col_ind += all_cols[sta...
1e-4
assert
numeric_literal
tests/theseus_tests/optimizer/linear/test_cholmod_sparse_solver.py
_check_correctness
68
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.core.cost_function import AutogradMode from theseus.core.cost_weight import ScaleCostWeight from .common import ( MockCostFunction, MockCostWeight, MockVar, check_another_theseus_function_is_copy...
0
assert
numeric_literal
tests/theseus_tests/core/test_cost_function.py
error_fn
178
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
dof
assert
variable
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_init
55
null
facebookresearch/theseus
import copy import torch import theseus as th BATCH_SIZES_TO_TEST = (1, 10) def create_mock_cost_functions(tensor=None, cost_weight=NullCostWeight()): len_data = 1 if tensor is None else tensor.shape[1] var1 = MockVar(len_data, tensor=tensor, name="var1") var2 = MockVar(len_data, tensor=tensor, name="va...
new_var.tensor
assert
complex_expr
tests/theseus_tests/core/common.py
check_copy_var
214
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
jac)
assert_*
variable
tests/torchlie_tests/functional/common.py
check_lie_group_function
145
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import scipy.sparse import torch import torch.nn as nn import theseus as th import theseus.utils as thutils def _check_sparse_mv_and_mtv(batch_size, num_rows, num_cols, fill, device): A_col_ind, A_row_ptr, A_val, _ = thutils.random_sparse_matrix( batch_size, ...
0
assert
numeric_literal
tests/theseus_tests/utils/test_utils.py
test_timer
177
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def test_cost_de...
0
assert
numeric_literal
tests/theseus_tests/core/test_objective.py
test_cost_delete_and_add
574
null
facebookresearch/theseus
from typing import Sequence, Union import pytest import torch import torchlie.functional.se3_impl as se3_impl from torchlie.functional import SE3 from .common import ( BATCH_SIZES_TO_TEST, TEST_EPS, check_binary_op_broadcasting, check_left_project_broadcasting, check_lie_group_function, check...
tangent_vector)
assert_*
variable
tests/torchlie_tests/functional/test_se3.py
test_vee
68
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def test_copy():...
objective
assert
variable
tests/theseus_tests/core/test_objective.py
test_copy
407
null
facebookresearch/theseus
from typing import Sequence, Union import pytest import torch import torchlie.functional.so3_impl as so3_impl from torchlie.functional import SO3 from torchlie.global_params import set_global_params from .common import ( BATCH_SIZES_TO_TEST, TEST_EPS, check_binary_op_broadcasting, check_left_project_...
sa_2.cpu())
assert_*
func_call
tests/torchlie_tests/functional/test_so3.py
test_sine_axis
125
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.constants import EPS from tests.theseus_tests.core.common import check_copy_var from .common import ( BATCH_SIZES_TO_TEST, check_jacobian_for_local, check_projection_for_exp_map, check_projection_for_log_map,...
torch.norm(t1, p="fro")
assert
func_call
tests/theseus_tests/geometry/test_vector.py
test_norm
131
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
new_var.precision
assert
complex_expr
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_copy
94
null
facebookresearch/theseus
import pytest import torch import torchlie as lie import torchlie.functional.se3_impl as se3_impl import torchlie.functional.so3_impl as so3_impl from .functional.common import get_test_cfg, sample_inputs def rng(): rng_ = torch.Generator(device="cuda:0" if torch.cuda.is_available() else "cpu") rng_.manual_se...
impl_out)
assert_*
variable
tests/torchlie_tests/test_lie_tensor.py
test_op
88
null
facebookresearch/theseus
import copy import torch import theseus as th BATCH_SIZES_TO_TEST = (1, 10) def create_mock_cost_functions(tensor=None, cost_weight=NullCostWeight()): len_data = 1 if tensor is None else tensor.shape[1] var1 = MockVar(len_data, tensor=tensor, name="var1") var2 = MockVar(len_data, tensor=tensor, name="va...
other_tensor
assert
variable
tests/theseus_tests/core/common.py
check_another_torch_tensor_is_copy
228
null
facebookresearch/theseus
import pytest import theseus as th import torch from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST def _new_robust_cf( batch_size, loss_cls, generator, masked_weight=False, gnc_cost=False, ) -> [th.RobustCostFunction, th.GNCRobustCostFunction]: v1 = th.rand_se3(batch_size, genera...
lin_flattened.b)
assert_*
complex_expr
tests/theseus_tests/core/test_robust_cost.py
test_flatten_dims
317
null
facebookresearch/theseus
import pytest import theseus as th import torch from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST def _new_robust_cf( batch_size, loss_cls, generator, masked_weight=False, gnc_cost=False, ) -> [th.RobustCostFunction, th.GNCRobustCostFunction]: v1 = th.rand_se3(batch_size, genera...
expected_rho2)
assert_*
variable
tests/theseus_tests/core/test_robust_cost.py
test_robust_cost_weighted_error
97
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
j2.reshape(broadcast_size + j1.shape[-2:]))
assert_*
func_call
tests/torchlie_tests/functional/common.py
check_binary_op_broadcasting
306
null
facebookresearch/theseus
from unittest import mock import numpy as np import pytest # noqa: F401 import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.core.vectorizer import _CostFunctionWrapper def test_costs_vars_and_err_before_vectorization(): for _ in range(20): objec...
optim_vars
assert
variable
tests/theseus_tests/core/test_vectorizer.py
test_costs_vars_and_err_before_vectorization
62
null
facebookresearch/theseus
import theseus as th import torch from theseus.utils import check_jacobians def test_hinge_cost(): rng = torch.Generator() rng.manual_seed(0) batch_size = 10 how_many = 4 def _rand_chunk(): return torch.rand(batch_size, how_many, generator=rng) for limit in [0.0, 1.0]: thresh...
nn_zero
assert
variable
tests/theseus_tests/embodied/motionmodel/test_misc.py
test_hinge_cost
63
null
facebookresearch/theseus
import numpy as np import pytest # noqa: F401 import torch import theseus as th from .common import ( MockCostFunction, MockCostWeight, MockVar, NullCostWeight, check_another_theseus_tensor_is_copy, create_mock_cost_functions, create_objective_with_mock_cost_functions, ) def test_update_...
batch_size
assert
variable
tests/theseus_tests/core/test_objective.py
test_update_raises_batch_size_error
506
null
facebookresearch/theseus
import pytest # noqa: F401 import torch import theseus as th from theseus.constants import __FROM_THESEUS_LAYER_TOKEN__ from tests.theseus_tests.optimizer.nonlinear.common import ( run_nonlinear_least_squares_check, ) def mock_objective(): objective = th.Objective() v1 = th.Vector(1, name="v1") v2 =...
RuntimeError)
pytest.raises
variable
tests/theseus_tests/optimizer/nonlinear/test_levenberg_marquardt.py
test_ellipsoidal_damping_compatibility
53
null
facebookresearch/theseus
import pytest # noqa import torch import theseus as th from tests.theseus_tests.core.common import ( BATCH_SIZES_TO_TEST, check_another_theseus_function_is_copy, check_another_theseus_tensor_is_copy, check_another_torch_tensor_is_copy, ) from theseus.utils import numeric_jacobian from .utils import r...
jac_error.shape
assert
complex_expr
tests/theseus_tests/embodied/collision/test_collision_factor.py
test_collision2d_error_shapes
41
null
facebookresearch/theseus
import pytest import torch import torchlie as lie import torchlie.functional.se3_impl as se3_impl import torchlie.functional.so3_impl as so3_impl from .functional.common import get_test_cfg, sample_inputs def rng(): rng_ = torch.Generator(device="cuda:0" if torch.cuda.is_available() else "cpu") rng_.manual_se...
[jac_c, out_c])
assert_*
collection
tests/torchlie_tests/test_lie_tensor.py
test_op
123
null
facebookresearch/theseus
from unittest import mock import numpy as np import pytest # noqa: F401 import torch import theseus as th from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST from theseus.core.vectorizer import _CostFunctionWrapper def _check_vectorized_wrappers(vectorization, objective): for w in vectorization._cos...
w_err)
assert_*
variable
tests/theseus_tests/core/test_vectorizer.py
_check_vectorized_wrappers
209
null
facebookresearch/theseus
import theseus as th import torch from theseus.utils import check_jacobians def test_hinge_cost(): rng = torch.Generator() rng.manual_seed(0) batch_size = 10 how_many = 4 def _rand_chunk(): return torch.rand(batch_size, how_many, generator=rng) for limit in [0.0, 1.0]: thresh...
(batch_size, 3 * how_many, 3 * how_many)
assert
collection
tests/theseus_tests/embodied/motionmodel/test_misc.py
test_hinge_cost
53
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th def random_manifold_gaussian_params(): manif_types = [th.Point2, th.Point3, th.SE2, th.SE3, th.SO2, th.SO3] n_vars = np.random.randint(1, 5) batch_size = np.random.randint(1, 100) mean = [] dof = 0 f...
"new"
assert
string_literal
tests/theseus_tests/optimizer/test_manifold_gaussian.py
test_copy
96
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.core.cost_function import AutogradMode from theseus.core.cost_weight import ScaleCostWeight from .common import ( MockCostFunction, MockCostWeight, MockVar, check_another_theseus_function_is_copy...
num_optim_vars
assert
variable
tests/theseus_tests/core/test_cost_function.py
test_autodiff_cost_function_error_and_jacobians_shape
147
null
facebookresearch/theseus
import pytest import theseus as th import torch from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST def _new_robust_cf( batch_size, loss_cls, generator, masked_weight=False, gnc_cost=False, ) -> [th.RobustCostFunction, th.GNCRobustCostFunction]: v1 = th.rand_se3(batch_size, genera...
j2)
assert_*
variable
tests/theseus_tests/core/test_robust_cost.py
test_mask_jacobians
231
null
facebookresearch/theseus
import pytest import theseus as th import torch @pytest.mark.parametrize("dof", [1, 8]) @pytest.mark.parametrize( "linear_solver_cls", [th.CholeskyDenseSolver, th.CholmodSparseSolver, th.LUCudaSparseSolver], ) def test_rho(dof, linear_solver_cls): device = "cuda:0" if torch.cuda.is_available() else "cpu" ...
torch.ones_like(rho))
assert_*
func_call
tests/theseus_tests/optimizer/nonlinear/test_trust_region.py
test_rho
62
null
facebookresearch/theseus
import pytest import theseus as th import torch from tests.theseus_tests.core.common import BATCH_SIZES_TO_TEST def _new_robust_cf( batch_size, loss_cls, generator, masked_weight=False, gnc_cost=False, ) -> [th.RobustCostFunction, th.GNCRobustCostFunction]: v1 = th.rand_se3(batch_size, genera...
lin_flattened.AtA)
assert_*
complex_expr
tests/theseus_tests/core/test_robust_cost.py
test_flatten_dims
318
null
facebookresearch/theseus
import copy import numpy as np import pytest # noqa: F401 import torch import theseus as th from theseus.core import Variable from tests.theseus_tests.core.common import ( BATCH_SIZES_TO_TEST, check_another_theseus_function_is_copy, ) from theseus.utils import numeric_jacobian def test_gp_motion_model_varia...
dt_v
assert
variable
tests/theseus_tests/embodied/motionmodel/test_double_integrator.py
test_gp_motion_model_variable_type
87
null
facebookresearch/theseus
from functools import reduce import torch from torchlie.global_params import set_global_params BATCH_SIZES_TO_TEST = [1, 20, (1, 2), (3, 4, 5), tuple()] TEST_EPS = 5e-7 def get_test_cfg(op_name, dtype, dim, data_shape, module=None): atol = TEST_EPS # input_type --> tuple[str, param] # input_types --> a ...
jac_ref)
assert_*
variable
tests/torchlie_tests/functional/common.py
check_log_map_passt
343
null