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 |
|---|---|---|---|---|---|---|---|---|---|
pdm-project/pdm | import pytest
from pdm.models.specifiers import PySpecSet
@pytest.mark.parametrize(
"left,right,result",
[
(">=3.6", ">=3.0", ">=3.6"),
(">=3.6", "<3.8", "<3.8,>=3.6"),
("", ">=3.6", ">=3.6"),
(">=3.6", "<3.2", "<empty>"),
(">=2.7,!=3.0.*", "!=3.1.*", "!=3.0.*,!=3.1.*,>... | PySpecSet(result) | assert | func_call | tests/models/test_specifiers.py | test_pyspec_and_op | 47 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, ProjectE... | 3 | assert | numeric_literal | tests/test_project.py | test_load_extra_sources | 304 | null | |
pdm-project/pdm | import pytest
from pdm.cli import actions
from pdm.models.markers import EnvSpec
from pdm.pytest import Distribution
from pdm.utils import cd
def test_sync_only_different(project, working_set, pdm):
working_set.add_distribution(Distribution("foo", "0.1.0"))
working_set.add_distribution(Distribution("chardet",... | out | assert | variable | tests/cli/test_install.py | test_sync_only_different | 69 | null | |
pdm-project/pdm | import os
import shutil
import sys
from pathlib import Path
import pytest
from pdm.cli.commands.use import Command as UseCommand
from pdm.exceptions import NoPythonVersion
from pdm.models.caches import JSONFileCache
def test_use_venv_python(project, pdm):
pdm(["venv", "create"], obj=project, strict=True)
pdm... | Path(venv_location) | assert | func_call | tests/cli/test_use.py | test_use_venv_python | 83 | null | |
pdm-project/pdm | import shlex
import sys
from collections import namedtuple
from textwrap import dedent
import pytest
from pdm.cli import actions
from pdm.cli.options import from_splitted_env
from pdm.signals import pdm_signals
pytestmark = pytest.mark.usefixtures("repository", "working_set", "local_finder")
def test_pre_script_fai... | 1 | assert | numeric_literal | tests/cli/test_hooks.py | test_pre_script_fail_fast | 23 | null | |
pdm-project/pdm | import logging
import textwrap
import pytest
from pdm.exceptions import ProjectError
from pdm.formats import MetaConvertError
from pdm.models.setup import Setup
def test_from_directory_precedence_and_falsy_update(tmp_path):
pyproject = textwrap.dedent(
"""
[project]
name = "name_py"
... | ["b"] | assert | collection | tests/models/test_setup_parsing_extra.py | test_from_directory_precedence_and_falsy_update | 187 | null | |
pdm-project/pdm | import platform
import sys
from pathlib import Path
import pytest
from pbs_installer import PythonVersion
from pdm.models.python import PythonInfo
from pdm.utils import parse_version
def mock_install(mocker):
if (arch := platform.machine().lower()) not in ("arm64", "aarch64", "amd64", "x86_64"):
pytest.s... | result.stderr | assert | complex_expr | tests/cli/test_python.py | test_link_python_invalid_interpreter | 190 | null | |
pdm-project/pdm | import os
import sys
from pathlib import Path
from types import ModuleType, SimpleNamespace
import pytest
from pdm.environments.local import PythonLocalEnvironment
from pdm.utils import pdm_scheme
def local_env(project):
# Ensure we construct a fresh local environment for each test
env = PythonLocalEnvironme... | "posix" | assert | string_literal | tests/environments/test_environment.py | test_script_kind_posix | 120 | null | |
pdm-project/pdm | import pytest
from unearth import Link
from pdm.models.cached_package import CachedPackage
from tests import FIXTURES
def prepare_wheel_cache(project):
cache_dir = project.cache("wheels")
(cache_dir / "arbitrary/path").mkdir(parents=True)
for name in (
"foo-0.1.0.whl",
"bar-0.2.0.whl",
... | 0 | assert | numeric_literal | tests/cli/test_cache.py | test_cache_list | 37 | null | |
pdm-project/pdm | import shutil
from pathlib import Path
import pytest
from pdm.models.backends import _BACKENDS, get_backend, get_relative_path
from pdm.project import Project
from pdm.utils import cd
from tests import FIXTURES
def _setup_backend(project: Project, backend: str):
project.pyproject.metadata["requires-python"] = ">... | path | assert | variable | tests/models/test_backends.py | test_get_relative_path | 88 | null | |
pdm-project/pdm | import pathlib
import sys
import unittest.mock as mock
from datetime import datetime, timezone
from pathlib import Path
import pytest
import tomlkit
from pdm import utils
from pdm._types import RepositoryConfig
from pdm.cli import utils as cli_utils
from pdm.cli.filters import GroupSelection
from pdm.exceptions impor... | url | assert | variable | tests/test_utils.py | test_hide_url | 515 | null | |
pdm-project/pdm | import platform
import sys
from pathlib import Path
import pytest
from pbs_installer import PythonVersion
from pdm.models.python import PythonInfo
from pdm.utils import parse_version
def mock_install(mocker):
if (arch := platform.machine().lower()) not in ("arm64", "aarch64", "amd64", "x86_64"):
pytest.s... | result.stdout | assert | complex_expr | tests/cli/test_python.py | test_find_python | 205 | null | |
pdm-project/pdm | import pytest
from pdm.models.versions import InvalidPyVersion, Version
def test_normalize_non_standard_version():
version = Version("3.9*")
assert str(version) == | "3.9.*" | assert | string_literal | tests/models/test_versions.py | test_normalize_non_standard_version | 23 | null | |
pdm-project/pdm | from __future__ import annotations
import shutil
import pytest
from unearth import Link
from pdm.exceptions import RequirementError
from pdm.models.candidates import Candidate
from pdm.models.requirements import Requirement, parse_requirement
from pdm.models.specifiers import PySpecSet
from pdm.utils import is_path_... | "demo" | assert | string_literal | tests/models/test_candidates.py | test_parse_local_directory_metadata | 29 | null | |
pdm-project/pdm | import pytest
from unearth import Link
from pdm.models.cached_package import CachedPackage
from tests import FIXTURES
def prepare_wheel_cache(project):
cache_dir = project.cache("wheels")
(cache_dir / "arbitrary/path").mkdir(parents=True)
for name in (
"foo-0.1.0.whl",
"bar-0.2.0.whl",
... | 1 | assert | numeric_literal | tests/cli/test_cache.py | test_clear_package_cache | 168 | null | |
pdm-project/pdm | import pytest
from pdm.cli import actions
from pdm.models.markers import EnvSpec
from pdm.pytest import Distribution
from pdm.utils import cd
def test_install_groups_and_lock(project, pdm, working_set):
project.add_dependencies(["urllib3"])
project.add_dependencies(["pytz"], to_group="tz")
pdm(["install",... | ["tz"] | assert | collection | tests/cli/test_install.py | test_install_groups_and_lock | 290 | null | |
pdm-project/pdm | from __future__ import annotations
import collections.abc
import json
import os
import shutil
import sys
from dataclasses import dataclass
from io import StringIO
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Iterable,
Iterator,
Mapping,
MutableM... | None | assert | none_literal | src/pdm/pytest.py | get_raw_dependencies | RepositoryData | 158 | null |
pdm-project/pdm | import pytest
from pdm.cli import actions
from pdm.models.markers import EnvSpec
from pdm.pytest import Distribution
from pdm.utils import cd
@pytest.mark.usefixtures("working_set")
def test_install_with_lockfile(project, pdm):
result = pdm(["lock", "-v"], obj=project)
assert result.exit_code == | 0 | assert | numeric_literal | tests/cli/test_install.py | test_install_with_lockfile | 152 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import pytest
from pdm.models.requirements import RequirementError, filter_requirements_with_extras, parse_requirement
from tests import FIXTURES
FILE_PREFIX = "file:///" if os.name == "nt" else "file://"
REQUIREMENTS = [
("requests", None),
("requests<2.21.0,>=... | ["bar", "baz"] | assert | collection | tests/models/test_requirements.py | test_filter_requirements_with_extras | 115 | null | |
pdm-project/pdm | import shutil
import pytest
from unearth import Link
from pdm.models.markers import EnvSpec
from pdm.models.specifiers import PySpecSet
from pdm.pytest import Distribution
from tests import FIXTURES
def test_add_update_reuse_installed(project, working_set, repository, pdm):
working_set["foo"] = Distribution("foo... | "1.0.0" | assert | string_literal | tests/cli/test_add.py | test_add_update_reuse_installed | 344 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, ProjectE... | with_pip | assert | variable | tests/test_project.py | test_create_venv_in_project | 251 | null | |
pdm-project/pdm | import os
import pytest
from pdm.cli.templates import ProjectTemplate
from pdm.exceptions import PdmException
def test_module_project_template(project_no_init):
metadata = {
"project": {"name": "foo", "version": "0.1.0", "requires-python": ">=3.10"},
"build-system": {"requires": ["pdm-backend"], ... | ["pytest"] | assert | collection | tests/cli/test_template.py | test_module_project_template | 29 | null | |
pdm-project/pdm | import shlex
import sys
from collections import namedtuple
from textwrap import dedent
import pytest
from pdm.cli import actions
from pdm.cli.options import from_splitted_env
from pdm.signals import pdm_signals
pytestmark = pytest.mark.usefixtures("repository", "working_set", "local_finder")
def test_pre_script_fai... | out | assert | variable | tests/cli/test_hooks.py | test_pre_script_fail_fast | 25 | null | |
pdm-project/pdm | import pytest
from pdm.models.versions import InvalidPyVersion, Version
def test_support_prerelease_version() -> None:
assert not Version("3.9.0").is_prerelease
v = Version("3.9.0a4")
assert v.is_prerelease
assert str(v) == "3.9.0a4"
assert v.complete() == | v | assert | variable | tests/models/test_versions.py | test_support_prerelease_version | 16 | null | |
pdm-project/pdm | import io
import os
import shlex
import zipfile
from pathlib import Path
import pytest
from pdm.environments.local import PythonLocalEnvironment, _get_shebang_path, _is_console_script, _replace_shebang
@pytest.mark.parametrize(
"executable,is_launcher,expected",
[
("/usr/bin/python", True, b"/usr/bin... | expected | assert | variable | tests/environments/test_shebangs.py | test_get_shebang_path | 21 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, ProjectE... | 0 | assert | numeric_literal | tests/test_project.py | test_create_venv_first_time | 234 | null | |
pdm-project/pdm | import pytest
@pytest.mark.usefixtures("working_set")
@pytest.mark.parametrize("strategy", ["reuse", "all"])
def test_update_all_packages(project, repository, pdm, strategy):
pdm(["add", "requests", "pytz"], obj=project, strict=True)
repository.add_candidate("pytz", "2019.6")
repository.add_candidate("char... | "2.20.0" | assert | string_literal | tests/cli/test_update.py | test_update_all_packages | 60 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sqlite3
import sys
import threading
from contextlib import closing
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
import hishel
import hishel.httpx
import httpx
from unearth.fetchers import PyPIClient
from pdm._... | None | assert | none_literal | src/pdm/models/session.py | __init__ | PDMPyPIClient | 141 | null |
pdm-project/pdm | import findpython
import pytest
from pdm.utils import cd
DEFAULT_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
PYPROJECT = {
"project": {"name": "test-project", "version": "0.1.0", "requires-python": ">=3.7"},
"build-system": {"requires": ["pdm-backend"], "build-backend": "pdm.backend"},
}... | r.output | assert | complex_expr | tests/test_integration.py | test_actual_list_freeze | 139 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, ProjectE... | "1.0" | assert | string_literal | tests/test_project.py | test_quiet_mode | 396 | null | |
pdm-project/pdm | def test_output_similar_command_when_typo(pdm):
result = pdm(["instal"])
assert "install" in | result.stderr | assert | complex_expr | tests/cli/test_utils.py | test_output_similar_command_when_typo | 9 | null | |
pdm-project/pdm | import sys
from pathlib import Path
def test_fix_non_existing_problem(project, pdm):
result = pdm(["fix", "non-existing"], obj=project)
assert result.exit_code == | 1 | assert | numeric_literal | tests/cli/test_fix.py | test_fix_non_existing_problem | 7 | null | |
pdm-project/pdm | import pytest
from pdm.models.versions import InvalidPyVersion, Version
def test_version_getitem():
version = Version("3.8.6")
assert version[0] == 3
assert version[1] == 8
assert version[2] == 6
assert version[1:2] == Version("8")
assert version[:-1] == | Version("3.8") | assert | func_call | tests/models/test_versions.py | test_version_getitem | 89 | null | |
pdm-project/pdm | from __future__ import annotations
import os
import sys
import venv
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from pbs_installer import PythonVersion
from pytest_httpserver import HTTPServer
from pdm.environments import PythonEnvironment
from pdm.exceptions import PdmException, ProjectE... | version | assert | variable | tests/test_project.py | test_project_packages_path | 149 | null | |
pdm-project/pdm | from types import SimpleNamespace
from unittest.mock import ANY
import pytest
from pdm.cli.commands import self_cmd
def mock_distribution(metadata, entry_points=()):
entry_points = (SimpleNamespace(group=ep) for ep in entry_points)
return SimpleNamespace(metadata=metadata, entry_points=entry_points)
def moc... | result.stdout | assert | complex_expr | tests/cli/test_self_command.py | test_self_update_already_latest | 125 | null | |
pdm-project/pdm | import os
import pytest
from pdm.cli.templates import ProjectTemplate
from pdm.exceptions import PdmException
def test_module_project_template_generate_application(project_no_init):
metadata = {
"project": {"name": "", "version": "", "requires-python": ">=3.10"},
}
with ProjectTemplate("tests/fi... | "" | assert | string_literal | tests/cli/test_template.py | test_module_project_template_generate_application | 43 | null | |
pdm-project/pdm | import pytest
from pdm.exceptions import PdmUsageError
from pdm.utils import cd
def test_default_repository_setting(project):
repository = project.global_config.get_repository_config("pypi", "repository")
assert repository.url == "https://upload.pypi.org/legacy/"
assert repository.username is | None | assert | none_literal | tests/cli/test_config.py | test_default_repository_setting | 92 | null | |
pdm-project/pdm | import os
import sys
from pathlib import Path
from types import ModuleType, SimpleNamespace
import pytest
from pdm.environments.local import PythonLocalEnvironment
from pdm.utils import pdm_scheme
def local_env(project):
# Ensure we construct a fresh local environment for each test
env = PythonLocalEnvironme... | "3.11" | assert | string_literal | tests/environments/test_environment.py | test_packages_path_compat_suffix_32 | 27 | null | |
pdm-project/pdm | import shutil
import pytest
from unearth import Link
from pdm.models.markers import EnvSpec
from pdm.models.specifiers import PySpecSet
from pdm.pytest import Distribution
from tests import FIXTURES
def test_add_package_update_reuse(project, repository, pdm):
pdm(["add", "--no-sync", "--save-wildcard", "requests... | "2.20.0" | assert | string_literal | tests/cli/test_add.py | test_add_package_update_reuse | 186 | null | |
pdm-project/pdm | import base64
import os
from argparse import Namespace
import pytest
from pdm._types import RepositoryConfig
from pdm.cli.commands.publish import Command as PublishCommand
from pdm.cli.commands.publish.package import PackageFile
from pdm.cli.commands.publish.repository import Repository
from pdm.exceptions import Pdm... | "source" | assert | string_literal | tests/cli/test_publish.py | test_package_parse_metadata | 34 | null | |
pdm-project/pdm | import base64
import os
from argparse import Namespace
import pytest
from pdm._types import RepositoryConfig
from pdm.cli.commands.publish import Command as PublishCommand
from pdm.cli.commands.publish.package import PackageFile
from pdm.cli.commands.publish.repository import Repository
from pdm.exceptions import Pdm... | ("signature.asc", b"test gpg signature") | assert | collection | tests/cli/test_publish.py | test_package_add_signature | 51 | null | |
pdm-project/pdm | import shutil
import pytest
from unearth import Link
from pdm.models.markers import EnvSpec
from pdm.models.specifiers import PySpecSet
from pdm.pytest import Distribution
from tests import FIXTURES
def test_add_package_update_reuse(project, repository, pdm):
pdm(["add", "--no-sync", "--save-wildcard", "requests... | "3.0.4" | assert | string_literal | tests/cli/test_add.py | test_add_package_update_reuse | 168 | null | |
pdm-project/pdm | import shutil
from argparse import Namespace
import pytest
from pdm.formats import MetaConvertError, flit, pipfile, poetry, requirements, setup_py
from pdm.models.requirements import parse_requirement
from pdm.utils import cd
from tests import FIXTURES
def ns(**kwargs):
default_options = {
"dev": False,
... | group | assert | variable | tests/test_formats.py | test_convert_requirements_file | 54 | null | |
pdm-project/pdm | import pytest
from pdm.cli import actions
from pdm.models.specifiers import PySpecSet
@pytest.mark.usefixtures("repository")
def test_remove_no_package(project, pdm):
result = pdm(["remove"], obj=project)
assert result.exit_code != | 0 | assert | numeric_literal | tests/cli/test_remove.py | test_remove_no_package | 80 | null | |
pdm-project/pdm | import pytest
@pytest.mark.usefixtures("working_set")
def test_update_ignore_constraints(project, repository, pdm):
project.project_config["strategy.save"] = "compatible"
pdm(["add", "pytz"], obj=project, strict=True)
assert project.pyproject.metadata["dependencies"] == ["pytz~=2019.3"]
repository.add_... | "3.0.4" | assert | string_literal | tests/cli/test_update.py | test_update_ignore_constraints | 34 | null | |
pdm-project/pdm | import base64
import os
from argparse import Namespace
import pytest
from pdm._types import RepositoryConfig
from pdm.cli.commands.publish import Command as PublishCommand
from pdm.cli.commands.publish.package import PackageFile
from pdm.cli.commands.publish.repository import Repository
from pdm.exceptions import Pdm... | filename | assert | variable | tests/cli/test_publish.py | test_package_parse_metadata | 24 | null | |
keon/algorithms | import unittest
from bst import bst
def height(root):
if root is None:
return 0
else:
return 1 + max(height(root.left), height(root.right))
class TestSuite(unittest.TestCase):
def setUp(self):
self.tree = bst()
self.tree.insert(9)
self.tree.insert(6)
self.t... | height(self.tree.root)) | self.assertEqual | func_call | algorithms/tree/bst_height.py | test_height | TestSuite | 61 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | jump_search(array, 3)) | self.assertEqual | func_call | tests/test_searching.py | test_jump_search | TestSuite | 127 | null |
keon/algorithms | import unittest
from algorithms.heap import BinaryHeap, get_skyline, k_closest, max_sliding_window
class TestSuite(unittest.TestCase):
def test_k_closest_points(self):
points = [(1, 0), (2, 3), (5, 2), (1, 1), (2, 8), (10, 2), (-1, 0), (-2, -2)]
self.assertEqual([(-1, 0), (1, 0)], k_closest(point... | k_closest(points, 8)) | self.assertEqual | func_call | tests/test_heap.py | test_k_closest_points | TestSuite | 53 | null |
keon/algorithms | from __future__ import annotations
import unittest
from algorithms.backtracking.minimax import minimax
from algorithms.bit_manipulation.gray_code import gray_code, gray_to_binary
from algorithms.data_structures.kd_tree import KDTree
from algorithms.dynamic_programming.bitmask import tsp
from algorithms.dynamic_progra... | 4) | self.assertEqual | numeric_literal | tests/test_community_algorithms.py | test_last_element | TestSentinelSearch | 154 | null |
keon/algorithms | from __future__ import annotations
import unittest
from algorithms.backtracking.minimax import minimax
from algorithms.bit_manipulation.gray_code import gray_code, gray_to_binary
from algorithms.data_structures.kd_tree import KDTree
from algorithms.dynamic_programming.bitmask import tsp
from algorithms.dynamic_progra... | 6) | self.assertEqual | numeric_literal | tests/test_community_algorithms.py | test_z_array_basic | TestZAlgorithm | 56 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | swap_pair(10)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_swap_pair | TestSuite | 231 | null |
keon/algorithms | import unittest
from algorithms.data_structures.b_tree import BTree
from algorithms.data_structures.fenwick_tree import Fenwick_Tree
from algorithms.tree import construct_tree_postorder_preorder as ctpp
from algorithms.tree.traversal_inorder import inorder, inorder_rec
from algorithms.tree.traversal_postorder import p... | preorder_rec(tree)) | self.assertEqual | func_call | tests/test_tree.py | test_preorder | TestTraversal | 22 | null |
keon/algorithms | import unittest
from algorithms.heap import BinaryHeap, get_skyline, k_closest, max_sliding_window
class TestSuite(unittest.TestCase):
def test_k_closest_points(self):
points = [(1, 0), (2, 3), (5, 2), (1, 1), (2, 8), (10, 2), (-1, 0), (-2, -2)]
self.assertEqual([(-1, 0), (1, 0)], k_closest(point... | k_closest(points, 3)) | self.assertEqual | func_call | tests/test_heap.py | test_k_closest_points | TestSuite | 51 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | find_min_rotate(array)) | self.assertEqual | func_call | tests/test_searching.py | test_find_min_rotate | TestSuite | 108 | null |
keon/algorithms | import unittest
from algorithms.backtracking import (
add_operators,
anagram,
array_sum_combinations,
combination_sum,
find_words,
generate_abbreviations,
generate_parenthesis_v1,
generate_parenthesis_v2,
get_factors,
letter_combinations,
palindromic_substrings,
pattern_... | answer1) | self.assertEqual | variable | tests/test_backtracking.py | test_combination_sum | TestCombinationSum | 120 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | search_range(array, 7)) | self.assertEqual | func_call | tests/test_searching.py | test_search_range | TestSuite | 98 | null |
keon/algorithms | import unittest
from algorithms.matrix import (
bomb_enemy,
cholesky_matrix_decomposition,
copy_transform,
crout_matrix_decomposition,
matrix_exponentiation,
matrix_inversion,
multiply,
rotate_image,
sort_matrix_diagonally,
sparse_dot_vector,
spiral_traversal,
sudoku_val... | [[-1]]) | self.assertEqual | collection | tests/test_matrix.py | test_inversion | TestInversion | 185 | null |
keon/algorithms | import unittest
from algorithms.queue import (
ArrayQueue,
LinkedListQueue,
PriorityQueue,
max_sliding_window,
reconstruct_queue,
)
class TestSuite(unittest.TestCase):
def test_max_sliding_window(self):
array = [1, 3, -1, -3, 5, 3, 6, 7]
self.assertEqual(max_sliding_window(arra... | [3, 3, 5, 5, 6, 7]) | self.assertEqual | collection | tests/test_queue.py | test_max_sliding_window | TestSuite | 80 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | remove_bit(21, 2)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_remove_bit | TestSuite | 279 | null |
keon/algorithms | import unittest
from algorithms.data_structures.veb_tree import VEBTree
class TestVEBTree(unittest.TestCase):
def setUp(self):
self.veb = VEBTree(16)
def test_delete(self):
for v in [1, 3, 5, 7]:
self.veb.insert(v)
self.veb.delete(3)
self.assertFalse(self.veb.memb... | self.veb.successor(1)) | self.assertEqual | func_call | tests/test_veb_tree.py | test_delete | TestVEBTree | 42 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | 4) | self.assertEqual | numeric_literal | tests/test_array.py | test_flatten_iter | TestFlatten | 111 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | reverse_bits(0)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_reverse_bits | TestSuite | 131 | null |
keon/algorithms | import unittest
from algorithms.linked_list import (
RandomListNode,
copy_random_pointer_v1,
copy_random_pointer_v2,
is_cyclic,
is_palindrome,
is_palindrome_dict,
is_palindrome_stack,
is_sorted,
merge_two_list,
merge_two_list_recur,
remove_range,
reverse_list,
revers... | result.label) | self.assertEqual | complex_expr | tests/test_linked_list.py | _assert_is_a_copy | TestSuite | 199 | null |
keon/algorithms | import unittest
from algorithms.queue import (
ArrayQueue,
LinkedListQueue,
PriorityQueue,
max_sliding_window,
reconstruct_queue,
)
class TestQueue(unittest.TestCase):
def test_array_queue(self):
queue = ArrayQueue()
queue.enqueue(1)
queue.enqueue(2)
queue.enqu... | len(queue)) | self.assertEqual | func_call | tests/test_queue.py | test_array_queue | TestQueue | 31 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | 6) | self.assertEqual | numeric_literal | tests/test_array.py | test_longest_non_repeat_v1 | TestLongestNonRepeat | 163 | null |
keon/algorithms | import math
import unittest
from fractions import Fraction
from algorithms.math.polynomial import Monomial, Polynomial
class TestSuite(unittest.TestCase):
def setUp(self):
self.p0 = Polynomial([Monomial({})])
self.p1 = Polynomial([Monomial({}), Monomial({})])
self.p2 = Polynomial([Monomial... | self.p1) | self.assertEqual | complex_expr | tests/test_polynomial.py | test_polynomial_addition | TestSuite | 41 | null |
keon/algorithms | import unittest
from algorithms.map import (
HashTable,
ResizableHashTable,
SeparateChainingHashTable,
is_anagram,
is_isomorphic,
longest_palindromic_subsequence,
word_pattern,
)
class TestHashTable(unittest.TestCase):
def test_len_trivial(self):
m = HashTable(10)
sel... | len(m)) | self.assertEqual | func_call | tests/test_map.py | test_len_trivial | TestHashTable | 69 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | get_bit(22, 3)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_get_bit | TestSuite | 197 | null |
keon/algorithms | import unittest
from algorithms.stack import (
ArrayStack,
LinkedListStack,
OrderedStack,
first_is_consecutive,
first_stutter,
first_switch_pairs,
is_sorted,
is_valid,
remove_min,
second_is_consecutive,
second_stutter,
second_switch_pairs,
simplify_path,
)
class Tes... | stack.peek()) | self.assertEqual | func_call | tests/test_stack.py | test_ordered_stack | TestOrderedStack | 153 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | 5) | self.assertEqual | numeric_literal | tests/test_array.py | test_flatten_iter | TestFlatten | 112 | null |
keon/algorithms | import unittest
from algorithms.stack import (
ArrayStack,
LinkedListStack,
OrderedStack,
first_is_consecutive,
first_stutter,
first_switch_pairs,
is_sorted,
is_valid,
remove_min,
second_is_consecutive,
second_stutter,
second_switch_pairs,
simplify_path,
)
class Tes... | len(stack)) | self.assertEqual | func_call | tests/test_stack.py | test_array_stack | TestStack | 91 | null |
keon/algorithms | import unittest
from algorithms.matrix import (
bomb_enemy,
cholesky_matrix_decomposition,
copy_transform,
crout_matrix_decomposition,
matrix_exponentiation,
matrix_inversion,
multiply,
rotate_image,
sort_matrix_diagonally,
sparse_dot_vector,
spiral_traversal,
sudoku_val... | [1, 2, 3, 6, 9, 8, 7, 4, 5]) | self.assertEqual | collection | tests/test_matrix.py | test_spiral_traversal | TestSpiralTraversal | 295 | null |
keon/algorithms | import unittest
from algorithms.heap import BinaryHeap, get_skyline, k_closest, max_sliding_window
class TestBinaryHeap(unittest.TestCase):
def setUp(self):
self.min_heap = BinaryHeap()
self.min_heap.insert(4)
self.min_heap.insert(50)
self.min_heap.insert(7)
self.min_heap.... | ret) | self.assertEqual | variable | tests/test_heap.py | test_remove_min | TestBinaryHeap | 32 | null |
keon/algorithms | import math
import unittest
from fractions import Fraction
from algorithms.math.polynomial import Monomial
class TestSuite(unittest.TestCase):
def setUp(self):
self.m1 = Monomial({})
self.m2 = Monomial({1: 1}, 2)
self.m3 = Monomial({1: 2, 2: -1}, 1.5)
self.m4 = Monomial({1: 1, 2: 2... | TypeError) | self.assertRaises | variable | tests/test_monomial.py | test_monomial_addition | TestSuite | 56 | null |
keon/algorithms | import math
import unittest
from fractions import Fraction
from algorithms.math.polynomial import Monomial, Polynomial
class TestSuite(unittest.TestCase):
def setUp(self):
self.p0 = Polynomial([Monomial({})])
self.p1 = Polynomial([Monomial({}), Monomial({})])
self.p2 = Polynomial([Monomial... | self.p0) | self.assertEqual | complex_expr | tests/test_polynomial.py | test_polynomial_addition | TestSuite | 40 | null |
keon/algorithms | import unittest
from algorithms.queue import (
ArrayQueue,
LinkedListQueue,
PriorityQueue,
max_sliding_window,
reconstruct_queue,
)
class TestPriorityQueue(unittest.TestCase):
def test_priority_queue(self):
queue = PriorityQueue([3, 4, 1, 6])
self.assertEqual(4, | queue.size()) | self.assertEqual | func_call | tests/test_queue.py | test_priority_queue | TestPriorityQueue | 102 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | 2) | self.assertEqual | numeric_literal | tests/test_array.py | test_flatten_iter | TestFlatten | 108 | null |
keon/algorithms | import unittest
from algorithms.heap import BinaryHeap, get_skyline, k_closest, max_sliding_window
class TestSuite(unittest.TestCase):
def test_k_closest_points(self):
points = [(1, 0), (2, 3), (5, 2), (1, 1), (2, 8), (10, 2), (-1, 0), (-2, -2)]
self.assertEqual([(-1, 0), (1, 0)], k_closest(point... | k_closest(points, 4)) | self.assertEqual | func_call | tests/test_heap.py | test_k_closest_points | TestSuite | 52 | null |
keon/algorithms | import unittest
from algorithms.queue import (
ArrayQueue,
LinkedListQueue,
PriorityQueue,
max_sliding_window,
reconstruct_queue,
)
class TestSuite(unittest.TestCase):
def test_max_sliding_window(self):
array = [1, 3, -1, -3, 5, 3, 6, 7]
self.assertEqual(max_sliding_window(arra... | [6, 7]) | self.assertEqual | collection | tests/test_queue.py | test_max_sliding_window | TestSuite | 81 | null |
keon/algorithms | import unittest
from algorithms.linked_list import (
RandomListNode,
copy_random_pointer_v1,
copy_random_pointer_v2,
is_cyclic,
is_palindrome,
is_palindrome_dict,
is_palindrome_stack,
is_sorted,
merge_two_list,
merge_two_list_recur,
remove_range,
reverse_list,
revers... | is_sorted(head)) | self.assertTrue | func_call | tests/test_linked_list.py | test_is_sorted | TestSuite | 72 | null |
keon/algorithms | import unittest
from algorithms.dynamic_programming import (
Item,
Job,
climb_stairs,
climb_stairs_optimized,
combination_sum_bottom_up,
combination_sum_topdown,
count,
edit_distance,
egg_drop,
fib_iter,
fib_list,
fib_recursive,
find_k_factor,
get_maximum_value,
... | 0) | self.assertEqual | numeric_literal | tests/test_dynamic_programming.py | test_max_profit_naive | TestBuySellStock | 33 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | count_ones_recur(0)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_count_ones_recur | TestSuite | 60 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | search_range(array, 8)) | self.assertEqual | func_call | tests/test_searching.py | test_search_range | TestSuite | 97 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | helper(array, 3)) | self.assertEqual | func_call | tests/test_searching.py | test_first_occurrence | TestSuite | 35 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | count_ones_iter(8)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_count_ones_iter | TestSuite | 65 | null |
keon/algorithms | from __future__ import annotations
import unittest
from algorithms.backtracking.minimax import minimax
from algorithms.bit_manipulation.gray_code import gray_code, gray_to_binary
from algorithms.data_structures.kd_tree import KDTree
from algorithms.dynamic_programming.bitmask import tsp
from algorithms.dynamic_progra... | 7) | self.assertEqual | numeric_literal | tests/test_community_algorithms.py | test_2d | TestManhattanDistance | 171 | null |
keon/algorithms | import unittest
from algorithms.data_structures.veb_tree import VEBTree
class TestVEBTree(unittest.TestCase):
def setUp(self):
self.veb = VEBTree(16)
def test_insert_and_member(self):
values = [2, 3, 4, 7, 14]
for v in values:
self.veb.insert(v)
for v in values:
... | self.veb.member(5)) | self.assertFalse | func_call | tests/test_veb_tree.py | test_insert_and_member | TestVEBTree | 18 | null |
keon/algorithms | import unittest
from algorithms.map import (
HashTable,
ResizableHashTable,
SeparateChainingHashTable,
is_anagram,
is_isomorphic,
longest_palindromic_subsequence,
word_pattern,
)
class TestHashTable(unittest.TestCase):
def test_delete_key(self):
m = HashTable(10)
for i... | m.get(2)) | self.assertEqual | func_call | tests/test_map.py | test_delete_key | TestHashTable | 50 | null |
keon/algorithms | import unittest
import pytest
from algorithms.math import (
base_to_int,
chinese_remainder_theorem,
combination,
combination_memo,
cosine_similarity,
decimal_to_binary_ip,
decrypt,
diffie_hellman_key_exchange,
encrypt,
euler_totient,
extended_gcd,
factorial,
factori... | counter) | self.assertEqual | variable | tests/test_math.py | test_prime_test | TestPrimeTest | 309 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | []) | self.assertListEqual | collection | tests/test_array.py | test_delete_nth_naive | TestDeleteNth | 66 | null |
keon/algorithms | import unittest
from algorithms.data_structures.b_tree import BTree
from algorithms.data_structures.fenwick_tree import Fenwick_Tree
from algorithms.tree import construct_tree_postorder_preorder as ctpp
from algorithms.tree.traversal_inorder import inorder, inorder_rec
from algorithms.tree.traversal_postorder import p... | preorder(tree)) | self.assertEqual | func_call | tests/test_tree.py | test_preorder | TestTraversal | 21 | null |
keon/algorithms | import random
import unittest
from algorithms.bit_manipulation import (
add_bitwise_operator,
binary_gap,
bytes_big_endian_to_int,
bytes_little_endian_to_int,
clear_bit,
count_flips_to_convert,
count_ones_iter,
count_ones_recur,
find_difference,
find_missing_number,
find_mis... | binary_gap(145)) | self.assertEqual | func_call | tests/test_bit_manipulation.py | test_binary_gap | TestSuite | 291 | null |
keon/algorithms | import unittest
from algorithms.dynamic_programming import (
Item,
Job,
climb_stairs,
climb_stairs_optimized,
combination_sum_bottom_up,
combination_sum_topdown,
count,
edit_distance,
egg_drop,
fib_iter,
fib_list,
fib_recursive,
find_k_factor,
get_maximum_value,
... | 7) | self.assertEqual | numeric_literal | tests/test_dynamic_programming.py | test_combination_sum_topdown | TestCombinationSum | 58 | null |
keon/algorithms | import unittest
from algorithms.graph import (
Sudoku,
Tarjan,
all_pairs_shortest_path,
bellman_ford,
check_bipartite,
check_digraph_strongly_connected,
count_connected_number_of_component,
count_islands,
cycle_detection,
dinic,
edmonds_karp,
find_path,
find_path_dfs... | test_obj.board) | self.assertEqual | complex_expr | tests/test_graph.py | test_sudoku_solver | TestSudoku | 519 | null |
keon/algorithms | import unittest
from algorithms.string import (
add_binary,
atbash,
bracket,
caesar_cipher,
check_pangram,
contain_string,
convert_morse_word,
count_binary_substring,
decode,
decode_string,
delete_reoccurring_characters,
domain_name_1,
domain_name_2,
encode,
... | expected) | self.assertEqual | variable | tests/test_string.py | test_fizzbuzz | TestFizzbuzz | 751 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | two_sum2(array, 9)) | self.assertEqual | func_call | tests/test_searching.py | test_two_sum | TestSuite | 92 | null |
keon/algorithms | import unittest
from algorithms.array import (
Interval,
delete_nth,
delete_nth_naive,
flatten,
flatten_iter,
garage,
get_longest_non_repeat_v1,
get_longest_non_repeat_v2,
josephus,
limit,
longest_non_repeat_v1,
longest_non_repeat_v2,
max_ones_index,
merge_interv... | 3) | self.assertEqual | numeric_literal | tests/test_array.py | test_flatten_iter | TestFlatten | 110 | null |
keon/algorithms | import unittest
from algorithms.searching import (
binary_search,
binary_search_recur,
find_min_rotate,
find_min_rotate_recur,
first_occurrence,
interpolation_search,
jump_search,
last_occurrence,
linear_search,
next_greatest_letter,
next_greatest_letter_v1,
next_greates... | two_sum1(array, 22)) | self.assertEqual | func_call | tests/test_searching.py | test_two_sum | TestSuite | 90 | null |
keon/algorithms | import unittest
import pytest
from algorithms.math import (
base_to_int,
chinese_remainder_theorem,
combination,
combination_memo,
cosine_similarity,
decimal_to_binary_ip,
decrypt,
diffie_hellman_key_exchange,
encrypt,
euler_totient,
extended_gcd,
factorial,
factori... | ValueError) | self.assertRaises | variable | tests/test_math.py | test_modular_inverse | TestModularInverse | 242 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.