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 |
|---|---|---|---|---|---|---|---|---|---|
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_implicit) | assert_* | variable | tests/theseus_tests/optimizer/nonlinear/test_backwards.py | test_backwards_quad_fit | 114 | 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... | ValueError) | pytest.raises | variable | tests/theseus_tests/core/test_cost_function.py | test_autodiff_cost_function_error_and_jacobians_shape | 121 | 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... | 2 | assert | numeric_literal | tests/theseus_tests/embodied/motionmodel/test_double_integrator.py | test_gp_motion_model_variable_type | 94 | 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 = ... | scaled_v) | assert_* | variable | tests/theseus_tests/optimizer/test_sparse_linearization.py | test_sparse_linearization | 49 | null | |
facebookresearch/theseus | import pytest # noqa: F401
import torch
import theseus as th
def _build_sparse_mat(batch_size, rng):
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[start:end]
row_ptr.append(len(c... | RuntimeError) | pytest.raises | variable | tests/theseus_tests/optimizer/linear/test_lu_cuda_sparse_solver.py | check_sparse_solver_multistep | 140 | null | |
facebookresearch/theseus | import pytest # noqa: F401
import torch
import theseus as th
from .common import MockVar, check_copy_var
def test_var_shape():
for sz in range(100):
data = torch.ones(1, sz)
var = MockVar(sz, tensor=data)
assert data.shape == | var.shape | assert | complex_expr | tests/theseus_tests/core/test_manifold.py | test_var_shape | 26 | 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... | obj_flattened.error()) | assert_* | func_call | tests/theseus_tests/core/test_robust_cost.py | test_flatten_dims | 316 | 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)
... | f"Variable__{t._id}" | assert | string_literal | tests/theseus_tests/core/test_variable.py | test_variable_init | 28 | 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, 2) | assert | collection | tests/theseus_tests/embodied/collision/test_signed_distance_field.py | test_sdf_2d_shapes | 27 | 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 = ... | linearization.b[i]) | assert_* | complex_expr | tests/theseus_tests/optimizer/test_sparse_linearization.py | test_sparse_linearization | 30 | 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... | v2_data | assert | variable | tests/theseus_tests/core/test_objective.py | _check_variables | 260 | 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 ... | 2 * batch_dim + 3 | assert | complex_expr | tests/torchlie_tests/functional/common.py | func | 173 | 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... | (objective.batch_size,) + tuple( var.shape[1:] ) + (max_iters + 1,) | assert | collection | tests/theseus_tests/optimizer/nonlinear/test_info.py | test_state_history | 35 | 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... | 2 * nn_zero | assert | complex_expr | tests/theseus_tests/embodied/motionmodel/test_misc.py | test_hinge_cost | 61 | 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[0].shape | assert | complex_expr | tests/theseus_tests/geometry/test_se2.py | test_transform_from_and_to | 158 | 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_fn | assert | variable | tests/theseus_tests/core/common.py | check_another_theseus_function_is_copy | 233 | 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... | mean[j] | assert | complex_expr | tests/theseus_tests/optimizer/test_manifold_gaussian.py | test_init | 57 | null | |
facebookresearch/theseus | import itertools
import random
import pytest # noqa: F401
import torch
import theseus as th
from tests.theseus_tests.core.common import MockCostFunction, MockCostWeight, MockVar
def test_variable_ordering_append_and_remove():
variables = [MockVar(1, tensor=None, name=f"var{i}") for i in range(50)]
mock_obje... | order.index_of(v.name) | assert | func_call | tests/theseus_tests/optimizer/test_variable_ordering.py | test_variable_ordering_append_and_remove | 59 | null | |
facebookresearch/theseus | import pytest # noqa: F401
import torch
import numpy as np
from theseus.optimizer.autograd import BaspachoSolveFunction
from tests.theseus_tests.decorators import run_if_baspacho
from theseus.utils import random_sparse_binary_matrix, split_into_param_sizes
import theseus as th
from .common import check_grad
def get... | 1.0 | assert | numeric_literal | tests/theseus_tests/optimizer/autograd/test_baspacho_sparse_backward.py | get_linearization_and_solver_for_random_sparse | 23 | null | |
facebookresearch/theseus | import numpy as np
import pytest # noqa: F401
import torch
import theseus as th
from .common import MockCostFunction, MockCostWeight
def test_no_copy_vars_check():
variables = [th.Variable(torch.ones(1, 1), name="var_1")]
aux_vars = [th.Variable(torch.ones(1, 1), name="aux_1")]
cost_weight = MockCostWei... | RuntimeError) | pytest.raises | variable | tests/theseus_tests/core/test_theseus_function.py | test_no_copy_vars_check | 40 | 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_var | assert | variable | tests/theseus_tests/core/common.py | check_another_theseus_tensor_is_copy | 223 | 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_... | tangent_vector) | assert_* | variable | tests/torchlie_tests/functional/test_so3.py | test_vee | 70 | 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 | complex_expr | tests/theseus_tests/embodied/motionmodel/test_misc.py | test_hinge_cost | 62 | 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... | t.name | assert | complex_expr | tests/theseus_tests/optimizer/test_manifold_gaussian.py | test_init | 52 | 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_grad) | assert_* | variable | tests/theseus_tests/core/test_robust_cost.py | test_robust_cost_grad_form | 125 | 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) | assert | collection | tests/theseus_tests/embodied/motionmodel/test_misc.py | test_hinge_cost | 54 | null | |
facebookresearch/theseus | import itertools
import random
import pytest # noqa: F401
import torch
import theseus as th
from tests.theseus_tests.core.common import MockCostFunction, MockCostWeight, MockVar
def test_variable_ordering_append_and_remove():
variables = [MockVar(1, tensor=None, name=f"var{i}") for i in range(50)]
mock_obje... | order[i] | assert | complex_expr | tests/theseus_tests/optimizer/test_variable_ordering.py | test_variable_ordering_append_and_remove | 60 | 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... | out_c) | assert_* | variable | tests/torchlie_tests/test_lie_tensor.py | test_op | 110 | 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 ... | func(jac)) | assert_* | func_call | tests/torchlie_tests/functional/common.py | check_lie_group_function | 151 | null | |
facebookresearch/theseus | import itertools
import random
import pytest # noqa: F401
import torch
import theseus as th
from tests.theseus_tests.core.common import MockCostFunction, MockCostWeight, MockVar
def test_variable_ordering_append_and_remove():
variables = [MockVar(1, tensor=None, name=f"var{i}") for i in range(50)]
mock_obje... | order._var_order | assert | complex_expr | tests/theseus_tests/optimizer/test_variable_ordering.py | test_variable_ordering_append_and_remove | 67 | 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... | f"{var.name}_copy" | assert | string_literal | tests/theseus_tests/core/common.py | check_copy_var | 218 | null | |
facebookresearch/theseus | import numpy as np
import pytest # noqa: F401
import torch
import theseus as th
from .common import MockVar
def test_properties():
for i in range(100):
length = np.random.randint(2, 5)
batch_size = np.random.randint(1, 100)
dtype = torch.float if np.random.random() < 0.5 else torch.long
... | dtype | assert | variable | tests/theseus_tests/core/test_variable.py | test_properties | 43 | 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... | err_expected) | assert_* | variable | tests/theseus_tests/core/test_robust_cost.py | test_mask_jacobians | 229 | 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... | cost_function_name | assert | variable | tests/theseus_tests/core/test_cost_function.py | test_default_name_and_ids | 56 | null | |
facebookresearch/theseus | import itertools
import random
import pytest # noqa: F401
import torch
import theseus as th
from tests.theseus_tests.core.common import MockCostFunction, MockCostWeight, MockVar
def test_variable_ordering_append_and_remove():
variables = [MockVar(1, tensor=None, name=f"var{i}") for i in range(50)]
mock_obje... | order._var_name_to_index | assert | complex_expr | tests/theseus_tests/optimizer/test_variable_ordering.py | test_variable_ordering_append_and_remove | 68 | 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_dlm) | assert_* | variable | tests/theseus_tests/optimizer/nonlinear/test_backwards.py | test_backwards_quad_fit | 142 | null | |
facebookresearch/theseus | import math
from unittest import mock
import pytest # noqa: F401
import torch
import torch.nn as nn
import torch.nn.functional as F
import theseus as th
import theseus.utils as thutils
from theseus.constants import __FROM_THESEUS_LAYER_TOKEN__
from tests.theseus_tests.core.common import (
MockCostFunction,
M... | RuntimeError) | pytest.raises | variable | tests/theseus_tests/test_theseus_layer.py | _do_check | 507 | 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 | assert | variable | tests/theseus_tests/optimizer/test_manifold_gaussian.py | test_copy | 91 | 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... | loss0 | assert | variable | tests/theseus_tests/test_dlm_perturbation.py | test_backward_pass_se3_runs | 111 | 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 tests.theseus_tests.geometry.test_se2 import create_random_se2
from theseus.utils import numeric_jacobian
def _check_jacobian(actual_, expected_):
# This makes failures... | 1e-5 | assert | numeric_literal | tests/theseus_tests/embodied/motionmodel/test_quasi_static_pushing_planar.py | _check_jacobian | 122 | 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... | "new_name" | assert | string_literal | tests/theseus_tests/embodied/collision/test_collision_factor.py | test_collision2d_copy | 78 | 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 | assert | variable | tests/theseus_tests/core/common.py | check_copy_var | 213 | 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 | collection | tests/theseus_tests/optimizer/nonlinear/common.py | _check_info | 98 | 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... | len(all_ids) | assert | func_call | tests/theseus_tests/optimizer/test_manifold_gaussian.py | test_init | 68 | 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... | 1e-6 | assert | numeric_literal | tests/theseus_tests/optimizer/linear/test_dense_solver.py | test_handle_singular | 102 | 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_for_autodiffcosts():
v1_1 = th.Vector(1)
v1_2 = th.Vecto... | cost_fns | assert | variable | tests/theseus_tests/core/test_vectorizer.py | test_correct_schemas_for_autodiffcosts | 191 | 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 ... | ["compose", "transform", "untransform"] | assert | collection | tests/torchlie_tests/functional/common.py | check_jacrev_binary | 230 | 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... | 1e-4 | assert | numeric_literal | tests/theseus_tests/optimizer/linear/test_dense_solver.py | test_dense_solvers | 38 | 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... | gA_float.double()) | assert_* | func_call | tests/theseus_tests/optimizer/autograd/common.py | check_grad | 34 | 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 ... | jf.reshape(*batch_size, *j.shape[lb:])) | assert_* | func_call | tests/torchlie_tests/functional/common.py | check_lie_group_function | 168 | 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... | cost_weight | assert | variable | tests/theseus_tests/core/test_cost_function.py | test_autodiff_cost_function_cost_weight | 205 | 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_... | var_.tensor | assert | complex_expr | tests/theseus_tests/core/test_objective.py | test_update_updates_properly | 481 | 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... | (batch_size, 1, 2) | assert | collection | tests/theseus_tests/embodied/collision/test_collision_factor.py | test_collision2d_error_shapes | 43 | null | |
facebookresearch/theseus | import math
from unittest import mock
import pytest # noqa: F401
import torch
import torch.nn as nn
import torch.nn.functional as F
import theseus as th
import theseus.utils as thutils
from theseus.constants import __FROM_THESEUS_LAYER_TOKEN__
from tests.theseus_tests.core.common import (
MockCostFunction,
M... | ValueError) | pytest.raises | variable | tests/theseus_tests/test_theseus_layer.py | test_pass_optimizer_kwargs | 556 | null | |
facebookresearch/theseus | import pytest # noqa: F401
import torch
from sksparse.cholmod import analyze_AAt
from torch.autograd import gradcheck
import theseus as th
from theseus.optimizer.autograd import CholmodSolveFunction
def _build_sparse_mat(batch_size):
torch.manual_seed(37)
all_cols = list(range(10))
col_ind = []
row_p... | 1.0 | assert | numeric_literal | tests/theseus_tests/optimizer/autograd/test_sparse_backward.py | test_float64_used | 76 | 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_err) | assert_* | variable | tests/theseus_tests/test_dlm_perturbation.py | test_dlm_perturbation_jacobian | 71 | 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 test_build_mlp():
# set seed for mlp
torch.manual_seed(0)
# create name to class map for activation function
act_name_to_cls_map = {"relu": nn.... | hidden_depth | assert | variable | tests/theseus_tests/utils/test_utils.py | test_build_mlp | 40 | 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, j) | assert | collection | tests/theseus_tests/geometry/test_vector.py | test_matmul | 91 | 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 ... | ["exp", "inv"] | assert | collection | tests/torchlie_tests/functional/common.py | check_jacrev_unary | 200 | 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_vars | assert | variable | tests/theseus_tests/core/test_cost_function.py | error_fn | 286 | null | |
facebookresearch/theseus | import numpy as np
import torch
import theseus.core as thcore
import theseus.embodied as thembod
import theseus.geometry as thgeom
from tests.theseus_tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
check_another_theseus_tensor_is_copy,
)
from tests.theseus_tests.geom... | "new_name" | assert | string_literal | tests/theseus_tests/embodied/measurements/test_moving_frame_between.py | test_copy_moving_frame_between | 44 | 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_for_autodiffcosts():
v1_1 = th.Vector(1)
v1_2 = th.Vecto... | [1] * 4 | assert | collection | tests/theseus_tests/core/test_vectorizer.py | test_correct_schemas_for_autodiffcosts | 201 | 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_analytic) | assert_* | variable | tests/torchlie_tests/functional/common.py | check_jacrev_unary | 220 | 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, tril
from tests.theseus_tests.decorators import run_if_baspacho
from theseus.utils import random_sparse_matrix, split_into_param_sizes
def check_baspacho(
batch_siz... | 1.0 | assert | numeric_literal | tests/theseus_tests/extlib/test_baspacho.py | check_baspacho | 30 | null | |
facebookresearch/theseus | import pytest
from theseus._version import lt_version
def test_lt_version():
assert not lt_version("2.0.0", "0.4.0")
assert not lt_version("1.13.0abcd", "0.4.0")
assert not lt_version("0.4.1+yzx", "0.4.0")
assert lt_version("1.13.0.1.2.3.4", "2.0.0")
assert lt_version("1.13.0.1.2+abc", "2.0.0")
... | ValueError) | pytest.raises | variable | tests/theseus_tests/test_misc.py | test_lt_version | 16 | 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"{var.name}_copy" | assert | string_literal | tests/theseus_tests/optimizer/test_manifold_gaussian.py | test_copy | 98 | null | |
facebookresearch/theseus | import itertools
import random
import pytest # noqa: F401
import torch
import theseus as th
from tests.theseus_tests.core.common import MockCostFunction, MockCostWeight, MockVar
def test_variable_ordering_iterator():
variables = [MockVar(1, tensor=None, name=f"var{i}") for i in range(50)]
mock_objective = t... | variables[i] | assert | complex_expr | tests/theseus_tests/optimizer/test_variable_ordering.py | test_variable_ordering_iterator | 81 | null | |
facebookresearch/theseus | import numpy as np
import pytest # noqa: F401
import torch
import theseus as th
from .common import MockVar
def test_properties():
for i in range(100):
length = np.random.randint(2, 5)
batch_size = np.random.randint(1, 100)
dtype = torch.float if np.random.random() < 0.5 else torch.long
... | data.ndim | assert | complex_expr | tests/theseus_tests/core/test_variable.py | test_properties | 42 | 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... | scale | assert | variable | tests/theseus_tests/core/test_objective.py | test_copy_no_duplicate_cost_weights | 448 | null | |
facebookresearch/theseus | import pytest # noqa: F401
import torch
from tests.theseus_tests.decorators import run_if_baspacho
from tests.theseus_tests.optimizer.autograd.test_baspacho_sparse_backward import (
get_linearization_and_solver_for_random_sparse,
)
def check_sparse_solver(
batch_size, rows_to_cols_ratio, num_cols, param_size... | atb_check) | assert_* | variable | tests/theseus_tests/optimizer/linear/test_baspacho_sparse_solver.py | check_sparse_solver | 41 | 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... | (batch_size, 1) | assert | collection | tests/theseus_tests/embodied/collision/test_collision_factor.py | test_collision2d_error_shapes | 42 | null | |
aiogram/aiogram | import datetime
import re
import pytest
from aiogram import F
from aiogram.filters import Command, CommandObject
from aiogram.filters.command import CommandStart
from aiogram.types import BotCommand, Chat, Message, User
from tests.mocked_bot import MockedBot
class TestCommandObject:
def test_update_handler_flag... | 1 | assert | numeric_literal | tests/test_filters/test_command.py | test_update_handler_flags | TestCommandObject | 223 | null |
aiogram/aiogram | import datetime
import functools
from typing import Any, NoReturn
import pytest
from pydantic import BaseModel
from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler
from aiogram.dispatcher.event.handler import HandlerObject
from aiogram.dispatcher.event.telegram import TelegramEventObserver
from aiogram.d... | 1 | assert | numeric_literal | tests/test_dispatcher/test_event/test_telegram.py | test_register | TestTelegramEventObserver | 72 | null |
aiogram/aiogram | import asyncio
import datetime
import signal
import time
import warnings
from asyncio import Event
from collections import Counter
from contextlib import suppress
from typing import Any
from unittest.mock import AsyncMock, patch
import pytest
from aiogram import Bot
from aiogram.dispatcher.dispatcher import Dispatche... | 1 | assert | numeric_literal | tests/test_dispatcher/test_dispatcher.py | test_data_bind | TestDispatcher | 99 | null |
aiogram/aiogram | import datetime
import logging
from aiogram.client.session.middlewares.request_logging import RequestLogging
from aiogram.methods import GetMe, SendMessage
from aiogram.types import Chat, Message, User
from tests.mocked_bot import MockedBot
class TestRequestLogging:
async def test_use_middleware(self, bot: Mocked... | caplog.text | assert | complex_expr | tests/test_api/test_client/test_session/test_middlewares/test_request_logging.py | test_use_middleware | TestRequestLogging | 17 | null |
aiogram/aiogram | import functools
from typing import Any
from unittest.mock import AsyncMock, patch
import pytest
from aiogram.dispatcher.event.event import EventObserver
from aiogram.dispatcher.event.handler import HandlerObject
async def my_handler(value: str, index: int = 0) -> Any:
return value
class TestEventObserver:
... | index + 1 | assert | complex_expr | tests/test_dispatcher/test_event/test_event.py | test_register_filters | TestEventObserver | 32 | null |
aiogram/aiogram | from unittest.mock import sentinel
import pytest
from aiogram.methods import GetMe, TelegramMethod
from aiogram.types import TelegramObject, User
from tests.mocked_bot import MockedBot
class TestTelegramMethodRemoveUnset:
@pytest.mark.parametrize(
"values,names",
[
[{}, set()],
... | names | assert | variable | tests/test_api/test_methods/test_base.py | test_remove_unset | TestTelegramMethodRemoveUnset | 22 | null |
aiogram/aiogram | import sys
import pytest
from aiogram.fsm.state import State, StatesGroup, any_state
PY312_OR_GREATER = sys.version_info >= (3, 12)
class TestState:
def test_alone(self):
state = State("test")
assert state._state == | "test" | assert | string_literal | tests/test_fsm/test_state.py | test_alone | TestState | 41 | null |
aiogram/aiogram | from aresponses import ResponsesMockServer
from aiogram import Bot
from aiogram.types import BufferedInputFile, FSInputFile, InputFile, URLInputFile
from tests.mocked_bot import MockedBot
class TestInputFile:
async def test_fs_input_file_readable(self, bot: MockedBot):
file = FSInputFile(__file__, chunk_... | 1 | assert | numeric_literal | tests/test_api/test_types/test_input_file.py | test_fs_input_file_readable | TestInputFile | 21 | null |
aiogram/aiogram | import inspect
from datetime import datetime
from unittest.mock import ANY, AsyncMock, patch
import pytest
from aiogram import Dispatcher, F, Router
from aiogram.dispatcher.event.bases import NextMiddlewareType
from aiogram.enums import UpdateType
from aiogram.exceptions import SceneException
from aiogram.filters imp... | 2 | assert | numeric_literal | tests/test_fsm/test_scene.py | test_wrap_handler | TestObserverDecorator | 157 | null |
aiogram/aiogram | from aiogram.methods import CloseGeneralForumTopic
from tests.mocked_bot import MockedBot
class TestCloseGeneralForumTopic:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CloseGeneralForumTopic, ok=True, result=True)
response: bool = await bot.close_general_fo... | prepare_result.result | assert | complex_expr | tests/test_api/test_methods/test_close_general_forum_topic.py | test_bot_method | TestCloseGeneralForumTopic | 11 | null |
aiogram/aiogram | import inspect
from datetime import datetime
from unittest.mock import ANY, AsyncMock, patch
import pytest
from aiogram import Dispatcher, F, Router
from aiogram.dispatcher.event.bases import NextMiddlewareType
from aiogram.enums import UpdateType
from aiogram.exceptions import SceneException
from aiogram.filters imp... | 1 | assert | numeric_literal | tests/test_fsm/test_scene.py | test_decorator | TestObserverMarker | 94 | null |
aiogram/aiogram | import pytest
from aiogram.dispatcher.flags import Flag, FlagDecorator, FlagGenerator
def flag_fixture() -> Flag:
return Flag("test", True)
def flag_decorator_fixture(flag: Flag) -> FlagDecorator:
return FlagDecorator(flag)
def flag_flag_generator() -> FlagGenerator:
return FlagGenerator()
class TestFl... | flag_decorator.flag | assert | complex_expr | tests/test_flags/test_decorator.py | test_with_value | TestFlagDecorator | 26 | null |
aiogram/aiogram | from aiogram.enums import StickerFormat
from aiogram.methods import AddStickerToSet
from aiogram.types import InputSticker
from tests.mocked_bot import MockedBot
class TestAddStickerToSet:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=... | prepare_result.result | assert | complex_expr | tests/test_api/test_methods/test_add_sticker_to_set.py | test_bot_method | TestAddStickerToSet | 19 | null |
aiogram/aiogram | from copy import copy
from inspect import isclass
import pytest
from aiogram.dispatcher.event.handler import FilterObject
from aiogram.filters import StateFilter
from aiogram.fsm.state import State, StatesGroup
from aiogram.types import Update
class TestStateFilter:
async def test_state_copy(self):
clas... | "OK" | assert | string_literal | tests/test_filters/test_state.py | test_state_copy | TestStateFilter | 65 | null |
aiogram/aiogram | from datetime import datetime
import pytest
from aiogram.filters.chat_member_updated import (
ADMINISTRATOR,
IS_MEMBER,
JOIN_TRANSITION,
LEAVE_TRANSITION,
ChatMemberUpdatedFilter,
_MemberStatusGroupMarker,
_MemberStatusMarker,
_MemberStatusTransition,
)
from aiogram.types import (
... | 4 | assert | numeric_literal | tests/test_filters/test_chat_member_updated.py | test_or | TestMemberStatusGroupMarker | 161 | null |
aiogram/aiogram | from aiogram.methods import GetMe
from aiogram.types import User
from tests.mocked_bot import MockedBot
class TestGetMe:
async def test_me_property(self, bot: MockedBot):
response: User = await bot.me()
assert isinstance(response, User)
assert response == | bot._me | assert | complex_expr | tests/test_api/test_methods/test_get_me.py | test_me_property | TestGetMe | 18 | null |
aiogram/aiogram | import datetime
from typing import Any
from aiogram.handlers import ChatMemberHandler
from aiogram.types import Chat, ChatMemberMember, ChatMemberUpdated, User
class MyHandler(ChatMemberHandler):
async def handle(self) -> Any:
assert self.event == | event | assert | variable | tests/test_handler/test_chat_member.py | handle | MyHandler | 20 | null |
aiogram/aiogram | import pytest
from pymongo.errors import PyMongoError
from aiogram.fsm.state import State
from aiogram.fsm.storage.pymongo import PyMongoStorage, StorageKey
from tests.conftest import CHAT_ID, USER_ID
PREFIX = "fsm"
async def test_update_not_existing_data_with_empty_dictionary(
pymongo_storage: PyMongoStorage,
... | {} | assert | collection | tests/test_fsm/storage/test_pymongo.py | test_update_not_existing_data_with_empty_dictionary | 32 | null | |
aiogram/aiogram | from datetime import datetime
from unittest.mock import patch
import pytest
from aiogram.dispatcher.middlewares.user_context import (
EventContext,
UserContextMiddleware,
)
from aiogram.types import (
Chat,
ChatBoost,
ChatBoostSourceGiftCode,
ChatBoostSourceGiveaway,
ChatBoostSourcePremium... | chat | assert | variable | tests/test_dispatcher/test_middlewares/test_user_context.py | test_call | TestUserContextMiddleware | 48 | null |
aiogram/aiogram | import pytest
from aiogram.types import User
class TestUser:
def test_get_profile_photos(self):
user = User(id=42, is_bot=False, first_name="Test", last_name="User")
method = user.get_profile_photos(description="test")
assert method.user_id == | user.id | assert | complex_expr | tests/test_api/test_types/test_user.py | test_get_profile_photos | TestUser | 58 | null |
aiogram/aiogram | import pytest
from aiogram.fsm.context import FSMContext
from aiogram.fsm.storage.base import StorageKey
from aiogram.fsm.storage.memory import MemoryStorage
from tests.mocked_bot import MockedBot
def state(bot: MockedBot):
storage = MemoryStorage()
key = StorageKey(user_id=42, chat_id=-42, bot_id=bot.id)
... | {} | assert | collection | tests/test_fsm/test_context.py | test_address_mapping | TestFSMContext | 34 | null |
aiogram/aiogram | import asyncio
from collections.abc import AsyncGenerator, AsyncIterable
from typing import (
Any,
AsyncContextManager,
)
from unittest.mock import AsyncMock, patch
import aiohttp_socks
import pytest
from aiohttp import ClientError
from aresponses import ResponsesMockServer
from aiogram import Bot
from aiogra... | ctx | assert | variable | tests/test_api/test_client/test_session/test_aiohttp_session.py | test_context_manager | TestAiohttpSession | 258 | null |
aiogram/aiogram | date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
forum_topic_closed=ForumTopicClosed(),
)
TEST_FORUM_TOPIC_REOPENED = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=U... | value | assert | variable | tests/test_api/test_types/test_message.py | test_reply_answer_aliases | TestMessage | 1,165 | null |
aiogram/aiogram | import pytest
from aiogram.filters.callback_data import CallbackData
from aiogram.types import (
InlineKeyboardButton,
InlineKeyboardMarkup,
KeyboardButton,
ReplyKeyboardMarkup,
)
from aiogram.utils.keyboard import (
InlineKeyboardBuilder,
KeyboardBuilder,
ReplyKeyboardBuilder,
)
class Tes... | rows | assert | variable | tests/test_utils/test_keyboard.py | test_add | TestKeyboardBuilder | 169 | null |
aiogram/aiogram | from pytest import mark, param
from aiogram.enums import ChatAction
from aiogram.types import BufferedInputFile, Chat, ChatPermissions
class TestChat:
def test_ban_sender_chat(self):
chat = Chat(id=-42, type="supergroup")
method = chat.ban_sender_chat(sender_chat_id=-1337)
assert method.... | chat.id | assert | complex_expr | tests/test_api/test_types/test_chat.py | test_ban_sender_chat | TestChat | 12 | null |
aiogram/aiogram | from datetime import datetime
from unittest.mock import patch
import pytest
from aiogram.dispatcher.middlewares.user_context import (
EventContext,
UserContextMiddleware,
)
from aiogram.types import (
Chat,
ChatBoost,
ChatBoostSourceGiftCode,
ChatBoostSourceGiveaway,
ChatBoostSourcePremium... | user | assert | variable | tests/test_dispatcher/test_middlewares/test_user_context.py | test_call | TestUserContextMiddleware | 49 | null |
aiogram/aiogram | from aiogram.methods import AnswerInlineQuery
from aiogram.types import InlineQueryResultArticle, InputTextMessageContent
from tests.mocked_bot import MockedBot
class TestAnswerInlineQuery:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(AnswerInlineQuery, ok=True, resu... | prepare_result.result | assert | complex_expr | tests/test_api/test_methods/test_answer_inline_query.py | test_bot_method | TestAnswerInlineQuery | 21 | null |
aiogram/aiogram | from aiogram.methods import ApproveSuggestedPost
from tests.mocked_bot import MockedBot
class TestApproveSuggestedPost:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveSuggestedPost, ok=True, result=True)
response: bool = await bot.approve_suggested_post... | prepare_result.result | assert | complex_expr | tests/test_api/test_methods/test_approve_suggested_post.py | test_bot_method | TestApproveSuggestedPost | 14 | null |
aiogram/aiogram | from aiogram.methods import CreateInvoiceLink
from aiogram.types import LabeledPrice
from tests.mocked_bot import MockedBot
class TestCreateInvoiceLink:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateInvoiceLink, ok=True, result="https://t.me/invoice... | prepare_result.result | assert | complex_expr | tests/test_api/test_methods/test_create_invoice_link.py | test_bot_method | TestCreateInvoiceLink | 21 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.