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 |
|---|---|---|---|---|---|---|---|---|---|
descriptinc/audiotools | import numpy as np
import pytest
import torch
from audiotools import AudioSignal
from audiotools.core.util import sample_from_dist
def test_corrupt_phase():
sample_rate = 44100
f = 440
t = torch.linspace(0, 1, sample_rate)
sine_wave = torch.sin(2 * np.pi * f * t)
sine_wave = AudioSignal(sine_wave,... | 0.0 | assert | numeric_literal | tests/core/test_dsp.py | test_corrupt_phase | 172 | null | |
descriptinc/audiotools | 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,... | old_stoi | assert | variable | tests/metrics/test_quality.py | test_stoi | 32 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_find_audio():
wav_files = util.find_audio("tests/", ["wav"])
for a in wav_files:
assert "wav" in str(a)
audio_files = ut... | len(wav_files) | assert | func_call | tests/core/test_util.py | test_find_audio | 71 | null | |
descriptinc/audiotools | import tempfile
from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools.data import transforms as tfm
def test_loader_out_of_range():
with tempfile.TemporaryDirectory() as d:
dataset_dir = Path(d)
num_items = 100
audiotools.util.generate_ch... | "none" | assert | string_literal | tests/data/test_datasets.py | test_loader_out_of_range | 168 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_io():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
signal = AudioSignal(pathlib.Path(audio_path))
with tempfile.NamedTemporaryF... | 5.0 | assert | numeric_literal | tests/core/test_audio_signal.py | test_io | 32 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_collate():
batch_size = 16
def _one_item():
return {
"signal": AudioSignal(torch.randn(1, 1, 44100), 44100),
... | batch_size | assert | variable | tests/core/test_util.py | test_collate | 119 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_hz_to_bin():
hz = torch.from_numpy(np.array([100, 200, 300]))
sr = 1000
n_fft = 2048
bins = util.hz_to_bin(hz, n_fft, sr)
... | 1 | assert | numeric_literal | tests/core/test_util.py | test_hz_to_bin | 55 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_zero_pad_to():
array = np.random.randn(4, 2, 16000)
sig1 = AudioSignal(array, sample_rate=16000)
sig1.zero_pad_to(16100)
zeros = torch... | 16000 | assert | numeric_literal | tests/core/test_audio_signal.py | test_zero_pad_to | 337 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_whisper_features():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
signal = AudioSignal(audio_path, offset=10, duration=10)
... | (1, 80, 3000) | assert | collection | tests/core/test_whisper.py | test_whisper_features | 20 | null | |
descriptinc/audiotools | import shlex
import subprocess
import tempfile
from pathlib import Path
import numpy as np
import pyloudnorm
import pytest
import torch
from audiotools import AudioSignal
def test_ffmpeg_audio_offset():
with tempfile.TemporaryDirectory() as d:
video_path = Path(d) / "test.mp4"
audio_path = Path(d... | 50 | assert | numeric_literal | tests/core/test_ffmpeg.py | test_ffmpeg_audio_offset | 128 | null | |
descriptinc/audiotools | from typing import Callable
import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
def test_batch_grad():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
signal = AudioSignal(audio_path)
signal.audio_data.requires_grad = True
assert signal.audio_... | None | assert | none_literal | tests/core/test_grad.py | test_batch_grad | 99 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | output | assert | variable | tests/data/test_transforms.py | test_transform | 76 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_seed():
util.seed(0)
torch_result_a = torch.randn(1)
np_result_a = np.random.randn(1)
py_result_a = random.random()
util... | torch_result_b | assert | variable | tests/core/test_util.py | test_seed | 43 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_collate():
batch_size = 16
def _one_item():
return {
"signal": AudioSignal(torch.randn(1, 1, 44100), 44100),
... | t | assert | variable | tests/core/test_util.py | test_collate | 147 | null | |
descriptinc/audiotools | import tempfile
from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools.data import transforms as tfm
def test_align_lists():
input_lists = [
["a/1.wav", "b/1.wav", "c/1.wav", "d/1.wav"],
["a/2.wav", "c/2.wav"],
["c/3.wav"],
]
targe... | aligned_lists | assert | variable | tests/data/test_datasets.py | test_align_lists | 36 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_zeros():
x = AudioSignal.zeros(0.5, 44100)
assert x.signal_duration == | 0.5 | assert | numeric_literal | tests/core/test_audio_signal.py | test_zeros | 292 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | targets[1] | assert | complex_expr | tests/data/test_transforms.py | test_choose_weighted | 269 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_zero_pad_to():
array = np.random.randn(4, 2, 16000)
sig1 = AudioSignal(array, sample_rate=16000)
sig1.zero_pad_to(16100)
zeros = torch... | 16100 | assert | numeric_literal | tests/core/test_audio_signal.py | test_zero_pad_to | 333 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | 0.5**3 | assert | complex_expr | tests/data/test_transforms.py | test_repeat | 330 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | targets | assert | variable | tests/data/test_transforms.py | test_choose_basic | 242 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_check_random_state():
# seed is None
rng_type = type(np.random.RandomState(10))
rng = util.random_state(None)
assert type(rn... | rng_type | assert | variable | tests/core/test_util.py | test_check_random_state | 17 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
@pytest.mark.parametrize("quant_ch", [2, 4, 8, 16, 32, 64, 128])
def test_quantization(quant_ch):
audio_path = "tests/audio/spk/f10_script4_produced.wav"
spk = AudioSignal(audio_path, offset=10, duration=2)
... | quant_ch | assert | variable | tests/core/test_effects.py | test_quantization | 262 | null | |
descriptinc/audiotools | import tempfile
from pathlib import Path
from audiotools.core.util import find_audio
from audiotools.core.util import read_sources
from audiotools.data import preprocess
def test_create_csv_with_empty_rows():
audio_files = find_audio("./tests/audio/spk", ext=["wav"])
audio_files.insert(0, "")
audio_files.... | 1 | assert | numeric_literal | tests/data/test_preprocess.py | test_create_csv_with_empty_rows | 25 | null | |
descriptinc/audiotools | 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,... | 3.0 | assert | numeric_literal | tests/metrics/test_quality.py | test_pesq | 45 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_truncate():
array = np.random.randn(4, 2, 16000)
sig1 = AudioSignal(array, sample_rate=16000)
sig1.truncate_samples(100)
assert sig1.... | 100 | assert | numeric_literal | tests/core/test_audio_signal.py | test_truncate | 355 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
def test_impulse_response_augmentation():
audio_path = "tests/audio/ir/h179_Bar_1txts.wav"
batch_size = 16
ir = AudioSignal(audio_path)
ir_batch = AudioSignal.batch([ir for _ in range(batch_size)])
e... | late_field.shape | assert | complex_expr | tests/core/test_effects.py | test_impulse_response_augmentation | 313 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_io():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
signal = AudioSignal(pathlib.Path(audio_path))
with tempfile.NamedTemporaryF... | 3 | assert | numeric_literal | tests/core/test_audio_signal.py | test_io | 61 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_to_mono():
array = np.random.randn(4, 2, 16000)
sr = 16000
signal = AudioSignal(array, sample_rate=sr)
assert signal.num_channels == 2... | 1 | assert | numeric_literal | tests/core/test_audio_signal.py | test_to_mono | 512 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | 2 | assert | numeric_literal | tests/data/test_transforms.py | test_compose_basic | 107 | null | |
descriptinc/audiotools | from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools import AudioSignal
from audiotools import util
from audiotools.data import transforms as tfm
from audiotools.data.datasets import AudioDataset
non_deterministic_transforms = ["TimeNoise", "FrequencyNoise"]
transf... | transform.keys | assert | complex_expr | tests/data/test_transforms.py | test_transform | 55 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_to_mono():
array = np.random.randn(4, 2, 16000)
sr = 16000
signal = AudioSignal(array, sample_rate=sr)
assert signal.num_channels == | 2 | assert | numeric_literal | tests/core/test_audio_signal.py | test_to_mono | 509 | null | |
descriptinc/audiotools | 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 | assert | variable | tests/metrics/test_quality.py | test_pesq | 56 | null | |
descriptinc/audiotools | import tempfile
from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools.data import transforms as tfm
def test_concat_dataset():
d1 = NumberDataset()
d2 = NumberDataset()
d3 = NumberDataset()
d = audiotools.datasets.ConcatDataset([d1, d2, d3])
x =... | t | assert | variable | tests/data/test_datasets.py | test_concat_dataset | 218 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_sample_dist():
state = util.random_state(0)
v1 = state.uniform(0.0, 1.0)
v2 = util.sample_from_dist(("uniform", 0.0, 1.0), 0)
... | [8, 16, 32] | assert | collection | tests/core/test_util.py | test_sample_dist | 100 | null | |
descriptinc/audiotools | 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") | assert | func_call | tests/ml/test_model.py | test_base_model | 43 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_seed():
util.seed(0)
torch_result_a = torch.randn(1)
np_result_a = np.random.randn(1)
py_result_a = random.random()
util... | np_result_b | assert | variable | tests/core/test_util.py | test_seed | 44 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
def test_ensure_max_of_audio():
spk = AudioSignal(torch.randn(1, 1, 44100), 44100)
max_vals = [1.0] + [np.random.rand() for _ in range(10)]
for val in max_vals:
after = spk.deepcopy().ensure_max_of_... | val + 1e-3 | assert | complex_expr | tests/core/test_effects.py | test_ensure_max_of_audio | 352 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
from audiotools import AudioSignal
from audiotools.core.util import sample_from_dist
def test_corrupt_phase():
sample_rate = 44100
f = 440
t = torch.linspace(0, 1, sample_rate)
sine_wave = torch.sin(2 * np.pi * f * t)
sine_wave = AudioSignal(sine_wave,... | 1.0 | assert | numeric_literal | tests/core/test_dsp.py | test_corrupt_phase | 173 | null | |
descriptinc/audiotools | import numpy as np
import pytest
from numpy.core.fromnumeric import clip
from audiotools import AudioSignal
from audiotools import metrics
@pytest.mark.parametrize("scaling", [False, True])
@pytest.mark.parametrize("reduction", ["mean", "sum"])
@pytest.mark.parametrize("clip_min", [None, -30])
@pytest.mark.parametriz... | loss_val_identity | assert | variable | tests/metrics/test_distance.py | test_sisdr | 35 | null | |
descriptinc/audiotools | import pathlib
import tempfile
import librosa
import numpy as np
import pytest
import rich
import torch
import audiotools
from audiotools import AudioSignal
def test_equality():
array = np.random.randn(2, 16000)
sig1 = AudioSignal(array, sample_rate=16000)
sig2 = AudioSignal(array, sample_rate=16000)
... | sig2 | assert | variable | tests/core/test_audio_signal.py | test_equality | 209 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
from audiotools import AudioSignal
from audiotools.core.util import sample_from_dist
def test_low_pass():
sample_rate = 44100
f = 440
t = torch.arange(0, 1, 1 / sample_rate)
sine_wave = torch.sin(2 * np.pi * f * t)
window = AudioSignal.get_window("hann... | 1e-3 | assert | numeric_literal | tests/core/test_dsp.py | test_low_pass | 88 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
@pytest.mark.parametrize("quant_ch", [2, 4, 8, 16, 32, 64, 128])
def test_quantization(quant_ch):
audio_path = "tests/audio/spk/f10_script4_produced.wav"
spk = AudioSignal(audio_path, offset=10, duration=2)
... | q_ch | assert | variable | tests/core/test_effects.py | test_quantization | 276 | null | |
descriptinc/audiotools | import numpy as np
import pytest
import torch
import torchaudio
from audiotools import AudioSignal
def test_clip_distortion():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
spk = AudioSignal(audio_path, offset=10, duration=2)
clipped = spk.deepcopy().clip_distortion(0.05)
spk_batch = AudioS... | 1.0 | assert | numeric_literal | tests/core/test_effects.py | test_clip_distortion | 248 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_whisper_embeddings():
audio_path = "tests/audio/spk/f10_script4_produced.wav"
signal = AudioSignal(audio_path, offset=10, duration=10... | (1, 1500, 512) | assert | collection | tests/core/test_whisper.py | test_whisper_embeddings | 38 | null | |
descriptinc/audiotools | 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 | assert | variable | tests/metrics/test_spectral.py | test_multiscale_stft | 21 | null | |
descriptinc/audiotools | import os
import random
import tempfile
import numpy as np
import pytest
import torch
from audiotools import util
from audiotools.core.audio_signal import AudioSignal
def test_find_audio():
wav_files = util.find_audio("tests/", ["wav"])
for a in wav_files:
assert "wav" in | str(a) | assert | func_call | tests/core/test_util.py | test_find_audio | 61 | null | |
descriptinc/audiotools | import tempfile
from pathlib import Path
import numpy as np
import pytest
import torch
import audiotools
from audiotools.data import transforms as tfm
def test_loader_without_replacement():
with tempfile.TemporaryDirectory() as d:
dataset_dir = Path(d)
num_items = 100
audiotools.util.gene... | idx | assert | variable | tests/data/test_datasets.py | test_loader_without_replacement | 127 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import validations
from .. import resources
@pytest.mark.parametrize(
"word, syllable_threshold, lang, expected",
[
(resources.EMPTY_STR, 0, "en", False),
(resources.EMPTY_STR, 1, "en", False),
(resources.EASY_TEXT,... | expected | assert | variable | tests/backend/validations/test_is_difficult_word.py | test_is_difficult_word | 31 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 4.222),
(resources.SHORT_TEXT, 4.8),
(resources.PUNCT_TEXT, 4.283),
... | expected | assert | variable | tests/backend/metrics/test_letters_per_word.py | test_letters_per_word | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat import textstat
from ..backend import resources
@pytest.mark.parametrize(
"text, float_output, expected",
[
(resources.EMPTY_STR, True, 1.0),
(resources.EMPTY_STR, False, "0th and 1st grade"),
(resources.EASY_TEXT, True, 4.... | expected | assert | variable | tests/textstat/test_text_standard.py | test_text_standard | 25 | null | |
textstat/textstat | from __future__ import annotations
from textstat import textstat
import pytest
@pytest.mark.parametrize(
"num,points,expected",
[
(1.234, 0, 1),
(1.234, 1, 1.2),
(1.234, 2, 1.23),
(1.234, 3, 1.234),
(1.234, 4, 1.234),
(3.512589, 4, 3.5126),
(3.512589, 5,... | num | assert | variable | tests/textstat/test_legacy_round.py | test_legacy_round | 23 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import utils
@pytest.mark.parametrize(
"lang, n_words",
[
("en", 2941),
("es", 20000),
("de", 2941),
("fr", 2941),
],
)
def test_get_lang_easy_words(lang: str, n_words: int) -> None:
if lang not in [... | n_words | assert | variable | tests/backend/utils/test_get_lang_easy_words.py | test_get_lang_easy_words | 21 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 78.798),
(resources.SHORT_TEXT, 99.0),
(resources.PUNCT_TEXT, 70.698),... | expected | assert | variable | tests/backend/metrics/test_gulpease_index.py | test_gulpease_index | 21 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"text,ignore_spaces,expected",
[
("", True, 0),
("", False, 0),
("a", True, 1),
("a ", True, 1),
("a ", False, 2),
("a b", Tru... | expected | assert | variable | tests/backend/counts/test_count_chars.py | test_count_chars | 27 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"test,lang,expected",
[
(resources.EASY_TEXT, "en_US", 6),
(resources.SHORT_TEXT, "en_US", 1),
(resources.PUNCT_TEXT, "en_US", 4),
(resources.... | expected | assert | variable | tests/backend/counts/test_count_polysyllable_words.py | test_count_polysyllable_words | 18 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import transformations
from .. import resources
@pytest.mark.parametrize(
"in_text,out_text,rm_apostrophe",
[
("They're here", "Theyre here", True),
("They're here", "They're here", False),
("They're here, and they'... | out_text | assert | variable | tests/backend/transformations/test_remove_punctuation.py | test_remove_punctuation | 27 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 22.131),
(resources.SHORT_TEXT, 25.0),
(resources.PUNCT_TEXT, 23.808),... | expected | assert | variable | tests/backend/metrics/test_lix.py | test_lix | 20 | null | |
textstat/textstat | from __future__ import annotations
from typing import Callable
import pytest
from textstat.backend import utils, counts, metrics
from .. import resources
@pytest.mark.parametrize(
"inner_func, outer_funcs",
[
(
counts.count_words,
[metrics.sentences_per_word, metrics.words_per_... | 1 | assert | numeric_literal | tests/backend/utils/test_get_typed_cache.py | test_typed_chache | 35 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, variant, expected",
[
(resources.EMPTY_STR, "en_US", 1, 0.0),
(resources.EMPTY_STR, "en_US", 2, 0.0),
(resources.EMPTY_STR, "en_US", 2,... | expected | assert | variable | tests/backend/metrics/test_wiener_sachtextformel.py | test_wiener_sachtextformel | 29 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 7.348),
(resources.SHORT_TEXT, "en_US", 8.842),
... | expected | assert | variable | tests/backend/metrics/test_smog_index.py | test_smog_index | 23 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"text,expected",
[
(resources.EMPTY_STR, 0),
(resources.EASY_TEXT, 11),
(resources.SHORT_TEXT, 1),
(resources.PUNCT_TEXT, 5),
(resourc... | expected | assert | variable | tests/backend/counts/test_count_sentences.py | test_count_sentences | 22 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 9.0),
(resources.SHORT_TEXT, 5.0),
(resources.PUNCT_TEXT, 10.6),
... | expected | assert | variable | tests/backend/metrics/test_words_per_sentence.py | test_words_per_sentence | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 0.111),
(resources.SHORT_TEXT, 0.2),
(resources.PUNCT_TEXT, 0.094),
... | expected | assert | variable | tests/backend/metrics/test_sentences_per_word.py | test_sentences_per_word | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from .. import resources
from textstat.backend import selections
@pytest.mark.parametrize(
"text, syllable_threshold, lang, expected",
[
(
"The quick brown fox jumps over the lazy dog",
2,
"en_US",
[],
... | expected | assert | variable | tests/backend/selections/test_list_difficult_words.py | test_list_difficult_words | 96 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"text,lang,syllable_threshold,unique,expected",
[
(resources.EASY_TEXT, "en_US", 1, True, 11),
(resources.EASY_TEXT, "en_US", 1, False, 22),
(resource... | expected | assert | variable | tests/backend/counts/test_count_difficult_words.py | test_count_difficult_words | 24 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 4.0),
(resources.SHORT_TEXT, "en_US", 2.0),
(r... | expected | assert | variable | tests/backend/metrics/test_text_standard.py | test_text_standard | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"test,lang,expected",
[
(resources.EASY_TEXT, "en_US", 65),
(resources.SHORT_TEXT, "en_US", 4),
(resources.PUNCT_TEXT, "en_US", 41),
(resource... | expected | assert | variable | tests/backend/counts/test_count_monosyllable_words.py | test_count_monosyllable_words | 18 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, strict_lower, strict_upper, expected",
[
(resources.EMPTY_STR, "en_US", False, False, 0.0),
(resources.EASY_TEXT, "en_US", False, False, 4.045)... | expected | assert | variable | tests/backend/metrics/test_linsear_write_formula.py | test_linsear_write_formula | 26 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import utils
@pytest.mark.parametrize(
"lang, root",
[
("en_US", "en"),
("en", "en"),
("en_GB", "en"),
("de_DE", "de"),
("es_ES", "es"),
("fr_FR", "fr"),
],
)
def test_get_lang_root(lang:... | root | assert | variable | tests/backend/utils/test_get_lang_root.py | test_get_lang_root | 19 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, ms_per_char, expected",
[
(resources.EMPTY_STR, 0.0, 0.0),
(resources.EMPTY_STR, 1.0, 0.0),
(resources.EMPTY_STR, 5.3, 0.0),
(resourc... | expected | assert | variable | tests/backend/metrics/test_reading_time.py | test_reading_time | 25 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 1.195),
(resources.SHORT_TEXT, "en_US", -0.647),
... | expected | assert | variable | tests/backend/metrics/test_crawford.py | test_crawford | 21 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_faseeh(text: str, expected: int) -> None:
assert counts.count_faseeh(text) == | expected | assert | variable | tests/backend/counts/test_count_faseeh.py | test_count_faseeh | 14 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 78.918),
(resources.SHORT_TEXT, "en_US", 83.32),
... | expected | assert | variable | tests/backend/metrics/test_flesch_reading_ease.py | test_flesch_reading_ease | 33 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_arabic_long_words(text: str, expected: int) -> None:
assert counts.count_arabic_long_words(text) == | expected | assert | variable | tests/backend/counts/test_count_arabic_long_words.py | test_count_arabic_long_words | 14 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import utils
@pytest.mark.parametrize(
"lang, key, value",
[
(lang, key, utils.constants.LANG_CONFIGS[lang][key])
for lang in utils.constants.LANG_CONFIGS
for key in utils.constants.LANG_CONFIGS[lang]
]
+ [
... | value | assert | variable | tests/backend/utils/test_get_lang_cfg.py | test_get_lang_cfg | 19 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import utils
def test_get_lang_cfg_default_fallback_bug():
# 1. If there's a config value of that key, return that
assert (
utils.get_lang_cfg("en", "syllable_threshold")
== utils.constants.LANG_CONFIGS["en"]["syllable_thre... | ValueError) | pytest.raises | variable | tests/backend/utils/test_get_lang_cfg.py | test_get_lang_cfg_default_fallback_bug | 55 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import utils
@pytest.mark.parametrize(
"grade, expected",
[
(1, "st"),
(2, "nd"),
(3, "rd"),
(4, "th"),
(5, "th"),
(6, "th"),
(7, "th"),
(8, "th"),
(9, "th"),
... | expected | assert | variable | tests/backend/utils/test_get_grade_suffix.py | test_get_grade_suffix | 35 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat import textstat
from ..backend import resources
@pytest.mark.parametrize(
"lang,expected",
[
("en_US", 139),
("en_GB", 139),
("en", 139),
("de_DE", 145),
("de", 145),
("es_ES", 172),
("fr_FR"... | expected | assert | variable | tests/textstat/test_set_lang.py | test_set_lang | 25 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 3.585),
(resources.SHORT_TEXT, "en_US", 3.264),
... | expected | assert | variable | tests/backend/metrics/test_spache_readability.py | test_spache_readability | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
@pytest.mark.parametrize(
"text,expected",
[
# TODO
],
)
def test_count_arabic_syllables(text: str, expected: int) -> None:
assert counts.count_arabic_syllables(text) == | expected | assert | variable | tests/backend/counts/test_count_arabic_syllables.py | test_count_arabic_syllables | 14 | null | |
textstat/textstat | from __future__ import annotations
from textstat import textstat
import pytest
@pytest.mark.parametrize(
"num,points,expected",
[
(1.234, 0, 1),
(1.234, 1, 1.2),
(1.234, 2, 1.23),
(1.234, 3, 1.234),
(1.234, 4, 1.234),
(3.512589, 4, 3.5126),
(3.512589, 5,... | expected | assert | variable | tests/textstat/test_legacy_round.py | test_legacy_round | 28 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from .. import resources
from textstat.backend import selections
@pytest.mark.parametrize(
"text, rm_punctuation, rm_apostrophe, lowercase, split_contractions,"
" split_hyphens, expected",
[
(resources.EMPTY_STR, False, False, False, False, False, [... | expected | assert | variable | tests/backend/selections/test_list_words.py | test_list_words | 446 | null | |
textstat/textstat | from __future__ import annotations
from typing import Callable
import pytest
from textstat.backend import utils, counts, metrics
from .. import resources
@pytest.mark.parametrize(
"inner_func, outer_funcs",
[
(
counts.count_words,
[metrics.sentences_per_word, metrics.words_per_... | len(outer_funcs) | assert | func_call | tests/backend/utils/test_get_typed_cache.py | test_typed_chache | 41 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"test, threshold, expected",
[
(resources.EASY_TEXT, 6, 13),
(resources.SHORT_TEXT, 6, 1),
(resources.SHORT_TEXT, 5, 1),
(resources.SHORT_TEXT... | expected | assert | variable | tests/backend/counts/test_count_long_words.py | test_count_long_words | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 1.404),
(resources.SHORT_TEXT, "en_US", 1.4),
... | expected | assert | variable | tests/backend/metrics/test_syllables_per_word.py | test_syllables_per_word | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, lang, expected",
[
(resources.EMPTY_STR, "en_US", 0.0),
(resources.EASY_TEXT, "en_US", 6.794),
(resources.SHORT_TEXT, "en_US", 7.043),
... | expected | assert | variable | tests/backend/metrics/test_dale_chall_readability_score_v2.py | test_dale_chall_readability_score_v2 | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
def test_count_syllables_with_unknown_word():
"""Test that count_syllables still produces an output when counting
an unknown word.
"""
assert counts.count_syllables("text_a", "en_US") == | 2 | assert | numeric_literal | tests/backend/counts/test_count_syllables.py | test_count_syllables_with_unknown_word | 55 | null | |
textstat/textstat | from __future__ import annotations
from typing import Callable
import pytest
from textstat.backend import utils, counts, metrics
from .. import resources
@pytest.mark.parametrize(
"inner_func, outer_funcs",
[
(
counts.count_words,
[metrics.sentences_per_word, metrics.words_per_... | len(outer_funcs) - 1 | assert | func_call | tests/backend/utils/test_get_typed_cache.py | test_typed_chache | 36 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"text,expected",
[
("", 0),
("a", 1),
("a ", 1),
("a b", 2),
("They're here, and they're there.", 24),
(
"""Who's ... | expected | assert | variable | tests/backend/counts/test_count_letters.py | test_letter_count | 26 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import counts
from .. import resources
@pytest.mark.parametrize(
"text, rm_punctuation, split_contractions, split_hyphens, n_words",
[
("", True, False, False, 0),
("a", True, False, False, 1),
("a ", True, False, F... | n_words | assert | variable | tests/backend/counts/test_count_words.py | test_count_words | 91 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 5.4),
(resources.SHORT_TEXT, 6.12),
(resources.PUNCT_TEXT, 6.249),
... | expected | assert | variable | tests/backend/metrics/test_coleman_liau_index.py | test_coleman_liau_index | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 4.354),
(resources.SHORT_TEXT, 5.0),
(resources.PUNCT_TEXT, 4.66),
... | expected | assert | variable | tests/backend/metrics/test_chars_per_word.py | test_chars_per_word | 20 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from .. import resources
from textstat.backend import selections
@pytest.mark.parametrize(
"text, syllable_threshold, lang, expected",
[
(
"The quick brown fox jumps over the lazy dog",
2,
"en_US",
set(),
... | expected | assert | variable | tests/backend/selections/test_set_difficult_words.py | test_set_difficult_words | 85 | null | |
textstat/textstat | from __future__ import annotations
from textstat import textstat
import pytest
from ..backend import resources
@pytest.mark.parametrize(
"rm_apostrophe,expected",
[
(True, resources.PUNCT_TEXT_RESULT_WO_APOSTR),
(False, resources.PUNCT_TEXT_RESULT_W_APOSTR),
],
)
def test_set_rm_apostrophe... | expected | assert | variable | tests/textstat/test_set_rm_apostrophe.py | test_set_rm_apostrophe | 18 | null | |
textstat/textstat | from __future__ import annotations
import pytest
from textstat.backend import metrics
from .. import resources
@pytest.mark.parametrize(
"text, expected",
[
(resources.EMPTY_STR, 0.0),
(resources.EASY_TEXT, 1.182),
(resources.SHORT_TEXT, 1.0),
(resources.PUNCT_TEXT, 1.4),
... | expected | assert | variable | tests/backend/metrics/test_rix.py | test_rix | 20 | null | |
manjurulhoque/django-job-portal | from django.test import TestCase
from jobsapp.api.serializers import JobSerializer, NewJobSerializer
from django.utils import timezone
from datetime import timedelta
from jobsapp.models import Job
from accounts.models import User
from tags.models import Tag
from django.forms.models import model_to_dict
class TestJobSe... | 100000) | self.assertEqual | numeric_literal | tests/jobsapp/test_serializers.py | test_job_serializer | TestJobSerializer | 39 | null |
manjurulhoque/django-job-portal | from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase, APIClient
from django.contrib.auth import get_user_model
User = get_user_model()
class EditEmployeeProfileAPITestCase(APITestCase):
def setUp(self):
self.user = User.objects.create_user(email="te... | self.valid_data["last_name"]) | self.assertEqual | complex_expr | tests/accounts/test_api_views.py | test_update_profile | EditEmployeeProfileAPITestCase | 88 | null |
manjurulhoque/django-job-portal | from django.test import TestCase
from jobsapp.api.serializers import JobSerializer, NewJobSerializer
from django.utils import timezone
from datetime import timedelta
from jobsapp.models import Job
from accounts.models import User
from tags.models import Tag
from django.forms.models import model_to_dict
class TestNewJo... | serializer.is_valid()) | self.assertTrue | func_call | tests/jobsapp/test_serializers.py | test_new_job_serializer | TestNewJobSerializer | 81 | null |
manjurulhoque/django-job-portal | from django.test import TestCase
from django.urls import reverse
from jobsapp.models import Job
class TestHomeView(TestCase):
def test_template_used(self):
response = self.client.get(reverse("jobs:home"))
self.assertEqual(response.status_code, | 200) | self.assertEqual | numeric_literal | tests/jobsapp/test_views.py | test_template_used | TestHomeView | 14 | null |
manjurulhoque/django-job-portal | from django.test import TestCase
from accounts.api.serializers import UserSerializer, UserCreateSerializer, SocialSerializer
from accounts.models import User
class TestUserSerializer(TestCase):
def setUp(self):
self.user_data = {"email": "test@example.com", "password": "testpass123", "role": "employee"}
... | "employer") | self.assertEqual | string_literal | tests/accounts/test_serializers.py | test_user_serializer_with_partial_update | TestUserSerializer | 25 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.