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 |
|---|---|---|---|---|---|---|---|---|---|
stanford-cs336/assignment1-basics | import numpy
import torch
import torch.nn as nn
import torch.nn.functional as F
from .adapters import get_adamw_cls, run_load_checkpoint, run_save_checkpoint
def are_optimizers_equal(optimizer1_state_dict, optimizer2_state_dict, atol=1e-8, rtol=1e-5):
# Check if the keys of the main dictionaries are equal (e.g., ... | loaded_iterations | assert | variable | tests/test_serialization.py | test_checkpointing | 102 | null | |
laixintao/flameshow | from flameshow.models import Profile
from flameshow.render.framedetail import FrameStatAll
from ..utils import create_frame
def test_render_self_value_all_instance():
root = create_frame(
{
"id": 0,
"values": [10],
"children": [
{"id": 1, "values": [4], "... | 6 | assert | numeric_literal | tests/test_render/test_render_detail.py | test_render_self_value_all_instance | 19 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame():
f1 = Frame("foo", 12)
f2 = Frame("bar", 12)
assert f1 == f2
assert f1 != Frame("a", 13)
assert f1 != | 123 | assert | numeric_literal | tests/test_models.py | test_frame | 63 | null | |
laixintao/flameshow | from rich.text import Text
from flameshow.parsers.stackcollapse_parser import StackCollapseFrame
def test_frame_model_render():
f = StackCollapseFrame(
"java::abc", 1, parent=None, children=[], values=[13]
)
render_result = f.render_one_frame_detail(f, 0, "count")
assert len(render_result) == | 1 | assert | numeric_literal | tests/test_stackcollapse_parse/test_model.py | test_frame_model_render | 10 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_parse_simple_text_data(simple_collapse_data):
parser = StackCollapseParser("a.txt")
profile = parser.parse(simple_collapse_data)
assert profile.highest_lines == 3
assert frame2json(profile.r... | "root" | assert | string_literal | tests/test_stackcollapse_parse/test_parser.py | test_parse_simple_text_data | 53 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | -1 | assert | numeric_literal | tests/test_pprof_parse/test_golang_pprof.py | test_golang_goroutine_parse_using_protobuf | 45 | null | |
laixintao/flameshow | from textual.geometry import Size
from flameshow.models import Frame, Profile, SampleType
from flameshow.render.app import FlameGraphScroll, FlameshowApp
from unittest.mock import MagicMock, patch, PropertyMock
def test_app_set_title_after_mount():
r = Frame("root", 0)
p = Profile(
filename="abc",
... | "count" | assert | string_literal | tests/test_render/test_app.py | test_app_set_title_after_mount | 46 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | 123 | assert | numeric_literal | tests/test_render/test_flamegraph.py | test_flamegraph_action_zoom_in_zoom_out | 204 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | 2 | assert | numeric_literal | tests/test_render/test_flamegraph.py | test_flamegraph_action_move_down | 239 | null | |
laixintao/flameshow | from flameshow.colors import LinaerColorPlatte, flamegraph_random_color_platte
from textual.color import Color
def test_linaer_color_platte():
platte = LinaerColorPlatte()
color1 = platte.get_color("1")
color3 = platte.get_color("1")
color2 = platte.get_color("2")
assert color1 is | color3 | assert | variable | tests/test_colors.py | test_linaer_color_platte | 12 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | expected | assert | variable | tests/test_pprof_parse/test_golang_pprof.py | test_python_protobuf_goroutine_check_frame_tree | 27 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | "cpu" | assert | string_literal | tests/test_pprof_parse/test_golang_pprof.py | test_golang_profile10s_parse_using_protobuf | 57 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame_get_color():
with patch("flameshow.models.r") as mock_r:
mock_r.get_color.return_value = "#1122ff"
f1 = Frame("foo", 12)
... | "#1122ff" | assert | string_literal | tests/test_models.py | test_frame_get_color | 75 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame_get_color():
with patch("flameshow.models.r") as mock_r:
mock_r.get_color.return_value = "#1122ff"
f1 = Frame("foo", 12)
... | "foo") | assert_* | string_literal | tests/test_models.py | test_frame_get_color | 76 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_parse_simple_text_data(simple_collapse_data):
parser = StackCollapseParser("a.txt")
profile = parser.parse(simple_collapse_data)
assert profile.highest_lines == 3
assert frame2json(profile.r... | [ "root", "a", "b", "c", "a", "b", "c", "a", "b", "d", "a", "b", "c", "a", "b", ] | assert | collection | tests/test_stackcollapse_parse/test_parser.py | test_parse_simple_text_data | 35 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | 24 | assert | numeric_literal | tests/test_pprof_parse/test_golang_pprof.py | test_golang_goroutine_parse_using_protobuf | 46 | null | |
laixintao/flameshow | from rich.text import Text, Span
from flameshow.render.header import (
HeaderIcon,
HeaderTitle,
HeaderOpenedFilename,
FlameshowHeader,
)
def test_header_opened_filename():
hf = HeaderOpenedFilename("goro.out")
assert hf.render() == | Text("goro.out") | assert | func_call | tests/test_render/test_render_header.py | test_header_opened_filename | 27 | null | |
laixintao/flameshow | import os
from unittest.mock import MagicMock, patch
from click.testing import CliRunner
from flameshow.main import ensure_tty, main
@patch("flameshow.main.os")
def test_run_app(mock_os, data_dir):
mock_os.isatty.return_value = True
runner = CliRunner()
result = runner.invoke(
main, [str(data_dir... | 0 | assert | numeric_literal | tests/test_cli_click.py | test_run_app | 25 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | Function( id=1, filename="/usr/local/go/src/runtime/proc.go", name="runtime.gopark", start_line=0, system_name="runtime.gopark", ) | assert | func_call | tests/test_pprof_parse/test_golang_pprof.py | test_protobuf_parse_gorouting_mapping | 142 | null | |
laixintao/flameshow | from flameshow.render.app import FlameshowApp
async def test_app_startup(profile10s_profile):
app = FlameshowApp(profile10s_profile)
async with app.run_test() as pilot:
center_text = app.query_one("HeaderOpenedFilename")
assert | "pprof_data/profile-10seconds.out: (cpu, nanoseconds)" | assert | string_literal | tests/test_integration/test_app.py | test_app_startup | 8 | null | |
laixintao/flameshow | from flameshow.models import Profile
from flameshow.render.framedetail import FrameStatAll
from ..utils import create_frame
def test_render_self_value_all_instance():
root = create_frame(
{
"id": 0,
"values": [10],
"children": [
{"id": 1, "values": [4], "... | 4 | assert | numeric_literal | tests/test_render/test_render_detail.py | test_render_self_value_all_instance | 25 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_parse_max_depth_when_have_multiple_lines(profile10s):
parser = ProfileParser("abc")
profile = parser.parse(profile10s)
assert profile.highe... | 26 | assert | numeric_literal | tests/test_models.py | test_parse_max_depth_when_have_multiple_lines | 12 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_parse_simple_text_data(simple_collapse_data):
parser = StackCollapseParser("a.txt")
profile = parser.parse(simple_collapse_data)
assert profile.highest_lines == 3
assert frame2json(profile.... | { "root": { "children": [ { "a": { "children": [ { "b": { "children": [ {"c": {"children": [], "values": [5]}}, {"d": {"children": [], "values": [4]}}, ], "values": [14], } } ], "values": [14], } } ], "values": [14], }, } | assert | collection | tests/test_stackcollapse_parse/test_parser.py | test_parse_simple_text_data | 11 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame():
f1 = Frame("foo", 12)
f2 = Frame("bar", 12)
assert f1 == f2
assert f1 != Frame("a", 13)
assert f1 != 123
f4 = Frame("h... | [f1] | assert | collection | tests/test_models.py | test_frame | 66 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | [Frame("", 1)] | assert | collection | tests/test_pprof_parse/test_golang_pprof.py | test_parser_get_name_aggr | 172 | null | |
laixintao/flameshow | from rich.text import Text, Span
from flameshow.render.header import (
HeaderIcon,
HeaderTitle,
HeaderOpenedFilename,
FlameshowHeader,
)
def test_header_title():
ht = HeaderTitle()
ht.text = "abc"
ht.sub_text = "foo"
assert ht.render() == | Text("abc — foo", spans=[Span(6, 9, "dim")]) | assert | func_call | tests/test_render/test_render_header.py | test_header_title | 21 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | [Frame("", 2)] | assert | collection | tests/test_pprof_parse/test_golang_pprof.py | test_parser_get_name_aggr | 173 | null | |
laixintao/flameshow | from flameshow.pprof_parser.parser import Line, PprofFrame, Frame
def test_render_detail_when_parent_zero():
root = PprofFrame("root", 0, values=[0])
s1 = PprofFrame("s1", 1, values=[0], parent=root, root=root)
s1.line = Line()
s1.line.function.name = "asdf"
detail = s1.render_detail(0, "bytes")
... | str(detail) | assert | func_call | tests/test_profile_parser.py | test_render_detail_when_parent_zero | 28 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | False | assert | bool_literal | tests/test_render/test_flamegraph.py | test_flamegraph_action_move_down | 238 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_parse_simple_text_data(simple_collapse_data):
parser = StackCollapseParser("a.txt")
profile = parser.parse(simple_collapse_data)
assert profile.highest_lines == | 3 | assert | numeric_literal | tests/test_stackcollapse_parse/test_parser.py | test_parse_simple_text_data | 9 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame():
f1 = Frame("foo", 12)
f2 = Frame("bar", 12)
assert f1 == | f2 | assert | variable | tests/test_models.py | test_frame | 61 | null | |
laixintao/flameshow | from flameshow.render.app import FlameshowApp
async def test_app_startup(profile10s_profile):
app = FlameshowApp(profile10s_profile)
async with app.run_test() as pilot:
center_text = app.query_one("HeaderOpenedFilename")
assert (
center_text.filename
== "pprof_data/profi... | "runtime.mcall" | assert | string_literal | tests/test_integration/test_app.py | test_app_startup | 17 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | [Frame("", 21)] | assert | collection | tests/test_pprof_parse/test_golang_pprof.py | test_parser_get_name_aggr_with_nested | 225 | null | |
laixintao/flameshow | import os
from unittest.mock import MagicMock, patch
from click.testing import CliRunner
from flameshow.main import ensure_tty, main
def test_print_version():
runner = CliRunner()
with patch("flameshow.main.__version__", "1.2.3"):
result = runner.invoke(main, ["--version"])
assert result.exit... | "1.2.3\n" | assert | string_literal | tests/test_cli_click.py | test_print_version | 14 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | 42 | assert | numeric_literal | tests/test_render/test_flamegraph.py | test_flamegraph_action_zoom_in_zoom_out | 208 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | Location( id=1, mapping=Mapping( id=1, memory_start=4194304, memory_limit=11280384, file_offset=0, filename="/usr/bin/node-exporter", build_id="", has_functions=True, has_filenames=False, has_line_numbers=False, has_inline_frames=False, ), address=4435364, lines=[ Line( line_no=336, function=Function( id=1, filename="/... | assert | func_call | tests/test_pprof_parse/test_golang_pprof.py | test_protobuf_parse_gorouting_mapping | 113 | null | |
laixintao/flameshow | import os
from unittest.mock import MagicMock, patch
from click.testing import CliRunner
from flameshow.main import ensure_tty, main
@patch("flameshow.main.sys")
@patch("flameshow.main.os")
def test_ensure_tty_when_its_not(mock_os, mock_sys):
mock_os.isatty.return_value = False
opened_fd = object()
mock_... | opened_fd | assert | variable | tests/test_cli_click.py | test_ensure_tty_when_its_not | 42 | null | |
laixintao/flameshow | from flameshow.utils import sizeof
def test_sizeof():
assert sizeof(1) == "1.0B"
assert sizeof(2048) == "2.0KiB"
assert | "5.8YiB" | assert | string_literal | tests/test_utils.py | test_sizeof | 7 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | 0 | assert | numeric_literal | tests/test_render/test_flamegraph.py | test_flamegraph_render_on_mouse_move | 632 | null | |
laixintao/flameshow | from rich.text import Text
from flameshow.parsers.stackcollapse_parser import StackCollapseFrame
def test_frame_model_render_with_square():
f = StackCollapseFrame("[abc]", 1, parent=None, children=[], values=[13])
render_result = f.render_one_frame_detail(f, 0, "count")
assert len(render_result) == 1
i... | "\\[abc]\n" | assert | string_literal | tests/test_stackcollapse_parse/test_model.py | test_frame_model_render_with_square | 20 | null | |
laixintao/flameshow | from textual.geometry import Size
from flameshow.models import Frame, Profile, SampleType
from flameshow.render.app import FlameGraphScroll, FlameshowApp
from unittest.mock import MagicMock, patch, PropertyMock
def test_app_set_title_after_mount():
r = Frame("root", 0)
p = Profile(
filename="abc",
... | r | assert | variable | tests/test_render/test_app.py | test_app_set_title_after_mount | 45 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_validate_simple_text_data_contains_numbers_somtimes_parsing():
data = b"""
a;b;c 10
5
c 4
10
"""
profile = StackCollapseParser("a.txt").parse(data)
assert frame2json(profile.root_stack) == | { "root": { "children": [ { "a": { "children": [ { "b": { "children": [ {"c": {"children": [], "values": [10]}} ], "values": [10], } } ], "values": [10], } }, {"c": {"children": [], "values": [4]}}, ], "values": [14], } } | assert | collection | tests/test_stackcollapse_parse/test_parser.py | test_validate_simple_text_data_contains_numbers_somtimes_parsing | 100 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | [Frame("", 1), Frame("", 2)] | assert | collection | tests/test_pprof_parse/test_golang_pprof.py | test_parser_get_name_aggr_with_nested | 224 | null | |
laixintao/flameshow | from flameshow.utils import sizeof
def test_sizeof():
assert sizeof(1) == "1.0B"
assert sizeof(2048) == | "2.0KiB" | assert | string_literal | tests/test_utils.py | test_sizeof | 6 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame_get_color_full_model_path():
with patch("flameshow.models.r") as mock_r:
mock_r.get_color.return_value = "#1122ff"
f1 = PprofFr... | "expfmt") | assert_* | string_literal | tests/test_models.py | test_frame_get_color_full_model_path | 86 | null | |
laixintao/flameshow | from rich.text import Text
from flameshow.parsers.stackcollapse_parser import StackCollapseFrame
def test_frame_model_render():
f = StackCollapseFrame(
"java::abc", 1, parent=None, children=[], values=[13]
)
render_result = f.render_one_frame_detail(f, 0, "count")
assert len(render_result) == 1... | "java::abc\n" | assert | string_literal | tests/test_stackcollapse_parse/test_model.py | test_frame_model_render | 12 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_pile_up():
root = Frame("root", 0, values=[5])
s1 = Frame("s1", 1, values=[4], parent=root)
s2 = Frame("s2", 2, values=[4], parent=s1)
r... | [7] | assert | collection | tests/test_models.py | test_pile_up | 28 | null | |
laixintao/flameshow | from unittest.mock import patch
from flameshow.models import Profile, SampleType
from flameshow.pprof_parser.parser import Frame, PprofFrame, ProfileParser
def test_frame():
f1 = Frame("foo", 12)
f2 = Frame("bar", 12)
assert f1 == f2
assert f1 != Frame("a", 13)
assert f1 != 123
f4 = Frame("h... | "<Frame #12 foo>" | assert | string_literal | tests/test_models.py | test_frame | 68 | null | |
laixintao/flameshow | from flameshow.pprof_parser.parser import Line, PprofFrame, Frame
def test_pile_up():
root = Frame("root", 0, values=[5])
s1 = Frame("s1", 1, values=[4], parent=root)
s2 = Frame("s2", 2, values=[4], parent=s1)
root.children = [s1]
s1.children = [s2]
s1 = Frame("s1", 3, values=[3], parent=None... | [6] | assert | collection | tests/test_profile_parser.py | test_pile_up | 18 | null | |
laixintao/flameshow | from flameshow.parsers.stackcollapse_parser import StackCollapseParser
from ..utils import frame2json
def test_space_and_numbers_in_stackcollapse_symbols():
data = b"""
a 1;b 2;c 3 10
"""
profile = StackCollapseParser("a.txt").parse(data)
assert frame2json(profile.root_stack) == | { "root": { "children": [ { "a 1": { "children": [ { "b 2": { "children": [ { "c 3": { "children": [], "values": [10], } } ], "values": [10], } } ], "values": [10], } } ], "values": [10], }, } | assert | collection | tests/test_stackcollapse_parse/test_parser.py | test_space_and_numbers_in_stackcollapse_symbols | 130 | null | |
laixintao/flameshow | from textual.geometry import Size
from flameshow.models import Frame, Profile, SampleType
from flameshow.render.app import FlameGraphScroll, FlameshowApp
from unittest.mock import MagicMock, patch, PropertyMock
def _test_scroll(line_no, height, expected_center):
fc = FlameGraphScroll()
size = Magic... | expected_center | assert | variable | tests/test_render/test_app.py | _test_scroll | 20 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | 2 | assert | numeric_literal | tests/test_pprof_parse/test_golang_pprof.py | test_golang_profile10s_parse_using_protobuf | 51 | null | |
laixintao/flameshow | import datetime
import json
from flameshow.models import Frame, Profile, SampleType
from flameshow.pprof_parser.parser import ProfileParser
from flameshow.pprof_parser.parser import (
Function,
Line,
Location,
Mapping,
ProfileParser,
get_frame_tree,
parse_profile,
unmarshal,
)
from ..u... | [Frame("", 0)] | assert | collection | tests/test_pprof_parse/test_golang_pprof.py | test_parser_get_name_aggr | 171 | null | |
laixintao/flameshow | from unittest.mock import MagicMock
import pytest
from textual.events import MouseMove
from flameshow.exceptions import RenderException
from flameshow.models import Frame
from flameshow.pprof_parser.parser import Profile, SampleType
from flameshow.render.flamegraph import FlameGraph, FrameMap, add_array
from ..utils... | 1 | assert | numeric_literal | tests/test_render/test_flamegraph.py | test_flamegraph_action_move_down_children_is_zero | 295 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | len(t2) | assert | func_call | core/text.py | assert_trees_equal | VerbatimStep | 787 | null |
alexmojaki/futurecoder | import ast
import inspect
from textwrap import indent
from core.exercises import assert_equal
from core.text import ExerciseStep, Page, VerbatimStep, MessageStep, search_ast
class introducing_assert_equal(VerbatimStep):
text = f"""
An important part of writing programs is testing that they work correctly.... | 10) | assert_* | numeric_literal | core/chapters/c09_functions.py | program | introducing_assert_equal | 524 | null |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | f"def {t.get_code_bit('solution')}(self):" | assert | string_literal | core/text.py | clean_program | 76 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | t2) | assert_* | variable | core/text.py | are_trees_equal | VerbatimStep | 777 | null |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_redefined_while_unused():
code_redefined_while_unused = """
def is_positive(number: int) -> bool:
return number > 0
def is_positive(number: int) -> bool:
return number >= 0
... | [ """ **Redefined `is_positive` without using it** You defined `is_positive` on line `2`, but before ever using it you redefined it, overwriting the original definition. In general your functions and classes should have different names. Check that you use everything you define, e.g. that you called your functions. """ ... | assert | collection | tests/test_linting.py | test_redefined_while_unused | 98 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | 12 + i | assert | complex_expr | tests/test_frontend.py | _tests | 295 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | "Error" | assert | string_literal | core/text.py | get_predictions | 245 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | program | assert | variable | tests/test_steps.py | test_steps | 55 | null | |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_import_star():
code_import_star = """
from base import *
print(BaseThing('hi'))
"""
assert lint_tree(code_import_star) == | [ """ **Import made using `*` ** `from base import *` imports everything from the module `base` into the current namespace. This creates a bunch of invisible unknown variables. It makes it hard to read and understand code and see where things come from. Avoid this kind of import and instead explicitly import exactly th... | assert | collection | tests/test_linting.py | test_import_star | 116 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | "Login / Sign up\nTable of Contents" | assert | string_literal | tests/test_frontend.py | _tests | 116 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | text | assert | variable | core/text.py | clean_step_class | 165 | null | |
alexmojaki/futurecoder | import ast
import inspect
from textwrap import indent
from core.exercises import assert_equal
from core.text import ExerciseStep, Page, VerbatimStep, MessageStep, search_ast
class introducing_assert_equal(VerbatimStep):
text = f"""
An important part of writing programs is testing that they work correctly.... | 4) | assert_* | numeric_literal | core/chapters/c09_functions.py | program | introducing_assert_equal | 523 | null |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_import_shadowed_by_loop_var():
code_import_shadowed_by_loop_var = """
import pandas as pd
x=[1,2,3]
for pd in x:
print(pd)
"""
assert lint_tree(code_import_shadowed_by_loop_va... | [ """ **Import `pd` shadowed by loop variable** The name of the loop variable `pd` should be changed as it redefines the `pd` module imported earlier. Choose a different loop variable to avoid this error. """ ] | assert | collection | tests/test_linting.py | test_import_shadowed_by_loop_var | 17 | null | |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_multi_value_repeated_key_literal():
code_multi_value_repeated_key = """
print({'a':1,'b':2,'a':3})
"""
assert lint_tree(code_multi_value_repeated_key) == | [ """ **Dictionary key `a` repeated with different values** A dictionary cannot have multiple entries for the same key. Check your code again and change the repeated key to something unique. """, """ **Dictionary key `a` repeated with different values** A dictionary cannot have multiple entries for the same key. Check ... | assert | collection | tests/test_linting.py | test_multi_value_repeated_key_literal | 151 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | "messages" | assert | string_literal | tests/test_steps.py | normalise_response | 108 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | not is_message | assert | complex_expr | tests/test_steps.py | test_steps | 66 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | get_solution | assert | variable | tests/test_steps.py | test_steps | 53 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | t2 | assert | variable | core/text.py | assert_trees_equal | VerbatimStep | 804 | null |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | message | assert | variable | tests/test_steps.py | normalise_response | 113 | null | |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_import_star_not_permitted():
code_import_star_not_permitted = """
def f():
from module import *
"""
assert lint_tree(code_import_star_not_permitted) == | [ """ **Import made using `*` ** `from module import *` imports everything from the module `module` into the current namespace. This creates a bunch of invisible unknown variables. It makes it hard to read and understand code and see where things come from. Avoid this kind of import and instead explicitly import exactl... | assert | collection | tests/test_linting.py | test_import_star_not_permitted | 134 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | num_hints | assert | variable | tests/test_frontend.py | show_hints_and_solution | 421 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | 1 | assert | numeric_literal | tests/test_steps.py | normalise_response | 109 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | f"prediction-choice prediction-{status}" | assert | string_literal | tests/test_frontend.py | check_choice_status | 542 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | hint_num | assert | variable | tests/test_frontend.py | show_hints_and_solution | 405 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | "Yes" | assert | string_literal | tests/test_frontend.py | show_hints_and_solution | 435 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | f" return {func.__name__}" | assert | string_literal | core/text.py | clean_program | 77 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | type(t2) | assert | func_call | core/text.py | assert_trees_equal | VerbatimStep | 785 | null |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | bottom_text | assert | variable | tests/test_frontend.py | predict_output | 510 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | list(ast.iter_fields(t2))) | assert_* | func_call | core/text.py | assert_trees_equal | VerbatimStep | 799 | null |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | {"type", "messages"} | assert | collection | tests/test_steps.py | normalise_response | 107 | null | |
alexmojaki/futurecoder | from __future__ import annotations
import ast
import inspect
import itertools
import re
from abc import ABC, abstractmethod
from copy import deepcopy
from functools import cached_property, cache
from importlib import import_module
from io import StringIO
from pathlib import Path
from random import shuffle
from textwra... | len(inputs) | assert | func_call | core/text.py | test_values | ExerciseStep | 703 | null |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | full | assert | variable | tests/test_frontend.py | await_result | 457 | null | |
alexmojaki/futurecoder | import os
import sys
from pathlib import Path
from time import sleep
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.expected_conditions import ... | 6 | assert | numeric_literal | tests/test_frontend.py | predict_output | 491 | null | |
alexmojaki/futurecoder | import json
import os
import random
import re
from pathlib import Path
import core.utils
from core import translation as t
from core.checker import check_entry, FullRunner
from core.text import step_test_entries, get_predictions, load_chapters
from core.utils import highlighted_markdown, make_test_input_callback
core... | 4 + is_function | assert | complex_expr | tests/test_steps.py | test_steps | 64 | null | |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_unused_var():
code_unused_var = """
import random
def write_random_to_file():
no = random.randint(1, 10)
with open("random.txt", "w") as file:
file.write(str(no))
retu... | [ """ **Unused variable `random_no`** You defined a variable `random_no` but never used it. Did you forget to use it? Maybe you used the wrong variable in its place? If you don't need it, just remove it entirely. """ ] | assert | collection | tests/test_linting.py | test_unused_var | 57 | null | |
alexmojaki/futurecoder | import ast
from core.linting import lint
def lint_tree(code):
tree = ast.parse(code)
return list(lint(tree))
def test_unused_import():
code_unused_import = """
import random
def write_to_file(text, filename):
with open("log.txt", "w") as file:
file.write(text)
"""
assert lint_tree(code_un... | [ """ **Unused import `random`** You imported `random` but never used it. Did you forget to use it? Maybe you used the wrong variable in its place? If you don't need the import, just remove it entirely. """ ] | assert | collection | tests/test_linting.py | test_unused_import | 34 | null | |
readthedocs/sphinx-autoapi | import sys
import astroid
import pytest
from autoapi._parser import Parser
class TestPythonParser:
def parse(self, source):
node = astroid.extract_node(source)
return Parser().parse(node)
def test_parses_basic_file(self):
source = """
def foo(bar):
pass
""... | "function" | assert | string_literal | tests/python/test_parser.py | test_parses_basic_file | TestPythonParser | 23 | null |
readthedocs/sphinx-autoapi | import logging
import os
import pathlib
import sys
from unittest.mock import Mock, call
import autoapi.settings
from autoapi._objects import (
PythonClass,
PythonData,
PythonFunction,
PythonMethod,
PythonModule,
)
from packaging import version
import pytest
import sphinx
from sphinx.application imp... | 3 | assert | numeric_literal | tests/python/test_pyintegration.py | check_integration | TestSimpleModule | 75 | null |
readthedocs/sphinx-autoapi | import sys
import astroid
import pytest
from autoapi._parser import Parser
class TestPythonParser:
def parse(self, source):
node = astroid.extract_node(source)
return Parser().parse(node)
def test_parses_all(self):
source = """
__all__ = ['Foo', 5.0]
"""
data ... | "['Foo', 5.0]" | assert | string_literal | tests/python/test_parser.py | test_parses_all | TestPythonParser | 31 | null |
readthedocs/sphinx-autoapi | import logging
import os
import pathlib
import sys
from unittest.mock import Mock, call
import autoapi.settings
from autoapi._objects import (
PythonClass,
PythonData,
PythonFunction,
PythonMethod,
PythonModule,
)
from packaging import version
import pytest
import sphinx
from sphinx.application imp... | "X" | assert | string_literal | tests/python/test_pyintegration.py | test_multiple_var_function | TestTypeParams | 1,474 | null |
readthedocs/sphinx-autoapi | import logging
import os
import pathlib
import sys
from unittest.mock import Mock, call
import autoapi.settings
from autoapi._objects import (
PythonClass,
PythonData,
PythonFunction,
PythonMethod,
PythonModule,
)
from packaging import version
import pytest
import sphinx
from sphinx.application imp... | 2 | assert | numeric_literal | tests/python/test_pyintegration.py | check_integration | TestSimpleModule | 68 | null |
readthedocs/sphinx-autoapi | import sys
import astroid
from autoapi import _astroid_utils
from autoapi import _objects
import pytest
def generate_module_names():
for i in range(1, 5):
yield ".".join(f"module{j}" for j in range(i))
yield "package.repeat.repeat"
def imported_basename_cases():
for module_name in generate_modul... | expected | assert | variable | tests/test_astroid_utils.py | test_can_get_full_imported_basename | TestAstroidUtils | 73 | null |
readthedocs/sphinx-autoapi | import os
import pytest
@pytest.mark.parametrize(
"value", ["package", "exception", "property", "data", "not_a_value"]
)
def test_invalid_values(builder, value):
"""Test failure when autoapi_own_page_level is invalid."""
with pytest.raises( | ValueError) | pytest.raises | variable | tests/python/test_own_page_option.py | test_invalid_values | 975 | null | |
readthedocs/sphinx-autoapi | import logging
import os
import pathlib
import sys
from unittest.mock import Mock, call
import autoapi.settings
from autoapi._objects import (
PythonClass,
PythonData,
PythonFunction,
PythonMethod,
PythonModule,
)
from packaging import version
import pytest
import sphinx
from sphinx.application imp... | "A" | assert | string_literal | tests/python/test_pyintegration.py | test_annotations | TestPy3Module | 468 | null |
readthedocs/sphinx-autoapi | import logging
import os
import pathlib
import sys
from unittest.mock import Mock, call
import autoapi.settings
from autoapi._objects import (
PythonClass,
PythonData,
PythonFunction,
PythonMethod,
PythonModule,
)
from packaging import version
import pytest
import sphinx
from sphinx.application imp... | "T" | assert | string_literal | tests/python/test_pyintegration.py | test_generic_method | TestTypeParams | 1,527 | null |
readthedocs/sphinx-autoapi | import sys
import astroid
import pytest
from autoapi._parser import Parser
class TestPythonParser:
def parse(self, source):
node = astroid.extract_node(source)
return Parser().parse(node)
def test_parses_list(self):
name = "__all__"
value = "[1, 2, 3, 4]"
source = f"{... | value | assert | variable | tests/python/test_parser.py | test_parses_list | TestPythonParser | 53 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.