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
webis-de/small-text
import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal, assert_raises def assert_array_not_equal(x, y): assert_raises(AssertionError, assert_array_equal, x, y) def assert_csr_matrix_equal(x, y, check_shape=True): if check_shape and x.shape != y.shape: rai...
other)
assert_*
variable
tests/utils/testing.py
assert_list_of_tensors_not_equal
41
null
webis-de/small-text
import os import unittest import pytest import small_text from importlib import reload from packaging.version import parse, Version from unittest.mock import patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_QUIET, VERBOSITY_MORE_VERBOSE ...
args.max_length)
self.assertIsNone
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_setfit.py
test_setfit_model_arguments_init_default
TestSetFitModelArguments
39
null
webis-de/small-text
import os import unittest import pytest import small_text import numpy as np from importlib import reload from unittest.mock import patch from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_MORE_VERBOSE...
classifier.lr)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_classification.py
test_init
TestTransformerBasedClassification
272
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import call, patch, Mock, ANY from numpy.testing import assert_array_equal from scipy import sparse from scipy.sparse import csr_matrix, vstack from small_text.active_learner import ( AbstractPoolBasedActiveLearner, ActiveLearner, PoolBasedActiveLearne...
clf_mock)
self.assertEqual
variable
tests/unit/small_text/test_active_learner.py
test_update_reuse_model
_PoolBasedActiveLearnerTest
551
null
webis-de/small-text
import unittest import numpy as np from scipy.sparse import csr_matrix from small_text.query_strategies.multi_label import ( CategoryVectorInconsistencyAndRanking, _label_cardinality_inconsistency, LabelCardinalityInconsistency, _uncertainty_weighted_label_cardinality_inconsistency, AdaptiveActive...
lci.shape)
self.assertEqual
complex_expr
tests/unit/small_text/query_strategies/test_multi_label.py
test_label_cardinality_inconsistency_average_two_labels
LabelCardinalityFunctionTest
43
null
webis-de/small-text
import unittest import numpy as np from unittest import mock from small_text import ( ConfidenceEnhancedLinearSVC, RandomSampling, SklearnClassifier, SklearnDataset ) from small_text.data.sampling import _get_class_histogram from small_text.query_strategies.class_balancing import ClassBalancer, _get_r...
n)
assert_*
variable
tests/unit/small_text/query_strategies/test_class_balancing.py
test_subsample_when_not_enough_samples
ClassBalancerSubsamplingTest
110
null
webis-de/small-text
import unittest import pytest import numpy as np from abc import abstractmethod from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.data.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.excep...
ds_cloned.y)
assert_*
complex_expr
tests/unit/small_text/integrations/pytorch/test_datasets.py
test_clone
_PytorchTextClassificationDatasetTest
206
null
webis-de/small-text
import logging import unittest from logging import Logger, INFO, DEBUG from unittest.mock import patch from small_text import VerbosityLogger, verbosity_logger, VERBOSITY_QUIET, VERBOSITY_ALL class VerbosityLoggerTest(unittest.TestCase): @patch('small_text.utils.logging.Logger.debug') def test_debug(self, d...
msg)
assert_*
variable
tests/unit/small_text/utils/test_logging.py
test_debug
VerbosityLoggerTest
19
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import Mock, patch from numpy.testing import assert_array_equal from sklearn.preprocessing import normalize from small_text.classifiers import ConfidenceEnhancedLinearSVC from small_text.query_strategies import ( LeastConfidence, AnchorSubs...
str(query_strategy))
self.assertEqual
func_call
tests/integration/small_text/query_strategies/test_subsampling.py
test_str
AnchorSubsamplingTest
140
null
webis-de/small-text
import os import numpy as np def increase_dense_labels_safe(ds): """Increase the labels without leaving the range of the target_labels property. The only purpose of this operation is to alter the labels so we can check for a change later.""" # modulo needs not be used when single index result is 0 if...
seed
assert
variable
tests/utils/misc.py
random_seed
22
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_UNLABELED from small_text.data.datasets import is_multi_label from small_text.data.datasets import ( SklearnDataset, DatasetView, Te...
y_new)
assert_*
variable
tests/unit/small_text/data/test_datasets.py
test_set_labels
_DatasetTest
159
null
webis-de/small-text
import unittest import numpy as np from scipy.sparse import csr_matrix from small_text.base import LABEL_UNLABELED from small_text.classifiers.classification import ConfidenceEnhancedLinearSVC, SklearnClassifier from small_text.data.datasets import SklearnDataset from tests.utils.datasets import random_sklearn_datas...
proba.shape[0])
self.assertEqual
complex_expr
tests/unit/small_text/classifiers/test_classifiers.py
test_predict_proba_on_empty_data
_ClassifierBaseFunctionalityTest
55
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.data import balanced_sampling, stratified_sampling from small_text.data.sampling import _get_class_histogram from small_text.utils.labels import list_to_csr class StratifiedSamplingTest...
len(counts))
self.assertEqual
func_call
tests/unit/small_text/data/test_sampling.py
test_stratified_sampling_with_gaps
StratifiedSamplingTest
84
null
webis-de/small-text
import unittest import pytest import numpy as np from packaging.version import parse, Version from unittest.mock import patch from unittest import mock from unittest.mock import Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_...
issparse(y_pred))
self.assertTrue
func_call
tests/integration/small_text/integrations/pytorch/classifiers/test_kimcnn.py
test_fit_and_predict
_KimCNNClassifierTest
75
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from sklearn.feature_extraction.text import TfidfVectorizer from unittest.mock import patch from small_text.data import SklearnDataset, TextDataset from tests.utils.datasets import random_labeling, random_labels from tests.utils.testing i...
dataset.y)
assert_*
complex_expr
tests/unit/small_text/data/test_dataset_construction.py
test_from_arrays_with_lists
TextDatasetConstructionSingleLabelTest
150
null
webis-de/small-text
import unittest import numpy as np from scipy.sparse import csr_matrix from small_text.query_strategies.multi_label import ( CategoryVectorInconsistencyAndRanking, _label_cardinality_inconsistency, LabelCardinalityInconsistency, _uncertainty_weighted_label_cardinality_inconsistency, AdaptiveActive...
uwlci.shape)
self.assertEqual
complex_expr
tests/unit/small_text/query_strategies/test_multi_label.py
test_label_cardinality_inconsistency_average_one_and_a_half_labels
UncertaintyWeightedLabelCardinalityFunctionTest
142
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import patch from small_text.utils.clustering import init_kmeans_plusplus_safe class ClusteringUtilsTest(unittest.TestCase): @patch('small_text.utils.clustering.warnings.warn') @patch('small_text.utils.clustering.choice') @patch('small_...
indices.shape[0])
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_clustering.py
test_init_kmeans_plusplus_safe
ClusteringUtilsTest
26
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import create_autospec, patch from scipy.sparse import issparse, csr_matrix from small_text.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.datasets import t...
y_pred.shape)
self.assertEqual
complex_expr
tests/integration/small_text/integrations/transformers/classifiers/test_setfit.py
test_fit_and_predict
_ClassificationTest
54
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_almost_equal from small_text.query_strategies.base import argselect class ArgselectIntegrationTest(unittest.TestCase): def test_argselect_maximum(self, n=5): for _ in range(1000): arr = np.random.randn(100) ...
np.sort(arr[indices]))
assert_*
func_call
tests/integration/small_text/query_strategies/test_base.py
test_argselect_maximum
ArgselectIntegrationTest
19
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_IGNORED from small_text.utils.labels import ( concatenate, csr_to_list, get_ignored_labels_mask, get_num_labels, list_to_csr, remove_by_index ) ...
y_new)
assert_*
variable
tests/unit/small_text/utils/test_labels.py
test_remove_by_index_dense
LabelUtilsTest
85
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNIntegrationTest(unittest.TestCase): def test_simple_prediction(self): """ Simple prediction with default weights (untrained). """ n = 10 vocab_size = 11 ...
output.size(1))
self.assertEqual
func_call
tests/integration/small_text/integrations/pytorch/models/test_kimcnn.py
test_simple_prediction
KimCNNIntegrationTest
33
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from sklearn.feature_extraction.text import TfidfVectorizer from unittest.mock import patch from small_text.data import SklearnDataset, TextDataset from tests.utils.datasets import random_labeling, random_labels from tests.utils.testing i...
dataset.x)
assert_*
complex_expr
tests/unit/small_text/data/test_dataset_construction.py
test_from_arrays_with_lists
TextDatasetConstructionSingleLabelTest
149
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import call, patch, Mock, ANY from numpy.testing import assert_array_equal from scipy import sparse from scipy.sparse import csr_matrix, vstack from small_text.active_learner import ( AbstractPoolBasedActiveLearner, ActiveLearner, PoolBasedActiveLearne...
len(dataset)
assert
func_call
tests/unit/small_text/test_active_learner.py
test_query_with_custom_representation_invalid
_PoolBasedActiveLearnerTest
346
null
webis-de/small-text
import unittest import pytest import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.misc import increase_dense_labels_safe from test...
len(result))
self.assertEqual
func_call
tests/unit/small_text/integrations/transformers/test_datasets.py
test_indexing_single_index
_TransformersDatasetTest
235
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import patch from scipy.sparse import csr_matrix from small_text.data import balanced_sampling, stratified_sampling from small_text.initialization import random_initialization, \ random_initialization_stratified, random_initialization_balanced from tests.util...
indices.shape[0])
self.assertEqual
complex_expr
tests/unit/small_text/initialization/test_strategies.py
test_random_initialization_stratified_multilabel
RandomInitializationStratifiedTest
63
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import create_autospec, patch from scipy.sparse import issparse, csr_matrix from small_text.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.datasets import t...
issparse(y_pred))
self.assertTrue
func_call
tests/integration/small_text/integrations/transformers/classifiers/test_setfit.py
test_fit_and_predict
_ClassificationTest
55
null
webis-de/small-text
import os import unittest import pytest import small_text from importlib import reload from packaging.version import parse, Version from unittest.mock import patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_QUIET, VERBOSITY_MORE_VERBOSE ...
args.seed)
self.assertIsNone
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_setfit.py
test_setfit_model_arguments_init_default
TestSetFitModelArguments
48
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNInitTest(unittest.TestCase): DEFAULT_KERNEL_HEIGHTS = [3, 4, 5] def test_init_parameters_default(self): vocab_size = 1000 max_seq_length = 50 model = KimCNN(vocab_s...
model.device)
self.assertIsNotNone
complex_expr
tests/unit/small_text/integrations/pytorch/models/test_kimcnn.py
test_init_parameters_default
KimCNNInitTest
34
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import patch from small_text.utils.clustering import init_kmeans_plusplus_safe class ClusteringUtilsTest(unittest.TestCase): @patch('small_text.utils.clustering.warnings.warn') @patch('small_text.utils.clustering.choice') @patch('small_...
centers.shape)
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_clustering.py
test_init_kmeans_plusplus_safe
ClusteringUtilsTest
25
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import patch, MagicMock from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class BuildLayerSpecificParamsTest(unittest.TestCase): def _assert_params(self, params, base_lr, num_different_lrs): self.assertIsNotNon...
param['lr'] > 0)
self.assertTrue
complex_expr
tests/unit/small_text/integrations/transformers/utils/test_classification.py
_assert_params
BuildLayerSpecificParamsTest
187
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNInitTest(unittest.TestCase): DEFAULT_KERNEL_HEIGHTS = [3, 4, 5] def test_init_parameters_specific(self): vocab_size = 1000 max_seq_length = 50 num_classes = 3 ...
conv.in_channels)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/pytorch/models/test_kimcnn.py
test_init_parameters_specific
KimCNNInitTest
96
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_IGNORED from small_text.utils.labels import ( concatenate, csr_to_list, get_ignored_labels_mask, get_num_labels, list_to_csr, remove_by_index ) ...
mask)
assert_*
variable
tests/unit/small_text/utils/test_labels.py
test_get_ignored_labels_mask_dense
LabelUtilsTest
71
null
webis-de/small-text
import unittest import numpy as np from unittest import mock from small_text.data.sampling import balanced_sampling, stratified_sampling from small_text.data.splits import split_data from tests.utils.datasets import random_sklearn_dataset class SplitDataTest(unittest.TestCase): @mock.patch('numpy.random.permut...
len(subset_valid))
self.assertEqual
func_call
tests/unit/small_text/data/test_splits.py
test_split_data_random
SplitDataTest
37
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.data.datasets import ( DatasetView, SklearnDataset, SklearnDatasetView, TextDataset, TextDatasetView ) from small_text.data.exceptions import U...
ds_cloned.y)
assert_*
complex_expr
tests/unit/small_text/data/test_datatset_views.py
_clone_test
_DatasetViewTest
168
null
webis-de/small-text
import unittest import pytest import numpy as np from abc import abstractmethod from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.data.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.excep...
len(ds))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/test_datasets.py
test_datasen_len
_PytorchTextClassificationDatasetTest
299
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import call, patch, Mock, ANY from numpy.testing import assert_array_equal from scipy import sparse from scipy.sparse import csr_matrix, vstack from small_text.active_learner import ( AbstractPoolBasedActiveLearner, ActiveLearner, PoolBasedActiveLearne...
ANY)
assert_*
variable
tests/unit/small_text/test_active_learner.py
test_query
_PoolBasedActiveLearnerTest
306
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class TransformersDatasetTest(unittest.TestCase): def test_indexing(self): data = random_transformer_dataset(10) dataset = TransformersDataset(data) subset = data...
len(subset))
self.assertEqual
func_call
tests/integration/small_text/integrations/transformers/test_datasets.py
test_indexing
TransformersDatasetTest
29
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.data.datasets import ( DatasetView, SklearnDataset, SklearnDatasetView, TextDataset, TextDatasetView ) from small_text.data.exceptions import U...
len(result))
self.assertEqual
func_call
tests/unit/small_text/data/test_datatset_views.py
test_indexing_single_index
_DatasetViewTest
202
null
webis-de/small-text
import unittest import pytest import numpy as np from abc import abstractmethod from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.data.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.excep...
ds._data)
self.assertIsNotNone
complex_expr
tests/unit/small_text/integrations/pytorch/test_datasets.py
test_init
_PytorchTextClassificationDatasetTest
50
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class LossTest(unittest.TestCase): def test_loss_fct(self): loss_fct = _LossAdapter2DTo1D(BCEWithLogitsLoss(reduction='none')) input = torch.randn(5, 3) target = torch.empty(5, 3).ra...
len(loss.shape))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/utils/test_loss.py
test_loss_fct
LossTest
26
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNInitTest(unittest.TestCase): DEFAULT_KERNEL_HEIGHTS = [3, 4, 5] def test_init_parameters_default(self): vocab_size = 1000 max_seq_length = 50 model = KimCNN(vocab_s...
len(model.convs))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/models/test_kimcnn.py
test_init_parameters_default
KimCNNInitTest
48
null
webis-de/small-text
import numpy as np class VectorIndexesTest(object): def get_vector_index(self): """ Defines the vector index to be used for these test cases. """ raise NotImplementedError def _get_random_data(self, n=20, d=4): return np.random.rand(n, d).astype(np.float32) def te...
indices.ravel().shape[0])
self.assertEqual
func_call
tests/integration/small_text/vector_indexes/test_base.py
test_search
VectorIndexesTest
48
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class _AMPArgumentsTest(object): def _test_with_no_amp_args_configured(self, clf): amp_args = clf.amp_args self.assertIsNotNone(
amp_args)
self.assertIsNotNone
variable
tests/integration/small_text/integrations/pytorch/classifiers/test_base.py
_test_with_no_amp_args_configured
_AMPArgumentsTest
55
null
webis-de/small-text
import os import unittest import pytest import small_text import numpy as np from importlib import reload from unittest.mock import patch from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_MORE_VERBOSE...
call_args[6])
self.assertEqual
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_classification.py
test_fit_with_optimizer_and_scheduler
TestTransformerBasedClassification
470
null
webis-de/small-text
import unittest import pytest import numpy as np from abc import abstractmethod from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.data.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.excep...
ds_new.y)
assert_*
complex_expr
tests/unit/small_text/integrations/pytorch/test_datasets.py
test_set_labels
_PytorchTextClassificationDatasetTest
144
null
webis-de/small-text
import unittest import numpy as np from small_text.classifiers import ConfidenceEnhancedLinearSVC from small_text.data.datasets import SklearnDataset from small_text.query_strategies import ( EmptyPoolException, greedy_coreset, GreedyCoreset, lightweight_coreset, LightweightCoreset ) from tests.un...
(num_samples,))
self.assertEqual
collection
tests/unit/small_text/query_strategies/test_coresets.py
test_query
_GreedyCoresetFunctionTest
31
null
webis-de/small-text
import unittest import pytest import numpy as np from packaging.version import parse, Version from unittest.mock import patch from unittest import mock from unittest.mock import Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_...
False)
assert_*
bool_literal
tests/integration/small_text/integrations/pytorch/classifiers/test_kimcnn.py
test_fit_and_predict
_KimCNNClassifierTest
72
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNInitTest(unittest.TestCase): DEFAULT_KERNEL_HEIGHTS = [3, 4, 5] def test_init_parameters_default(self): vocab_size = 1000 max_seq_length = 50 model = KimCNN(vocab_s...
model.pool_sizes)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/pytorch/models/test_kimcnn.py
test_init_parameters_default
KimCNNInitTest
31
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_UNLABELED from small_text.data.datasets import is_multi_label from small_text.data.datasets import ( SklearnDataset, DatasetView, Te...
ds_new.y)
self.assertIsNotNone
complex_expr
tests/unit/small_text/data/test_datasets.py
test_set_features
_DatasetTest
122
null
webis-de/small-text
import unittest import pytest import numpy as np from packaging.version import parse, Version from unittest.mock import patch from unittest import mock from unittest.mock import Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_...
call_args[5])
self.assertEqual
complex_expr
tests/integration/small_text/integrations/pytorch/classifiers/test_kimcnn.py
test_fit_with_optimizer_and_scheduler
_KimCNNClassifierTest
325
null
webis-de/small-text
import os import unittest import pytest import small_text import numpy as np from importlib import reload from unittest.mock import patch from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_MORE_VERBOSE...
model_args.model)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_classification.py
test_transformer_model_arguments_init
TestTransformerModelArguments
54
null
webis-de/small-text
import unittest import pytest import warnings import numpy as np from packaging.version import parse, Version from unittest import mock from unittest.mock import patch, Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.trai...
clf.model)
self.assertIsNotNone
complex_expr
tests/integration/small_text/integrations/transformers/classifiers/test_classification.py
test_fit_with_class_weight
_TransformerBasedClassificationTest
71
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class PytorchTextClassificationDatasetTest(unittest.TestCase): def test_dataset_to_copy(self): ds = random_text_classification_dataset(10) self.assertTrue(ds.target_label...
hasattr(ds_new, 'TEST'))
self.assertFalse
func_call
tests/integration/small_text/integrations/pytorch/test_datasets.py
test_dataset_to_copy
PytorchTextClassificationDatasetTest
63
null
webis-de/small-text
import os import unittest import pytest import small_text from importlib import reload from packaging.version import parse, Version from unittest.mock import patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_QUIET, VERBOSITY_MORE_VERBOSE ...
device)
self.assertEqual
variable
tests/unit/small_text/integrations/transformers/classifiers/test_setfit.py
test_init_device
_SetFitClassification
290
null
webis-de/small-text
import unittest import pytest from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class KimCNNInitTest(unittest.TestCase): DEFAULT_KERNEL_HEIGHTS = [3, 4, 5] def test_init_parameters_default(self): vocab_size = 1000 max_seq_length = 50 model = KimCNN(vocab_s...
len(model.pools))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/models/test_kimcnn.py
test_init_parameters_default
KimCNNInitTest
44
null
webis-de/small-text
import unittest import pytest import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.misc import increase_dense_labels_safe from test...
result.x)
assert_*
complex_expr
tests/unit/small_text/integrations/transformers/test_datasets.py
test_indexing_list_index
_TransformersDatasetTest
249
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_IGNORED from small_text.utils.labels import ( concatenate, csr_to_list, get_ignored_labels_mask, get_num_labels, list_to_csr, remove_by_index ) ...
result.dtype)
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_labels.py
test_list_to_csr
LabelUtilsTest
132
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.utils.classification import empty_result, prediction_result from tests.utils.testing import assert_csr_matrix_equal class ClassificationUtilsTest(unittest.TestCase): def test_empt...
proba.dtype)
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_classification.py
test_empty_result_single_label_proba
ClassificationUtilsTest
132
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import patch, MagicMock from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class BuildLayerSpecificParamsTest(unittest.TestCase): def _assert_params(self, params, base_lr, num_different_lrs): self.assertIsNotNo...
params)
self.assertIsNotNone
variable
tests/unit/small_text/integrations/transformers/utils/test_classification.py
_assert_params
BuildLayerSpecificParamsTest
183
null
webis-de/small-text
import unittest from sklearn.datasets import fetch_20newsgroups from sklearn.feature_extraction.text import CountVectorizer from small_text.classifiers import ConfidenceEnhancedLinearSVC class ConfidenceEnhancedLinearSVCIntegrationTest(unittest.TestCase): def _get_20news_vectors(self, categories=None): ...
len(y_pred.shape))
self.assertEqual
func_call
tests/integration/classifiers/test_svm.py
test_predict_binary
ConfidenceEnhancedLinearSVCIntegrationTest
27
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.datasets import random_labeling, random_labels, _train_tokenizer class PytorchTextClassificationDatasetSingleLabelTest(unittest.TestCase): def test_from_arrays_with_lists...
len(dataset))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/test_dataset_construction.py
test_from_arrays_with_lists
PytorchTextClassificationDatasetSingleLabelTest
26
null
webis-de/small-text
import unittest import pytest import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.misc import increase_dense_labels_safe from test...
ds_new.y)
assert_*
complex_expr
tests/unit/small_text/integrations/transformers/test_datasets.py
test_set_labels
_TransformersDatasetTest
135
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import patch from scipy.sparse import csr_matrix from small_text.data import balanced_sampling, stratified_sampling from small_text.initialization import random_initialization, \ random_initialization_stratified, random_initialization_balanced from tests.util...
len(np.unique(indices)))
self.assertEqual
func_call
tests/unit/small_text/initialization/test_strategies.py
test_random_initialization
RandomInitializationTest
22
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_UNLABELED from small_text.data.datasets import is_multi_label from small_text.data.datasets import ( SklearnDataset, DatasetView, Te...
ds.y)
self.assertIsNotNone
complex_expr
tests/unit/small_text/data/test_datasets.py
test_get_features
_DatasetTest
112
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.data import balanced_sampling, stratified_sampling from small_text.data.sampling import _get_class_histogram from small_text.utils.labels import list_to_csr class StratifiedSamplingTest...
counts[0])
self.assertEqual
complex_expr
tests/unit/small_text/data/test_sampling.py
test_stratified_sampling
StratifiedSamplingTest
50
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import Mock, patch from numpy.testing import assert_array_equal from sklearn.preprocessing import normalize from small_text.classifiers import ConfidenceEnhancedLinearSVC from small_text.query_strategies import ( LeastConfidence, AnchorSubs...
y)
assert_*
variable
tests/integration/small_text/query_strategies/test_subsampling.py
test_query_when_unlabeled_pool_is_smaller_than_k
AnchorSubsamplingTest
135
null
webis-de/small-text
import unittest from packaging import version from unittest.mock import patch from small_text.utils.annotations import ( deprecated, experimental, DeprecationError, ExperimentalWarning ) class DeprecationUtilsTest(unittest.TestCase): def test_deprecate_function(self): from small_text.uti...
myfunc('foo'))
self.assertTrue
func_call
tests/unit/small_text/utils/test_annotations.py
test_deprecate_function
DeprecationUtilsTest
67
null
webis-de/small-text
import os import unittest import pytest import small_text from importlib import reload from packaging.version import parse, Version from unittest.mock import patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_QUIET, VERBOSITY_MORE_VERBOSE ...
args.max_steps)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_setfit.py
test_setfit_model_arguments_init_default
TestSetFitModelArguments
42
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class PytorchTextClassificationDatasetTest(unittest.TestCase): def test_dataset_to(self): ds = random_text_classification_dataset(10) tensor_is_on_cpu = [item[PytorchText...
np.all(tensor_is_on_cpu))
self.assertTrue
func_call
tests/integration/small_text/integrations/pytorch/test_datasets.py
test_dataset_to
PytorchTextClassificationDatasetTest
24
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.utils.classification import empty_result, prediction_result from tests.utils.testing import assert_csr_matrix_equal class ClassificationUtilsTest(unittest.TestCase): def test_empt...
proba.shape)
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_classification.py
test_empty_result_single_label_proba
ClassificationUtilsTest
133
null
webis-de/small-text
import unittest import pytest import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.misc import increase_dense_labels_safe from test...
ds_cloned.x)
assert_*
complex_expr
tests/unit/small_text/integrations/transformers/test_datasets.py
test_clone
_TransformersDatasetTest
196
null
webis-de/small-text
import pytest import unittest from unittest.mock import Mock, patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.training.model_selection import NoopModelSelection from tests.utils.datasets import random_text_classification_dataset class SimplePytorchClassifierTest(unit...
clf.multi_label)
self.assertFalse
complex_expr
tests/unit/small_text/integrations/pytorch/classifiers/test_base.py
test_default_init
SimplePytorchClassifierTest
126
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import create_autospec, patch from scipy.sparse import issparse, csr_matrix from small_text.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.datasets import t...
np.int64)
self.assertEqual
complex_expr
tests/integration/small_text/integrations/transformers/classifiers/test_setfit.py
test_fit_and_predict
_ClassificationTest
56
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.data.datasets import TextDataset from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class SetFitUtilsTest(unittest.TestCase): def test_truncate_texts(self): model_args = SetFitModelArguments('sentence-transformers/p...
len(result_datasets))
self.assertEqual
func_call
tests/integration/small_text/integrations/transformers/utils/test_setfit.py
test_truncate_texts
SetFitUtilsTest
40
null
webis-de/small-text
import unittest import numpy as np from copy import copy from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.base import LABEL_UNLABELED from small_text.data.datasets import is_multi_label from small_text.data.datasets import ( SklearnDataset, DatasetView, Te...
ds.x)
assert_*
complex_expr
tests/unit/small_text/data/test_datasets.py
test_get_features
_TextDatasetTest
483
null
webis-de/small-text
import unittest import numpy as np from small_text.stopping_criteria.uncertainty import OverallUncertainty class OverallUncertaintyTest(unittest.TestCase): def test_first_stop_call(self): stopping_criterion = OverallUncertainty(2) proba = np.array([ [0.5, 0.5] ]) sto...
stop)
self.assertFalse
variable
tests/unit/small_text/stopping_criteria/test_uncertainty.py
test_first_stop_call
OverallUncertaintyTest
39
null
webis-de/small-text
import unittest import pytest import numpy as np from abc import abstractmethod from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.data.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.excep...
len(ds.x))
self.assertEqual
func_call
tests/unit/small_text/integrations/pytorch/test_datasets.py
test_get_features
_PytorchTextClassificationDatasetTest
110
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.utils.classification import empty_result, prediction_result from tests.utils.testing import assert_csr_matrix_equal class ClassificationUtilsTest(unittest.TestCase): def test_pred...
result)
assert_*
variable
tests/unit/small_text/utils/test_classification.py
test_prediction_result
ClassificationUtilsTest
23
null
webis-de/small-text
import unittest import pytest import numpy as np from packaging.version import parse, Version from unittest.mock import patch from unittest import mock from unittest.mock import Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_...
loss >= 0)
self.assertTrue
complex_expr
tests/integration/small_text/integrations/pytorch/classifiers/test_kimcnn.py
test_fit_and_validate
_KimCNNClassifierTest
157
null
webis-de/small-text
import unittest import pytest import numpy as np from unittest.mock import create_autospec, patch from scipy.sparse import issparse, csr_matrix from small_text.exceptions import UnsupportedOperationException from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.datasets import t...
amp_args.use_amp)
self.assertFalse
complex_expr
tests/integration/small_text/integrations/transformers/classifiers/test_setfit.py
test_with_no_amp_args_configured
SetFitClassificationAMPArgumentsTest
269
null
webis-de/small-text
import pytest import unittest from unittest.mock import Mock, patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.training.model_selection import NoopModelSelection from tests.utils.datasets import random_text_classification_dataset class AMPArgumentsTest(unittest.TestCa...
amp_args.dtype)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/pytorch/classifiers/test_base.py
test_init_default
AMPArgumentsTest
41
null
webis-de/small-text
import unittest import warnings import numpy as np from small_text.classifiers import ConfidenceEnhancedLinearSVC from small_text.query_strategies.bayesian import BALD, _bald from tests.utils.datasets import random_sklearn_dataset from tests.utils.testing import assert_array_equal class BALDHelperTest(unittest.TestC...
result)
assert_*
variable
tests/unit/small_text/query_strategies/test_bayesian.py
test_bald_with_only_zeros
BALDHelperTest
17
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from scipy.sparse import csr_matrix from small_text.utils.classification import empty_result, prediction_result from tests.utils.testing import assert_csr_matrix_equal class ClassificationUtilsTest(unittest.TestCase): def test_empt...
prediction.shape)
self.assertEqual
complex_expr
tests/unit/small_text/utils/test_classification.py
test_empty_result_single_label_prediction
ClassificationUtilsTest
125
null
webis-de/small-text
import unittest import pytest import numpy as np from scipy.sparse import csr_matrix from numpy.testing import assert_array_equal from small_text.base import LABEL_UNLABELED from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from tests.utils.misc import increase_dense_labels_safe from test...
ds.y)
assert_*
complex_expr
tests/unit/small_text/integrations/transformers/test_datasets.py
test_get_labels
_TransformersDatasetTest
125
null
webis-de/small-text
import unittest import numpy as np from unittest.mock import patch from scipy.sparse import csr_matrix from small_text.data import balanced_sampling, stratified_sampling from small_text.initialization import random_initialization, \ random_initialization_stratified, random_initialization_balanced from tests.util...
len(indices))
self.assertEqual
func_call
tests/unit/small_text/initialization/test_strategies.py
test_random_initialization
RandomInitializationTest
21
null
webis-de/small-text
import unittest import tempfile import pytest import numpy as np from numpy.testing import assert_array_equal from small_text.active_learner import PoolBasedActiveLearner from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.query_strategies import RandomSampling from tests.ut...
len(weights_after))
self.assertEqual
func_call
tests/integration/small_text/integrations/pytorch/test_serialization.py
test_and_load_with_file_str
SerializationTest
55
null
webis-de/small-text
import os import unittest from unittest.mock import patch from small_text.utils.system import ( OFFLINE_MODE_VARIABLE, PROGRESS_BARS_VARIABLE, TMP_DIR_VARIABLE, get_offline_mode, get_show_progress_bar_default, get_tmp_dir_base ) class SystemUtilsTest(unittest.TestCase): def test_get_tmp_...
get_tmp_dir_base())
self.assertIsNone
func_call
tests/unit/small_text/utils/test_system.py
test_get_tmp_dir_base
SystemUtilsTest
41
null
webis-de/small-text
import unittest import numpy as np from numpy.testing import assert_array_equal from small_text.stopping_criteria.kappa import KappaAverage, _adapted_cohen_kappa_score class KappaAverageTest(unittest.TestCase): def test_first_stop_call(self): stopping_criterion = KappaAverage(2) predictions = n...
stop)
self.assertFalse
variable
tests/unit/small_text/stopping_criteria/test_kappa.py
test_first_stop_call
KappaAverageTest
103
null
webis-de/small-text
import unittest import numpy as np from unittest import mock from small_text import ( ConfidenceEnhancedLinearSVC, RandomSampling, SklearnClassifier, SklearnDataset ) from small_text.data.sampling import _get_class_histogram from small_text.query_strategies.class_balancing import ClassBalancer, _get_r...
str(strategy))
self.assertEqual
func_call
tests/unit/small_text/query_strategies/test_class_balancing.py
test_class_balancer_str
ClassBalancerTest
190
null
webis-de/small-text
import numpy as np class VectorIndexesTest(object): def get_vector_index(self): """ Defines the vector index to be used for these test cases. """ raise NotImplementedError def _get_random_data(self, n=20, d=4): return np.random.rand(n, d).astype(np.float32) def te...
indices.shape)
self.assertEqual
complex_expr
tests/integration/small_text/vector_indexes/test_base.py
test_search_with_ids
VectorIndexesTest
61
null
webis-de/small-text
import os import unittest import pytest import small_text from importlib import reload from packaging.version import parse, Version from unittest.mock import patch from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.utils.logging import VERBOSITY_QUIET, VERBOSITY_MORE_VERBOSE ...
clf.device)
self.assertIsNone
complex_expr
tests/unit/small_text/integrations/transformers/classifiers/test_setfit.py
test_init
_SetFitClassification
272
null
webis-de/small-text
import unittest import pytest import warnings import numpy as np from packaging.version import parse, Version from unittest import mock from unittest.mock import patch, Mock from scipy.sparse import issparse, csr_matrix from small_text.integrations.pytorch.exceptions import PytorchNotFoundError from small_text.trai...
issparse(y_pred))
self.assertTrue
func_call
tests/integration/small_text/integrations/transformers/classifiers/test_classification.py
test_fit_and_predict
_TransformerBasedClassificationTest
141
null
webis-de/small-text
import unittest import pytest import numpy as np from small_text.integrations.pytorch.exceptions import PytorchNotFoundError class ExpectedGradientLengthTest(unittest.TestCase): def test_init_default(self): strategy = ExpectedGradientLength(2) self.assertEqual(2, strategy.num_classes) s...
strategy.device)
self.assertEqual
complex_expr
tests/unit/small_text/integrations/pytorch/test_strategies.py
test_init_default
ExpectedGradientLengthTest
47
null
explosion/thinc
import numpy import pytest from thinc.api import ( SGD, ArgsKwargs, CupyOps, Linear, MPSOps, NumpyOps, PyTorchWrapper, PyTorchWrapper_v2, PyTorchWrapper_v3, Relu, chain, get_current_ops, torch2xp, use_ops, xp2torch, ) from thinc.backends import context_pools ...
(nN, nI)
assert
collection
thinc/tests/layers/test_pytorch_wrapper.py
test_pytorch_wrapper
95
null
explosion/thinc
import numpy import pytest from numpy.testing import assert_allclose from thinc.types import Pairs, Ragged def ragged(): data = numpy.zeros((20, 4), dtype="f") lengths = numpy.array([4, 2, 8, 1, 4], dtype="i") data[0] = 0 data[1] = 1 data[2] = 2 data[3] = 3 data[4] = 4 data[5] = 5 ...
(1, 45)
assert
collection
thinc/tests/test_indexing.py
test_pairs_arrays
65
null
explosion/thinc
import math import numpy import pytest from thinc.api import SGD, SparseLinear, SparseLinear_v2, to_categorical def instances(): lengths = numpy.asarray([5, 4], dtype="int32") keys = numpy.arange(9, dtype="uint64") values = numpy.ones(9, dtype="float32") X = (keys, values, lengths) y = numpy.asar...
(2, 3)
assert
collection
thinc/tests/layers/test_sparse_linear.py
test_init
45
null
explosion/thinc
import numpy import pytest from thinc.api import reduce_first, reduce_last, reduce_max, reduce_mean, reduce_sum from thinc.types import Ragged def Xs(): seqs = [numpy.zeros((10, 8), dtype="f"), numpy.zeros((4, 8), dtype="f")] for x in seqs: x[0] = 1 x[1] = 2 # so max != first x[-1] = ...
list(Xs[0][1])
assert
func_call
thinc/tests/layers/test_reduce.py
test_reduce_max
74
null
explosion/thinc
import numpy import pytest from thinc.api import NumpyOps, Ragged, registry, strings2arrays from ..util import get_data_checker def shapes(request): return request.param def ops(): return NumpyOps() def list_data(shapes): return [numpy.zeros(shape, dtype="f") for shape in shapes] def ragged_data(ops, ...
len(strings)
assert
func_call
thinc/tests/layers/test_transforms.py
test_strings2arrays
78
null
explosion/thinc
import platform import threading import time from collections import Counter import numpy import pytest from thinc.api import ( Adam, CupyOps, Dropout, Linear, Model, Relu, Shim, Softmax, chain, change_attr_values, concatenate, set_dropout_rate, use_ops, with_de...
4
assert
numeric_literal
thinc/tests/model/test_model.py
test_maybe_methods
192
null
explosion/thinc
import pytest import srsly from thinc.api import ( Linear, Maxout, Model, Shim, chain, deserialize_attr, serialize_attr, with_array, ) def linear(): return Linear(5, 3) def test_simple_model_roundtrip_bytes_serializable_attrs(): fwd = lambda model, X, is_train: (X, lambda dY: ...
"foo"
assert
string_literal
thinc/tests/test_serialize.py
test_simple_model_roundtrip_bytes_serializable_attrs
82
null