repo_id stringclasses 400
values | commit_sha stringclasses 400
values | commit_index int32 0 951 | in_repo_split stringclasses 1
value | cross_repo_split stringclasses 1
value | test_file stringlengths 7 121 | test_function stringlengths 1 108 | assertion_type stringclasses 32
values | difficulty stringclasses 8
values | context_lines int32 3 600 | prefix large_stringlengths 44 113k | target large_stringlengths 1 498 | anchor_sha stringclasses 400
values | anchor_index int32 0 951 | qna_source stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/metrics/test_quality.py | test_pesq | assert | variable | 32 | import numpy as np
import pytest
import torch
import torchaudio
import audiotools
from audiotools import AudioSignal
from audiotools import metrics
from audiotools.core import audio_signal
def test_pesq():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
x = AudioSignal.excerpt(audio_path, duration=1,... | old_pesq | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/metrics/test_quality.py | test_stoi | assert | variable | 26 | import numpy as np
import pytest
import torch
import torchaudio
import audiotools
from audiotools import AudioSignal
from audiotools import metrics
from audiotools.core import audio_signal
def test_stoi():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
x = AudioSignal.excerpt(audio_path, duration=1,... | loss_val_identity | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/metrics/test_spectral.py | test_multiscale_stft | assert | variable | 21 | import numpy as np
from audiotools import AudioSignal
from audiotools import metrics
def test_multiscale_stft():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
x = AudioSignal.excerpt(audio_path, duration=1)
y = x.deepcopy()
loss = metrics.spectral.MultiScaleSTFTLoss()
loss_val_identit... | loss_val_identity | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_model.py | test_base_model | assert | func_call | 23 | import tempfile
import torch
from torch import nn
from audiotools import ml
from audiotools import util
SEED = 0
def seed_and_run(model, *args, **kwargs):
util.seed(SEED)
return model(*args, **kwargs)
def test_base_model():
# Save and load
ml.BaseModel.EXTERN += ["test_model"]
x = torch.randn(... | torch.device("cpu") | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_trainer.py | test_trainer | assert | numeric_literal | 42 | import tempfile
import pytest
import torch
from torch import nn
from audiotools import ml
from audiotools import util
def test_trainer():
class Dataset(torch.utils.data.Dataset):
def __init__(self, N):
super().__init__()
self.N = N
def __len__(self):
return se... | 1 | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_trainer.py | test_trainer | assert | variable | 46 | import tempfile
import pytest
import torch
from torch import nn
from audiotools import ml
from audiotools import util
def test_trainer():
class Dataset(torch.utils.data.Dataset):
def __init__(self, N):
super().__init__()
self.N = N
def __len__(self):
return se... | state_dict | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_trainer.py | test_trainer | assert | complex_expr | 54 | import tempfile
import pytest
import torch
from torch import nn
from audiotools import ml
from audiotools import util
def test_trainer():
class Dataset(torch.utils.data.Dataset):
def __init__(self, N):
super().__init__()
self.N = N
def __len__(self):
return se... | trainer.trainer.state | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_tricks.py | test_compute_grad_norm | assert | numeric_literal | 12 | import numpy as np
import torch
from torch import nn
from audiotools import ml
from audiotools.ml.tricks import compute_grad_norm
def test_compute_grad_norm():
model = DummyModel()
grad_norm = compute_grad_norm(model)
assert grad_norm == | 0.0 | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_tricks.py | test_autoclip | assert | complex_expr | 29 | import numpy as np
import torch
from torch import nn
from audiotools import ml
from audiotools.ml.tricks import compute_grad_norm
def test_autoclip():
model = DummyModel()
optimizer = torch.optim.SGD(model.parameters(), lr=1e-3)
autoclip = ml.tricks.AutoClip(0) # min-clip
grad_history = []
for _... | grad_norm + 1e-6 | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_tricks.py | test_autoclip | assert | complex_expr | 30 | import numpy as np
import torch
from torch import nn
from audiotools import ml
from audiotools.ml.tricks import compute_grad_norm
def test_autoclip():
model = DummyModel()
optimizer = torch.optim.SGD(model.parameters(), lr=1e-3)
autoclip = ml.tricks.AutoClip(0) # min-clip
grad_history = []
for _... | clip_value + 1e-6 | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_tricks.py | test_autobalance | assert | complex_expr | 30 | import numpy as np
import torch
from torch import nn
from audiotools import ml
from audiotools.ml.tricks import compute_grad_norm
def test_autobalance():
losses = torch.randn(10).abs().tolist()
ratios = torch.randn(10).abs()
ratios = torch.nn.functional.normalize(ratios, p=1, dim=-1)
ratios = ratios.... | weight_history[-1] | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
descriptinc/audiotools | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | train | train | tests/ml/test_tricks.py | test_compute_grad_norm | assert | collection | 20 | import numpy as np
import torch
from torch import nn
from audiotools import ml
from audiotools.ml.tricks import compute_grad_norm
def test_compute_grad_norm():
model = DummyModel()
grad_norm = compute_grad_norm(model)
assert grad_norm == 0.0
x, y = torch.randn(1), torch.randn(1)
y_hat = model(x)
... | (x * 2.0 * (y_hat - y)).abs() | b1b0f4063feba878982b1ee1b2f4180e8c282d4c | 58 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_tensorflow_with_sharing | assert | numeric_literal | 35 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | 0 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_jax_jit_gradient | assert | variable | 40 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | x1 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_autograd_gradient | assert | variable | 36 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | x0 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_tensorflow_with_sharing | assert | variable | 33 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | cache | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_object_arrays_backend | assert | variable | 24 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | object | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_auto_backend_custom_array_no_tensordot | assert | string_literal | 24 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | 'numpy' | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_tensorflow_with_sharing | assert | variable | 37 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | cache_sz | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_auto_backend_custom_array_no_tensordot | assert | string_literal | 23 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | 'opt_einsum' | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_jax_jit_gradient | pytest.approx | complex_expr | 30 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | x0, rel=1e-5) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_backends.py | test_jax_jit_gradient | assert | func_call | 30 | import numpy as np
import pytest
from opt_einsum import backends, contract, contract_expression, helpers, sharing
from opt_einsum.contract import Shaped, infer_backend, parse_backend
tests = [
'ab,bc->ca',
'abc,bcd,dea',
'abc,def->fedcba',
'abc,bcd,df->fa',
# test 'prefer einsum' ops
'ijk,ikj'... | pytest.approx(x0, rel=1e-5) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_blas.py | test_can_blas | assert | variable | 66 | import numpy as np
import pytest
from opt_einsum import blas, contract, helpers
blas_tests = [
# DOT
((['k', 'k'], '', set('k')), 'DOT'), # DDOT
((['ijk', 'ijk'], '', set('ijk')), 'DOT'), # DDOT
# GEMV?
# GEMM
((['ij', 'jk'], 'ik', set('j')), 'GEMM'), # GEMM N N
((['ijl', 'jlk'], 'ik'... | benchmark | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_contract.py | test_printing | assert | numeric_literal | 106 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, helpers
from opt_einsum.paths import linear_to_ssa, ssa_to_linear, _PATH_OPTIONS
tests = [
# Test scalar-like operations
'a,->a',
'ab,->ab',
',ab,->ab',
# Test hadamard-like products
'a,ab,ab... | 728 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_contract.py | test_linear_vs_ssa | assert | variable | 107 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, helpers
from opt_einsum.paths import linear_to_ssa, ssa_to_linear, _PATH_OPTIONS
tests = [
# Test scalar-like operations
'a,->a',
'ab,->ab',
',ab,->ab',
# Test hadamard-like products
'a,ab,ab... | linear_path | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_contract.py | test_contract_expressions | assert | func_call | 122 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, helpers
from opt_einsum.paths import linear_to_ssa, ssa_to_linear, _PATH_OPTIONS
tests = [
# Test scalar-like operations
'a,->a',
'ab,->ab',
',ab,->ab',
# Test hadamard-like products
'a,ab,ab... | expr.__str__() | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_contract.py | test_contract_expressions | assert | func_call | 121 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, helpers
from opt_einsum.paths import linear_to_ssa, ssa_to_linear, _PATH_OPTIONS
tests = [
# Test scalar-like operations
'a,->a',
'ab,->ab',
',ab,->ab',
# Test hadamard-like products
'a,ab,ab... | expr.__repr__() | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_edge_cases.py | test_can_blas_on_healed_broadcast_dimensions | assert | bool_literal | 12 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression
def test_can_blas_on_healed_broadcast_dimensions():
expr = contract_expression("ab,bc,bd->acd", (5, 4), (1, 5), (4, 20))
# first contraction involves broadcasting
assert expr.contraction_list[0][2] == 'bc,ab->bca'
... | False | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_edge_cases.py | test_can_blas_on_healed_broadcast_dimensions | assert | string_literal | 15 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression
def test_can_blas_on_healed_broadcast_dimensions():
expr = contract_expression("ab,bc,bd->acd", (5, 4), (1, 5), (4, 20))
# first contraction involves broadcasting
assert expr.contraction_list[0][2] == 'bc,ab->bca'
a... | 'GEMM' | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_edge_cases.py | test_contract_expression_checks | pytest.raises | variable | 9 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression
def test_contract_expression_checks():
# check optimize needed
with pytest.raises( | ValueError) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_edge_cases.py | test_can_blas_on_healed_broadcast_dimensions | assert | string_literal | 11 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression
def test_can_blas_on_healed_broadcast_dimensions():
expr = contract_expression("ab,bc,bd->acd", (5, 4), (1, 5), (4, 20))
# first contraction involves broadcasting
assert expr.contraction_list[0][2] == | 'bc,ab->bca' | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_edge_cases.py | test_can_blas_on_healed_broadcast_dimensions | assert | string_literal | 14 | import numpy as np
import pytest
from opt_einsum import contract, contract_expression
def test_can_blas_on_healed_broadcast_dimensions():
expr = contract_expression("ab,bc,bd->acd", (5, 4), (1, 5), (4, 20))
# first contraction involves broadcasting
assert expr.contraction_list[0][2] == 'bc,ab->bca'
a... | 'bca,bd->acd' | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_input.py | test_type_errors | pytest.raises | variable | 24 | import numpy as np
import pytest
from opt_einsum import contract, contract_path
def build_views(string):
chars = 'abcdefghij'
sizes = np.array([2, 3, 4, 5, 4, 3, 2, 6, 5, 4])
sizes = {c: s for c, s in zip(chars, sizes)}
views = []
string = string.replace('...', 'ij')
terms = string.split('-... | TypeError) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_input.py | test_value_errors | pytest.raises | variable | 23 | import numpy as np
import pytest
from opt_einsum import contract, contract_path
def build_views(string):
chars = 'abcdefghij'
sizes = np.array([2, 3, 4, 5, 4, 3, 2, 6, 5, 4])
sizes = {c: s for c, s in zip(chars, sizes)}
views = []
string = string.replace('...', 'ij')
terms = string.split('-... | ValueError) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_explicit_path | assert | numeric_literal | 79 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | 6 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_dp_edge_cases_dimension_1 | assert | numeric_literal | 81 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | 3 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_custom_random_greedy | assert | numeric_literal | 87 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | 10 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_custom_random_greedy | assert | numeric_literal | 100 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | 16 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_custom_path_optimizer | assert | variable | 90 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | out | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_parallel_random_greedy | assert | variable | 92 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | pool | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_path_scalar_cases | assert | variable | 85 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | order | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_optimizer_registration | pytest.raises | variable | 81 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | KeyError) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_paths.py | test_custom_random_greedy | pytest.raises | variable | 81 | import itertools
import sys
import numpy as np
import pytest
import opt_einsum as oe
explicit_path_tests = {
'GEMM1': ([set('abd'), set('ac'), set('bdc')], set(''), {
'a': 1,
'b': 2,
'c': 3,
'd': 4
}),
'Inner1': ([set('abcd'), set('abc'), set('bc')], set(''), {
'a'... | ValueError) | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_sharing.py | method1 | assert | variable | 43 | import itertools
import weakref
from collections import Counter
import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, helpers, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.pars... | refs | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_sharing.py | test_complete_sharing | assert | variable | 55 | import itertools
import weakref
from collections import Counter
import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, helpers, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.pars... | expected | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_sharing.py | test_multithreaded_sharing | assert | collection | 53 | import itertools
import weakref
from collections import Counter
import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, helpers, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.pars... | [expected] * 16 | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_sharing.py | test_chain_sharing | assert | variable | 68 | import itertools
import weakref
from collections import Counter
import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, helpers, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.pars... | num_exprs_sharing | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgasmith/opt_einsum | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | train | train | opt_einsum/tests/test_sharing.py | test_partial_sharing | assert | complex_expr | 60 | import itertools
import weakref
from collections import Counter
import numpy as np
import pytest
from opt_einsum import contract, contract_expression, contract_path, get_symbol, helpers, shared_intermediates
from opt_einsum.backends import to_cupy, to_torch
from opt_einsum.contract import _einsum
from opt_einsum.pars... | num_exprs_sharing['einsum'] | 3a0df5f15f03c32bc60c60495585aae49395cba1 | 56 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_annotations.py | test_annotated_callback | assert | collection | 9 | import pytest
import pydash as _
from pydash._compat import PY2
@pytest.mark.skipif(PY2, reason='test requires Python 3 annotations')
def test_annotated_callback():
assert _.map_([1, 2], typed_function) == | [2, 3] | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_arrays.py | test_pop | assert | variable | 17 | import math
import pytest
import pydash as _
from .fixtures import parametrize
@parametrize('case,expected,after', [
(([1, 2, 3],), 3, [1, 2]),
(([1, 2, 3], 0), 1, [2, 3]),
(([1, 2, 3], 1), 2, [1, 3]),
])
def test_pop(case, expected, after):
array = case[0]
assert _.pop(*case) == expected
as... | after | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_arrays.py | test_remove | assert | func_call | 16 | import math
import pytest
import pydash as _
from .fixtures import parametrize
@parametrize('case,filter_by,expected', [
([1, 2, 3, 4, 5, 6], lambda x: x % 2 == 0, [2, 4, 6]),
([1, 2, 3, 4], lambda x: x >= 3, [3, 4]),
])
def test_remove(case, filter_by, expected):
original = list(case)
assert _.remov... | set([]) | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_arrays.py | test_chunk | assert | variable | 18 | import math
import pytest
import pydash as _
from .fixtures import parametrize
@parametrize('case,expected', [
(([1, 2, 3, 4, 5],), [[1], [2], [3], [4], [5]]),
(([1, 2, 3, 4, 5], 2), [[1, 2], [3, 4], [5]]),
(([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]),
(([1, 2, 3, 4, 5], 4), [[1, 2, 3, 4], [5]]),
... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_lazy | assert | numeric_literal | 28 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_lazy():
tracker = {'called': False}
def interceptor(value):
tracker['called'] = True
return value.pop()
chain = _... | 3 | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_late_value_reuse | assert | numeric_literal | 13 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_late_value_reuse():
square_sum = _.chain().power(2).sum()
assert square_sum([1, 2, 3, 4]) == 30
assert square_sum([2]) == | 4 | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_late_value | assert | numeric_literal | 12 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_late_value():
square_sum = _.chain().power(2).sum()
assert square_sum([1, 2, 3, 4]) == | 30 | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_late_value_override | assert | numeric_literal | 12 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_late_value_override():
square_sum = _.chain([1, 2, 3, 4]).power(2).sum()
assert square_sum([5, 6, 7, 8]) == | 174 | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_dash_alias | assert | complex_expr | 11 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_dash_alias():
assert _.py_ is | _._ | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_plant | assert | variable | 19 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_plant():
value = [1, 2, 3, 4]
square_sum1 = _.chain(value).power(2).sum()
def root_value(wrapper):
if isinstance(wrapper._... | value | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining | assert | variable | 22 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
@parametrize('value,methods', [
([1, 2, 3, 4], [('without', (2, 3)),
('reject', (lambda x: x > 1,))])
])
def test_chaining(value, methods... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_commit | assert | variable | 14 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_commit():
chain = _.chain([1, 2, 3, 4]).power(2).sum()
committed = chain.commit()
assert chain is not | committed | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_plant | assert | variable | 25 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_plant():
value = [1, 2, 3, 4]
square_sum1 = _.chain(value).power(2).sum()
def root_value(wrapper):
if isinstance(wrapper._... | test_value | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_dash_method_call | assert | func_call | 12 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_dash_method_call():
value = [1, 2, 3, 4, 5]
assert _._.initial(value) == | _.initial(value) | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_commit | assert | func_call | 15 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_commit():
chain = _.chain([1, 2, 3, 4]).power(2).sum()
committed = chain.commit()
assert chain is not committed
assert chain.... | committed.value() | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_dash_instance_chaining | assert | func_call | 15 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_dash_instance_chaining():
value = [1, 2, 3, 4]
from__ = _._(value).without(2, 3).reject(lambda x: x > 1)
from_chain = _.chain(value).without... | from_chain.value() | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_chaining.py | test_chaining_methods | assert | func_call | 18 | from copy import deepcopy
import pydash as _
from .fixtures import parametrize
pydash_methods = _.filter_(dir(_), lambda m: callable(getattr(_, m, None)))
def test_chaining_methods():
chain = _.chain([])
for method in dir(_):
if not callable(method):
continue
chained = getattr(... | getattr(_, method) | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_collections.py | test_sample | assert | variable | 13 | import math
import pydash as _
from . import fixtures
from .fixtures import parametrize
@parametrize('case', [
[1, 2, 3, 4, 5, 6],
])
def test_sample(case):
assert _.sample(case) in | case | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_collections.py | test_at | assert | variable | 15 | import math
import pydash as _
from . import fixtures
from .fixtures import parametrize
@parametrize('case,expected', [
((['a', 'b', 'c', 'd', 'e'], [0, 2, 4]), ['a', 'c', 'e']),
((['moe', 'larry', 'curly'], 0, 2), ['moe', 'curly']),
(({'a': 1, 'b': 2, 'c': 3}, 'a', 'b'), [1, 2])
])
def test_at(case, exp... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_functions.py | test_after | assert | none_literal | 17 | import time
import pydash as _
from .fixtures import parametrize
@parametrize('case,expected', [
((lambda: 3, 2), 3),
((lambda: 3, -1), 3),
])
def test_after(case, expected):
done = _.after(*case)
for x in range(case[1] - 1):
ret = done()
assert ret is | None | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_functions.py | test_after | assert | variable | 20 | import time
import pydash as _
from .fixtures import parametrize
@parametrize('case,expected', [
((lambda: 3, 2), 3),
((lambda: 3, -1), 3),
])
def test_after(case, expected):
done = _.after(*case)
for x in range(case[1] - 1):
ret = done()
assert ret is None
ret = done()
ass... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_numerical.py | test_add | assert | variable | 11 | import pydash as _
from .fixtures import parametrize
import pytest
@parametrize('case,expected', [
((5, 3), 8),
])
def test_add(case, expected):
assert _.add(*case) == | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_objects.py | test_clone | assert | variable | 19 | from collections import namedtuple
import datetime as dt
import pydash as _
from . import fixtures
from .fixtures import parametrize
today = dt.date.today()
@parametrize('case', [
{'a': {'d': 1}, 'b': {'c': 2}},
[{'a': {'d': 1}, 'b': {'c': 2}}],
])
def test_clone(case):
result = _.clone(case)
asse... | case | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_objects.py | test_unset | assert | variable | 22 | from collections import namedtuple
import datetime as dt
import pydash as _
from . import fixtures
from .fixtures import parametrize
today = dt.date.today()
@parametrize('obj,path,expected,new_obj', [
({'a': [{'b': {'c': 7}}]}, 'a.0.b.c', True, {'a': [{'b': {}}]}),
([1, 2, 3], '1', True, [1, 3]),
([1, 2... | new_obj | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_objects.py | test_assign | assert | variable | 19 | from collections import namedtuple
import datetime as dt
import pydash as _
from . import fixtures
from .fixtures import parametrize
today = dt.date.today()
@parametrize('case,expected', [
(({'name': 'fred'}, {'employer': 'slate'}),
{'name': 'fred', 'employer': 'slate'}),
(({'name': 'fred'}, {'employer... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_predicates.py | test_eq | assert | variable | 19 | import datetime
import decimal
import operator
import re
import pydash as _
from . import fixtures
from .fixtures import parametrize
@parametrize('value,other,expected', [
('a', 'a', True),
(None, None, True),
(None, '', False),
(1, str(1), False)
])
def test_eq(value, other, expected):
assert _... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_strings.py | test_url | assert | variable | 38 | import re
import pydash as _
from pydash._compat import urlsplit, parse_qsl
from .fixtures import parametrize
@parametrize('case,expected', [
({'args': [''], 'kargs': {}}, ''),
({'args': ['/'], 'kargs': {}}, '/'),
({'args': ['http://github.com'], 'kargs': {}}, 'http://github.com'),
({'args': ['http://... | e_path | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_strings.py | test_camel_case | assert | variable | 20 | import re
import pydash as _
from pydash._compat import urlsplit, parse_qsl
from .fixtures import parametrize
@parametrize('case,expected', [
('foo bar baz', 'fooBarBaz'),
('foo bar baz', 'fooBarBaz'),
('foo__bar_baz', 'fooBarBaz'),
('foo-_bar-_-baz', 'fooBarBaz'),
('foo!bar,baz', 'fooBarBaz'),
... | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_utilities.py | test_random | assert | variable | 19 | import time
import pydash as _
import pytest
from .fixtures import parametrize
@parametrize('case,minimum,maximum', [
((), 0, 1),
((25,), 0, 25),
((5, 10), 5, 10)
])
def test_random(case, minimum, maximum):
for x in range(50):
rnd = _.random(*case)
assert isinstance(rnd, int)
... | rnd | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_utilities.py | test_constant | assert | variable | 15 | import time
import pydash as _
import pytest
from .fixtures import parametrize
@parametrize('case', [
'foo',
'bar'
])
def test_constant(case):
assert _.constant(case)() == | case | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_utilities.py | test_now | assert | func_call | 13 | import time
import pydash as _
import pytest
from .fixtures import parametrize
def test_now():
present = int(time.time() * 1000)
# Add some leeway when comparing time.
assert (present - 1) <= | _.now() | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
dgilland/pydash | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | train | train | tests/test_utilities.py | test_attempt | assert | variable | 14 | import time
import pydash as _
import pytest
from .fixtures import parametrize
@parametrize('case,expected', [
((lambda a, b: a / b, 4, 2), 2)
])
def test_attempt(case, expected):
assert _.attempt(*case) == | expected | db043ef2a62d21a90bfd51bb0c6a144040d262e5 | 331 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/action_parsers/utils/test_set_property_value.py | test_set_property_value_datetime | assert | variable | 20 | from datetime import datetime
from typing import List
import pytest
from django_unicorn.components import UnicornView
from django_unicorn.views.action_parsers.utils import set_property_value
from example.coffee.models import Flavor, Taste
def test_set_property_value_datetime():
component = FakeComponent(componen... | dt | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/message/test_call_method.py | test_message_call_method_with_message | assert | variable | 43 | import time
from typing import Dict, Optional
import orjson
import shortuuid
from tests.views.message.utils import post_and_get_response
from django_unicorn.components import UnicornView, unicorn_view
from django_unicorn.utils import generate_checksum
def _post_to_component(
client,
method_name: str,
com... | dom | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/templatetags/test_unicorn_render.py | test_unicorn_render_component_one_script_tag | assert | variable | 24 | import re
import pytest
from django.template import Context
from django.template.base import Parser, Token, TokenType
from django_unicorn.components import UnicornView
from django_unicorn.errors import ComponentNotValidError
from django_unicorn.templatetags.unicorn import unicorn
from django_unicorn.utils import gene... | html | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/message/test_call_method.py | test_message_call_method_redirect | assert | variable | 38 | import time
from typing import Dict, Optional
import orjson
import shortuuid
from tests.views.message.utils import post_and_get_response
from django_unicorn.components import UnicornView, unicorn_view
from django_unicorn.utils import generate_checksum
def _post_to_component(
client,
method_name: str,
com... | body | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/action_parsers/utils/test_set_property_value.py | test_set_property_value_model | assert | variable | 26 | from datetime import datetime
from typing import List
import pytest
from django_unicorn.components import UnicornView
from django_unicorn.views.action_parsers.utils import set_property_value
from example.coffee.models import Flavor, Taste
def test_set_property_value_model():
component = FakeComponent(component_n... | model | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/message/test_message.py | assert_json_error | assert | variable | 14 | import time
from uuid import uuid4
import pytest
from django.http import JsonResponse
from django_unicorn.errors import ComponentClassLoadError, ComponentModuleLoadError
from django_unicorn.views import message
def assert_json_error(response, error):
assert isinstance(response, JsonResponse)
assert response.... | error | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_component.py | test_meta_javascript_exclude_nested_multiple_with_spaces | assert | variable | 30 | import types
import orjson
import pytest
from tests.views.fake_components import (
FakeAuthenticationComponent,
FakeValidationComponent,
)
from django_unicorn.components import UnicornView
from django_unicorn.serializer import InvalidFieldNameError
def component():
return ExampleComponent(component_id="a... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_convert_to_dash_case.py | test_convert_to_dash_case | assert | variable | 8 | from django_unicorn.components.unicorn_view import convert_to_dash_case
def test_convert_to_dash_case():
expected = "hello-world"
actual = convert_to_dash_case("hello_world")
assert expected == | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_convert_to_pascal_case.py | test_convert_to_pascal_case | assert | variable | 8 | from django_unicorn.components.unicorn_view import convert_to_pascal_case
def test_convert_to_pascal_case():
expected = "HelloWorld"
actual = convert_to_pascal_case("hello-world")
assert expected == | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_convert_to_snake_case.py | test_convert_to_snake_case | assert | variable | 8 | from django_unicorn.components.unicorn_view import convert_to_snake_case
def test_convert_to_snake_case():
expected = "hello_world"
actual = convert_to_snake_case("hello-world")
assert expected == | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_get_locations.py | test_get_locations_kebab_case | assert | variable | 21 | import pytest
from django_unicorn.components.unicorn_view import get_locations
def cache_clear():
get_locations.cache_clear()
def clear_apps(settings):
unicorn_apps = settings.UNICORN["APPS"]
del settings.UNICORN["APPS"]
yield
settings.UNICORN["APPS"] = unicorn_apps
def test_get_locations_keba... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/components/test_unicorn_template_response.py | test_desoupify | assert | variable | 25 | import pytest
from bs4 import BeautifulSoup
from django_unicorn.components.unicorn_template_response import (
UnicornTemplateResponse,
assert_has_single_wrapper_element,
get_root_element,
)
from django_unicorn.errors import (
MissingComponentElementError,
MissingComponentViewElementError,
Multi... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/serializer/test_dumps.py | test_int | assert | variable | 28 | import json
import uuid
from datetime import timedelta
from decimal import Decimal
from types import MappingProxyType
from typing import Dict
import pytest
from django.db import models
from django.utils.timezone import now
from pydantic import BaseModel
from django_unicorn import serializer
from django_unicorn.serial... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/serializer/test_model_value.py | test_model_value_all_fields | assert | variable | 30 | import pytest
from django.db import models
from django_unicorn.components import ModelValueMixin
from django_unicorn.serializer import model_value
from example.coffee.models import Flavor
def test_model_value_all_fields():
flavor = Flavor(name="flavor-1")
expected = {
"date": None,
"datetime"... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/test_settings.py | test_settings_cache_alias | assert | variable | 17 | import pytest
from django_unicorn.settings import (
get_cache_alias,
get_minify_html_enabled,
get_morpher_settings,
get_script_location,
get_serial_enabled,
)
def test_settings_cache_alias(settings):
settings.UNICORN["CACHE_ALIAS"] = "unicorn_cache"
expected = "unicorn_cache"
actual =... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/test_typer.py | test_cast_attribute_value_int | assert | variable | 17 | import datetime
from dataclasses import dataclass
from typing import List, Optional
from typing import get_type_hints as typing_get_type_hints
from pydantic import BaseModel
from django_unicorn.components import UnicornView
from django_unicorn.typer import cast_attribute_value, cast_value, get_type_hints
from example... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/test_utils.py | test_generate_checksum_bytes | assert | variable | 19 | import pytest
from django.template.backends.django import Template
from django_unicorn.utils import (
create_template,
generate_checksum,
get_method_arguments,
is_non_string_sequence,
sanitize_html,
)
def test_generate_checksum_bytes(settings):
settings.SECRET_KEY = "asdf"
expected = "Tfx... | actual | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/action_parsers/utils/test_set_property_value.py | test_set_property_value_str | assert | variable | 25 | from datetime import datetime
from typing import List
import pytest
from django_unicorn.components import UnicornView
from django_unicorn.views.action_parsers.utils import set_property_value
from example.coffee.models import Flavor, Taste
def test_set_property_value_str():
component = FakeComponent(component_nam... | string | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/test_is_component_field_model_or_unicorn_field.py | test_type_hint | assert | variable | 13 | from django_unicorn.components import UnicornView
from django_unicorn.views.utils import _is_component_field_model_or_unicorn_field
from example.coffee.models import Flavor
def test_type_hint():
component = TypeHintView(component_name="asdf", component_id="test_type_hint")
name = "model"
actual = _is_compo... | Flavor | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
django-commons/django-unicorn | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | train | train | tests/views/utils/test_set_property_from_data.py | component_queryset_field_asserts | assert | variable | 17 | import sys
from datetime import datetime, timezone
from typing import List
import pytest
from django.db.models import Model, QuerySet
from django_unicorn.components import UnicornView
from django_unicorn.typing import QuerySetType
from django_unicorn.views.utils import set_property_from_data
from example.coffee.model... | Flavor | 04be090fec6234f5501f47f1c4661beb454db861 | 139 | v2_extractor_at_anchor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.