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 |
|---|---|---|---|---|---|---|---|---|---|
mammothb/symspellpy | import pytest
from symspellpy import SymSpell
def symspell_edit_distance_load(dictionary_path, request):
sym_spell = SymSpell(request.param)
sym_spell.load_dictionary(dictionary_path, 0, 1)
return sym_spell, request.param
class TestSymSpellPyWordSegmentation:
@pytest.mark.parametrize("symspell_defaul... | result.corrected_string | assert | complex_expr | tests/test_symspellpy_word_segmentation.py | test_word_segmentation_ignore_token | TestSymSpellPyWordSegmentation | 19 | null |
mammothb/symspellpy | from symspellpy.helpers import null_distance_results, prefix_suffix_prep
def test_prefix_suffix_prep():
assert prefix_suffix_prep("dabca", "ddca") == | (2, 1, 1) | assert | collection | tests/test_compatibility.py | test_prefix_suffix_prep | 12 | null | |
mammothb/symspellpy | import os
import pickle
from unittest import TestCase
import pytest
from symspellpy import SymSpell
class TestSymSpellPyPickle:
@pytest.mark.parametrize(
"symspell_default_load, is_compressed",
[("unigram", True), ("bigram", True), ("unigram", False), ("bigram", False)],
indirect=["symspe... | sym_spell_2._max_length | assert | complex_expr | tests/test_symspellpy_pickle.py | test_pickle | TestSymSpellPyPickle | 40 | null |
mammothb/symspellpy | import sys
import pytest
from symspellpy import SymSpell, Verbosity
def symspell_high_thres():
return SymSpell(2, 7, 10)
def symspell_high_thres_flame(symspell_high_thres):
symspell_high_thres.create_dictionary_entry("flame", 20)
symspell_high_thres.create_dictionary_entry("flam", 1)
return symspell... | len(result) | assert | func_call | tests/test_symspellpy_lookup.py | test_deletes | TestSymSpellPyLookup | 28 | null |
mammothb/symspellpy | import pytest
from symspellpy import Verbosity
ENTRIES = ["baked", "ax", "lake", "", "slaked"]
class TestSymSpellPyEdgeCases:
def test_split_correction_part_of_single_term_correction(self, symspell_default):
symspell_default.create_dictionary_entry("where", 2)
symspell_default.create_dictionary_... | suggestions[0].count | assert | complex_expr | tests/test_symspellpy_edge_cases.py | test_split_correction_part_of_single_term_correction | TestSymSpellPyEdgeCases | 26 | null |
mammothb/symspellpy | import sys
from itertools import combinations, permutations
import pytest
from symspellpy.abstract_distance_comparer import AbstractDistanceComparer
from symspellpy.editdistance import (
DamerauOsa,
DamerauOsaFast,
DistanceAlgorithm,
EditDistance,
Levenshtein,
LevenshteinFast,
)
SHORT_STRING ... | comparer.distance( s1, s2, max_distance ) | assert | func_call | tests/test_editdistance.py | test_comparer_match_ref | TestEditDistance | 176 | null |
mammothb/symspellpy | import pytest
from symspellpy.suggest_item import SuggestItem
def suggest_item():
return SuggestItem("term", 0, 0)
class TestSuggestItem:
def test_suggest_item(self):
si_1 = SuggestItem("asdf", 12, 34)
si_2 = SuggestItem("sdfg", 12, 34)
si_3 = SuggestItem("dfgh", 56, 78)
ass... | str(si_1) | assert | func_call | tests/test_suggest_item.py | test_suggest_item | TestSuggestItem | 40 | null |
mammothb/symspellpy | import pytest
from symspellpy.helpers import (
case_transfer_matching,
case_transfer_similar,
is_acronym,
to_similarity,
)
def get_acronyms():
return [
("ABCDE", {"default": True, "digits": True}),
("AB12E", {"default": True, "digits": True}),
("abcde", {"default": False, "... | is_acronym(word, True) | assert | func_call | tests/test_helpers.py | test_is_acronym | TestHelpers | 52 | null |
mammothb/symspellpy | import os
import pickle
from unittest import TestCase
import pytest
from symspellpy import SymSpell
class TestSymSpellPyPickle:
@pytest.mark.parametrize(
"symspell_default_load, is_compressed",
[("unigram", True), ("bigram", True), ("unigram", False), ("bigram", False)],
indirect=["symspe... | sym_spell_2.words | assert | complex_expr | tests/test_symspellpy_pickle.py | test_pickle | TestSymSpellPyPickle | 39 | null |
mammothb/symspellpy | import sys
from itertools import combinations, permutations
import pytest
from symspellpy.abstract_distance_comparer import AbstractDistanceComparer
from symspellpy.editdistance import (
DamerauOsa,
DamerauOsaFast,
DistanceAlgorithm,
EditDistance,
Levenshtein,
LevenshteinFast,
)
SHORT_STRING ... | comparer.distance(s1, s2, max_distance) | assert | func_call | tests/test_editdistance.py | test_editdistance_use_custom_comparer | TestEditDistance | 187 | null |
mammothb/symspellpy | import pytest
from symspellpy.helpers import (
case_transfer_matching,
case_transfer_similar,
is_acronym,
to_similarity,
)
def get_acronyms():
return [
("ABCDE", {"default": True, "digits": True}),
("AB12E", {"default": True, "digits": True}),
("abcde", {"default": False, "... | to_similarity(-1.0, length) | assert | func_call | tests/test_helpers.py | test_to_similarity | TestHelpers | 47 | null |
mammothb/symspellpy | import pytest
from symspellpy.suggest_item import SuggestItem
def suggest_item():
return SuggestItem("term", 0, 0)
class TestSuggestItem:
def test_suggest_item(self):
si_1 = SuggestItem("asdf", 12, 34)
si_2 = SuggestItem("sdfg", 12, 34)
si_3 = SuggestItem("dfgh", 56, 78)
as... | si_2 | assert | variable | tests/test_suggest_item.py | test_suggest_item | TestSuggestItem | 29 | null |
mammothb/symspellpy | import pytest
from symspellpy.helpers import (
case_transfer_matching,
case_transfer_similar,
is_acronym,
to_similarity,
)
def get_acronyms():
return [
("ABCDE", {"default": True, "digits": True}),
("AB12E", {"default": True, "digits": True}),
("abcde", {"default": False, "... | case_transfer_matching( cased_text, uncased_text ) | assert | func_call | tests/test_helpers.py | test_case_transfer_matching | TestHelpers | 68 | null |
mammothb/symspellpy | import sys
import pytest
from symspellpy import SymSpell, Verbosity
def symspell_high_thres():
return SymSpell(2, 7, 10)
def symspell_high_thres_flame(symspell_high_thres):
symspell_high_thres.create_dictionary_entry("flame", 20)
symspell_high_thres.create_dictionary_entry("flam", 1)
return symspell... | result[1].term | assert | complex_expr | tests/test_symspellpy_lookup.py | test_words_with_shared_prefix_should_retain_counts | TestSymSpellPyLookup | 42 | null |
mammothb/symspellpy | import pytest
from symspellpy import SymSpell
def symspell_edit_distance_load(dictionary_path, request):
sym_spell = SymSpell(request.param)
sym_spell.load_dictionary(dictionary_path, 0, 1)
return sym_spell, request.param
class TestSymSpellPyWordSegmentation:
@pytest.mark.parametrize("symspell_edit_... | result[1] | assert | complex_expr | tests/test_symspellpy_word_segmentation.py | test_word_segmentation_apostrophe | TestSymSpellPyWordSegmentation | 58 | null |
mammothb/symspellpy | import pytest
from symspellpy import Verbosity
ENTRIES = ["baked", "ax", "lake", "", "slaked"]
class TestSymSpellPyEdgeCases:
def test_split_correction_part_of_single_term_correction(self, symspell_default):
symspell_default.create_dictionary_entry("where", 2)
symspell_default.create_dictionary_... | suggestions[0].term | assert | complex_expr | tests/test_symspellpy_edge_cases.py | test_split_correction_part_of_single_term_correction | TestSymSpellPyEdgeCases | 24 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | 5 | assert | numeric_literal | paperscraper/citations/tests/test_self_citations.py | test_whole_researcher | TestSelfCitations | 137 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | "Juan M. Galeazzi" | assert | string_literal | paperscraper/citations/tests/test_self_citations.py | test_researcher_from_orcid | TestSelfCitations | 110 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | int(ssaid) | assert | func_call | paperscraper/citations/tests/test_self_citations.py | test_researcher | TestSelfCitations | 85 | null |
jannisborn/paperscraper | import logging
from paperscraper.citations import get_citations_by_doi
from paperscraper.citations.utils import check_overlap, author_name_to_ssaid
logging.disable(logging.INFO)
class TestCitations:
def test_author_name_to_ssid(self):
ssaid, name = author_name_to_ssaid('Fabian H Sinz')
assert s... | 'Fabian H Sinz' | assert | string_literal | paperscraper/citations/tests/test_citations.py | test_author_name_to_ssid | TestCitations | 22 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | True | assert | bool_literal | paperscraper/tests/test_pdf.py | test_fallback_bioc_pmc_real_api | TestPDF | 273 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_references_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_references import ReferenceResult
logging.disable(logging.INFO)
class TestSelfReferences:
def dois(self... | "Patrick Soga" | assert | string_literal | paperscraper/citations/tests/test_self_references.py | test_researcher | TestSelfReferences | 61 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | s | assert | variable | paperscraper/citations/tests/test_self_citations.py | test_multiple_dois | TestSelfCitations | 76 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | 100 | assert | numeric_literal | paperscraper/tests/test_pdf.py | test_fallback_bioc_pmc_real_api | TestPDF | 280 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_value_error(self, impactor: Impactor):
with pytest.raises( | ValueError) | pytest.raises | variable | paperscraper/tests/test_impactor.py | test_value_error | TestImpactor | 99 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_quantum_information_search(self, impactor):
expected_results = [
{"journal": "Innovation", "factor": 25.7, "sco... | expected_results | assert | variable | paperscraper/tests/test_impactor.py | test_quantum_information_search | TestImpactor | 90 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.citations import SelfLinkClient
from paperscraper.citations.entity import PaperResult
logging.disable(logging.INFO)
class TestPaper:
def ssids(self):
return [
"a732443cae8cd2d6a76f4f3cf785a562baf41137", # semantic scholar ID
]
def... | 0 | assert | numeric_literal | paperscraper/citations/tests/test_paper.py | test_paper_doi | TestPaper | 32 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | sync_duration | assert | variable | paperscraper/citations/tests/test_self_citations.py | test_multiple_dois | TestSelfCitations | 67 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_references_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_references import ReferenceResult
logging.disable(logging.INFO)
class TestSelfReferences:
def dois(self... | orcid | assert | variable | paperscraper/citations/tests/test_self_references.py | test_researcher_from_orcid | TestSelfReferences | 82 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_quantum_information_search(self, impactor):
expected_results = [
{"journal": "Innovation", "factor": 25.7, "sco... | len(expected_results) | assert | func_call | paperscraper/tests/test_impactor.py | test_quantum_information_search | TestImpactor | 68 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | False | assert | bool_literal | paperscraper/tests/test_pdf.py | test_fallback_bioc_pmc_no_pmcid | TestPDF | 290 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_quantum_information_search(self, impactor):
expected_results = [
{"journal": "Innovation", "factor": 25.7, "sco... | 0.001 | assert | numeric_literal | paperscraper/tests/test_impactor.py | test_quantum_information_search | TestImpactor | 73 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | KeyError) | pytest.raises | variable | paperscraper/tests/test_pdf.py | test_missing_doi | TestPDF | 92 | null |
jannisborn/paperscraper | import logging
from paperscraper.citations import get_citations_by_doi
from paperscraper.citations.utils import check_overlap, author_name_to_ssaid
logging.disable(logging.INFO)
class TestCitations:
def test_author_name_to_ssid(self):
ssaid, name = author_name_to_ssaid('Fabian H Sinz')
assert ... | '50095217' | assert | string_literal | paperscraper/citations/tests/test_citations.py | test_author_name_to_ssid | TestCitations | 21 | null |
jannisborn/paperscraper | import functools
import logging
import pandas as pd
import pytest
from scholarly._proxy_generator import MaxTriesExceededException
from paperscraper.citations import get_citations_from_title
from paperscraper.scholar import get_and_dump_scholar_papers, get_scholar_papers
logging.disable(logging.INFO)
def handle_sch... | 0 | assert | numeric_literal | paperscraper/scholar/tests/test_scholar.py | test_bad_search | TestScholar | 60 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_basic_search(self, impactor: Impactor):
results = impactor.search("Nat Comm", threshold=99, sort_by="score")
asser... | 0 | assert | numeric_literal | paperscraper/tests/test_impactor.py | test_basic_search | TestImpactor | 17 | null |
jannisborn/paperscraper | import os
import tempfile
from paperscraper.pubmed import get_and_dump_pubmed_papers, get_pubmed_papers
from paperscraper.pubmed.utils import get_query_from_keywords_and_date
KEYWORDS = [["machine learning", "deep learning"], ["zoology"]]
class TestPubMed:
def test_email(self):
query = get_query_from_ke... | df.columns | assert | complex_expr | paperscraper/pubmed/tests/test_pubmed.py | test_email | TestPubMed | 20 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_sort_by_score(self, impactor: Impactor):
results = impactor.search("nature chem", threshold=80, sort_by="score")
sc... | sorted( scores, reverse=True ) | assert | func_call | paperscraper/tests/test_impactor.py | test_sort_by_score | TestImpactor | 31 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_quantum_information_search(self, impactor):
expected_results = [
{"journal": "Innovation", "factor": 25.7, "sco... | actual["journal"] | assert | complex_expr | paperscraper/tests/test_impactor.py | test_quantum_information_search | TestImpactor | 70 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_references_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_references import ReferenceResult
logging.disable(logging.INFO)
class TestSelfReferences:
def dois(self... | int(ssaid) | assert | func_call | paperscraper/citations/tests/test_self_references.py | test_researcher | TestSelfReferences | 59 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | len(dois) | assert | func_call | paperscraper/citations/tests/test_self_citations.py | test_multiple_dois | TestSelfCitations | 41 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | 3 | assert | numeric_literal | paperscraper/citations/tests/test_self_citations.py | test_whole_researcher | TestSelfCitations | 138 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | orcid | assert | variable | paperscraper/citations/tests/test_self_citations.py | test_researcher_from_orcid | TestSelfCitations | 108 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | caplog.text.lower() | assert | func_call | paperscraper/tests/test_pdf.py | test_fallback_elsevier_api_invalid_key | TestPDF | 400 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_citations_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_citations import CitationResult
logging.disable(logging.INFO)
class TestSelfCitations:
def dois(self):
... | 10 | assert | numeric_literal | paperscraper/citations/tests/test_self_citations.py | test_single_doi | TestSelfCitations | 27 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | TypeError) | pytest.raises | variable | paperscraper/tests/test_pdf.py | test_invalid_metadata_type | TestPDF | 97 | null |
jannisborn/paperscraper | import importlib
import logging
import multiprocessing
import os
import time
from datetime import datetime, timedelta
from functools import partial
import pytest
import paperscraper.load_dumps as load_dumps_module
from paperscraper import dump_queries
from paperscraper.arxiv import get_and_dump_arxiv_papers
from pape... | ValueError, match=r"start_date .* cannot be later than end_date .*") | pytest.raises | complex_expr | paperscraper/tests/test_dump.py | test_arxiv_wrong_date | TestDumper | 113 | null |
jannisborn/paperscraper | import logging
import time
from typing import Dict
import pytest
from paperscraper.citations import self_references_paper
from paperscraper.citations.entity import Researcher
from paperscraper.citations.self_references import ReferenceResult
logging.disable(logging.INFO)
class TestSelfReferences:
def dois(self... | -1 | assert | numeric_literal | paperscraper/citations/tests/test_self_references.py | test_researcher | TestSelfReferences | 65 | null |
jannisborn/paperscraper | import logging
import os
import shutil
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from paperscraper.pdf import load_api_keys, save_pdf, save_pdf_from_dump
from paperscraper.pdf.fallbacks import FALLBACKS
logging.disable(logging.INFO)
TEST_FILE_PATH = str(Path(__file__).parent ... | ValueError) | pytest.raises | variable | paperscraper/tests/test_pdf.py | test_nonexistent_directory_in_filepath | TestPDF | 117 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_quantum_information_search(self, impactor):
expected_results = [
{"journal": "Innovation", "factor": 25.7, "sco... | actual["score"] | assert | complex_expr | paperscraper/tests/test_impactor.py | test_quantum_information_search | TestImpactor | 76 | null |
jannisborn/paperscraper | import logging
import pytest
from paperscraper.impact import Impactor
logging.disable(logging.INFO)
class TestImpactor:
def impactor(self):
return Impactor()
def test_type_error(self, impactor: Impactor):
with pytest.raises( | TypeError) | pytest.raises | variable | paperscraper/tests/test_impactor.py | test_type_error | TestImpactor | 93 | null |
AlignmentResearch/tuned-lens | import pytest
from tuned_lens.plotting import TokenFormatter
def formatter():
return TokenFormatter()
def test_format_non_string(formatter):
assert formatter.format(None) == | "<unk>" | assert | string_literal | tests/plotting/test_token_formatter.py | test_format_non_string | 12 | null | |
AlignmentResearch/tuned-lens | from pathlib import Path
import mock
import pytest
import torch as th
import transformers as trf
from tuned_lens.load_artifacts import load_lens_artifacts
from tuned_lens.nn.lenses import LogitLens, TunedLens, TunedLensConfig
from tuned_lens.nn.unembed import Unembed
def model_config():
config = mock.MagicMock(t... | 1 | assert | numeric_literal | tests/test_lenses.py | test_tuned_lens_generate_smoke | 146 | null | |
AlignmentResearch/tuned-lens | import warnings
from pathlib import Path
import pytest
from tuned_lens.__main__ import main
def test_train_subcommand_fails_when_not_enough_data_given(
text_dataset_path: Path, gpt2_tiny_random_model_local_path: Path, tmp_path: Path
):
args = (
f"--log_level DEBUG train --data.name {text_dataset_path... | ValueError, match="Can only take") | pytest.raises | complex_expr | tests/scripts/test_integration.py | test_train_subcommand_fails_when_not_enough_data_given | 85 | null | |
AlignmentResearch/tuned-lens | import pytest
import torch as th
from tuned_lens.causal import remove_subspace
@pytest.mark.parametrize("d", list(range(1, 1000, 100)))
def test_remove_subspace(d: int):
a = th.randn(10, d, dtype=th.float64)
for k in range(1, d, 10):
b = th.randn(d, k, dtype=th.float64)
inner = a @ b
... | inner.mean(0, keepdim=True).expand_as(inner_)) | assert_* | func_call | tests/test_subspaces.py | test_remove_subspace | 21 | null | |
AlignmentResearch/tuned-lens | import torch as th
from torch.distributions import Categorical, kl_divergence
from tuned_lens.stats import js_distance, js_divergence
def test_js_divergence():
p = Categorical(logits=th.randn(10))
q = Categorical(logits=th.randn(10))
m = Categorical(probs=0.5 * (p.probs + q.probs)) # type: ignore
kl... | our_js_fwd) | assert_* | variable | tests/test_distance.py | test_js_divergence | 19 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
from plotly import graph_objects as go
from tuned_lens.plotting.trajectory_plotting import (
TrajectoryLabels,
TrajectoryStatistic,
_stride_keep_last,
)
def test_stride_method():
stats = np.zeros((3, 2), dtype=float)
ts = TrajectoryStatistic("test", stats)
stri... | ts.min | assert | complex_expr | tests/plotting/test_trajectory_plotting.py | test_stride_method | 115 | null | |
AlignmentResearch/tuned-lens | import math
import transformers as tr
from datasets import Dataset
from tuned_lens import data
def test_compute_nats_to_bpb_ratio(
text_dataset: Dataset, gpt2_tokenizer: tr.PreTrainedTokenizerBase
):
max_seq_len = 128
_, ratio = data.chunk_and_tokenize(
text_dataset, gpt2_tokenizer, load_from_cac... | ratio | assert | variable | tests/test_data.py | test_compute_nats_to_bpb_ratio | 50 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
from plotly import graph_objects as go
from tuned_lens.plotting.trajectory_plotting import (
TrajectoryLabels,
TrajectoryStatistic,
_stride_keep_last,
)
def test_stride_method():
stats = np.zeros((3, 2), dtype=float)
ts = TrajectoryStatistic("test", stats)
stri... | ts.max | assert | complex_expr | tests/plotting/test_trajectory_plotting.py | test_stride_method | 114 | null | |
AlignmentResearch/tuned-lens | import pytest
import torch as th
from transformers import PreTrainedModel
from tuned_lens import model_surgery
def test_get_layers_from_model(random_small_model: PreTrainedModel):
path, layers = model_surgery.get_transformer_layers(random_small_model)
assert isinstance(layers, th.nn.ModuleList)
assert isi... | random_small_model.config.num_hidden_layers | assert | complex_expr | tests/test_model_surgery.py | test_get_layers_from_model | 23 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
from plotly import graph_objects as go
from tuned_lens.plotting.trajectory_plotting import (
TrajectoryLabels,
TrajectoryStatistic,
_stride_keep_last,
)
def test_trajectory_statistic_post_init():
stats = np.zeros((2, 2), dtype=float)
trajectory_labels = TrajectoryL... | AssertionError) | pytest.raises | variable | tests/plotting/test_trajectory_plotting.py | test_trajectory_statistic_post_init | 28 | null | |
AlignmentResearch/tuned-lens | import math
import transformers as tr
from datasets import Dataset
from tuned_lens import data
def test_chunk_and_tokenize(
text_dataset: Dataset, small_model_tokenizer: tr.PreTrainedTokenizerBase
):
max_seq_len = 128
chunked, _ = data.chunk_and_tokenize(
text_dataset,
small_model_tokeniz... | length | assert | variable | tests/test_data.py | test_chunk_and_tokenize | 22 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
import torch as th
import transformer_lens as tl
from transformers import AutoModelForCausalLM, AutoTokenizer
from tuned_lens.nn.lenses import LogitLens, TunedLens, Unembed
from tuned_lens.plotting import PredictionTrajectory
from tuned_lens.plotting.prediction_trajectory import _selec... | "" | assert | string_literal | tests/plotting/test_prediction_trajectory.py | test_rank_smoke | 151 | null | |
AlignmentResearch/tuned-lens | from pathlib import Path
import mock
import pytest
import torch as th
import transformers as trf
from tuned_lens.load_artifacts import load_lens_artifacts
from tuned_lens.nn.lenses import LogitLens, TunedLens, TunedLensConfig
from tuned_lens.nn.unembed import Unembed
def model_config():
config = mock.MagicMock(t... | 11 | assert | numeric_literal | tests/test_lenses.py | test_tuned_lens_generate_smoke | 145 | null | |
AlignmentResearch/tuned-lens | import numpy as np
from tuned_lens.utils import tensor_hash
def test_tensor_hash():
random = np.random.default_rng(42)
a = random.normal(size=(10, 1000)).astype(np.float32)
b = random.normal(size=(10, 1000)).astype(np.float32)
assert tensor_hash(a) != tensor_hash(b)
assert tensor_hash(a) == | tensor_hash(a) | assert | func_call | tests/test_utils.py | test_tensor_hash | 11 | null | |
AlignmentResearch/tuned-lens | import numpy as np
from tuned_lens.utils import tensor_hash
def test_tensor_hash():
random = np.random.default_rng(42)
a = random.normal(size=(10, 1000)).astype(np.float32)
b = random.normal(size=(10, 1000)).astype(np.float32)
assert tensor_hash(a) != | tensor_hash(b) | assert | func_call | tests/test_utils.py | test_tensor_hash | 10 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
from plotly import graph_objects as go
from tuned_lens.plotting.trajectory_plotting import (
TrajectoryLabels,
TrajectoryStatistic,
_stride_keep_last,
)
def test_trajectory_statistic_post_init():
stats = np.zeros((2, 2), dtype=float)
trajectory_labels = TrajectoryL... | None | assert | none_literal | tests/plotting/test_trajectory_plotting.py | test_trajectory_statistic_post_init | 45 | null | |
AlignmentResearch/tuned-lens | import warnings
from pathlib import Path
import pytest
from tuned_lens.__main__ import main
def test_eval_subcommand_fails_when_not_enough_data_given(
text_dataset_path: Path, gpt2_tiny_random_model_local_path: Path, tmp_path: Path
):
args = (
f"--log_level DEBUG eval --data.name {text_dataset_path}"... | ValueError, match="Requested to evaluate on") | pytest.raises | complex_expr | tests/scripts/test_integration.py | test_eval_subcommand_fails_when_not_enough_data_given | 44 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
import torch as th
import transformer_lens as tl
from transformers import AutoModelForCausalLM, AutoTokenizer
from tuned_lens.nn.lenses import LogitLens, TunedLens, Unembed
from tuned_lens.plotting import PredictionTrajectory
from tuned_lens.plotting.prediction_trajectory import _selec... | None | assert | none_literal | tests/plotting/test_prediction_trajectory.py | test_largest_prob_labels_smoke | 116 | null | |
AlignmentResearch/tuned-lens | import torch as th
import transformers as tr
from tuned_lens.model_surgery import get_final_norm
from tuned_lens.nn import Unembed
def back_translate(unembed: Unembed, h: th.Tensor, tol: float = 1e-4) -> th.Tensor:
"""Project hidden states into logits and then back into hidden states."""
scale = h.norm(dim=-1... | unembed(x_hat).softmax(-1)) | assert_* | func_call | tests/test_unembed.py | test_correctness | 31 | null | |
AlignmentResearch/tuned-lens | import numpy as np
import pytest
from plotly import graph_objects as go
from tuned_lens.plotting.trajectory_plotting import (
TrajectoryLabels,
TrajectoryStatistic,
_stride_keep_last,
)
def test_template_and_customdata():
n_layers = 2
seq_len = 1
trajectory_labels = TrajectoryLabels(
l... | "%{customdata[0]}%{customdata[1]}" "<br>%{customdata[2]}%{customdata[3]}<br>" "<extra></extra>" | assert | string_literal | tests/plotting/test_trajectory_plotting.py | test_template_and_customdata | 80 | null | |
AlignmentResearch/tuned-lens | import pytest
import torch as th
from transformers import PreTrainedModel
from tuned_lens import model_surgery
def test_get_final_layer_norm_raises(opt_random_model: PreTrainedModel):
opt_random_model.base_model.decoder.final_layer_norm = None
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_model_surgery.py | test_get_final_layer_norm_raises | 10 | null | |
AlignmentResearch/tuned-lens | import pytest
import torch as th
from tuned_lens.causal import remove_subspace
@pytest.mark.parametrize("d", list(range(1, 1000, 100)))
def test_remove_subspace(d: int):
a = th.randn(10, d, dtype=th.float64)
for k in range(1, d, 10):
b = th.randn(d, k, dtype=th.float64)
inner = a @ b
... | th.zeros_like(inner_)) | assert_* | func_call | tests/test_subspaces.py | test_remove_subspace | 17 | null | |
AlignmentResearch/tuned-lens | import numpy as np
from tuned_lens.utils import tensor_hash
def test_tensor_hash():
random = np.random.default_rng(42)
a = random.normal(size=(10, 1000)).astype(np.float32)
b = random.normal(size=(10, 1000)).astype(np.float32)
assert tensor_hash(a) != tensor_hash(b)
assert tensor_hash(a) == tensor... | tensor_hash(a.astype(np.float16)) | assert | func_call | tests/test_utils.py | test_tensor_hash | 12 | null | |
AlignmentResearch/tuned-lens | import random
import torch as th
from torch.distributions import Dirichlet, kl_divergence
from tuned_lens.stats import LogitStats
def test_logit_stats_correctness():
"""Test that `LogitStats` recovers the true Dirichlet within a small error."""
th.manual_seed(42)
x = Dirichlet(th.tensor([1.0, 1.0, 1.0])... | 1e-3 | assert | numeric_literal | tests/test_stats.py | test_logit_stats_correctness | 22 | null | |
AlignmentResearch/tuned-lens | from pathlib import Path
import mock
import pytest
import torch as th
import transformers as trf
from tuned_lens.load_artifacts import load_lens_artifacts
from tuned_lens.nn.lenses import LogitLens, TunedLens, TunedLensConfig
from tuned_lens.nn.unembed import Unembed
def model_config():
config = mock.MagicMock(t... | TypeError) | pytest.raises | variable | tests/test_lenses.py | test_from_model_and_pretrained_propogates_kwargs | 118 | null | |
AlignmentResearch/tuned-lens | import pytest
from tuned_lens.load_artifacts import available_lens_artifacts, load_lens_artifacts
def test_list_available_lens_artifacts_smoke():
artifacts = available_lens_artifacts("AlignmentResearch/tuned-lens", "space")
assert len(artifacts) > 0
with pytest.raises( | FileNotFoundError) | pytest.raises | variable | tests/test_load_artifact.py | test_list_available_lens_artifacts_smoke | 18 | null | |
AlignmentResearch/tuned-lens | import torch as th
import transformers as tr
from tuned_lens.model_surgery import get_final_norm
from tuned_lens.nn import Unembed
def back_translate(unembed: Unembed, h: th.Tensor, tol: float = 1e-4) -> th.Tensor:
"""Project hidden states into logits and then back into hidden states."""
scale = h.norm(dim=-1... | unembed(x).log_softmax(-1)) | assert_* | func_call | tests/test_unembed.py | test_correctness | 28 | null | |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import TextResponse
from pystock_crawler.spiders.yahoo import make_url, YahooSpider
from pystock_crawler.tests.base import TestCaseBase
class YahooSpiderTest(TestCaseBase):
def test_parse(self):
spider = YahooSpider()
body = ('Date,Open,High,Low,Close,... | { 'symbol': 'YHOO', 'date': '2013-11-22', 'open': 121.58, 'high': 122.75, 'low': 117.93, 'close': 121.38, 'volume': 11096700, 'adj_close': 121.38 }) | assert_* | collection | pystock_crawler/tests/test_spiders_yahoo.py | test_parse | YahooSpiderTest | 83 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | { 'symbol': 'QEP', 'amend': False, 'doc_type': '10-Q', 'period_focus': 'Q2', 'fiscal_year': 2011, 'end_date': '2011-06-30', 'revenues': 784100000, 'op_income': 168900000, 'net_income': 92800000, 'eps_basic': 0.52, 'eps_diluted': 0.52, 'dividend': 0.02, 'assets': 7075000000, 'cur_assets': 655600000, 'cur_liab': 58290000... | assert_* | collection | pystock_crawler/tests/test_loaders.py | test_qep_20110630 | ReportItemLoaderTest | 2,959 | null |
eliangcs/pystock-crawler | import cStringIO
import os
from pystock_crawler import utils
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
class UtilsTest(TestCaseBase):
def test_parse_csv(self):
f = cStringIO.StringIO('name,age\nAvon,30\nOmar,29\nJoe,45\n')
items = list(utils.parse_csv(f))
self.... | [ { 'name': 'Avon', 'age': '30' }, { 'name': 'Omar', 'age': '29' }, { 'name': 'Joe', 'age': '45' } ]) | self.assertEqual | collection | pystock_crawler/tests/test_utils.py | test_parse_csv | UtilsTest | 55 | null |
eliangcs/pystock-crawler | import cStringIO
import os
from pystock_crawler import utils
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
class UtilsTest(TestCaseBase):
def test_parse_limit_arg(self):
self.assertEqual(utils.parse_limit_arg(''), (0, None))
self.assertEqual(utils.parse_limit_arg('11,22'),... | (11, 22)) | self.assertEqual | collection | pystock_crawler/tests/test_utils.py | test_parse_limit_arg | UtilsTest | 33 | null |
eliangcs/pystock-crawler | import cStringIO
import os
from pystock_crawler import utils
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
class UtilsTest(TestCaseBase):
def test_parse_limit_arg(self):
self.assertEqual(utils.parse_limit_arg(''), (0, None))
self.assertEqual(utils.parse_limit_arg('11,22'), ... | ValueError) | self.assertRaises | variable | pystock_crawler/tests/test_utils.py | test_parse_limit_arg | UtilsTest | 35 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | { 'symbol': 'NFLX', 'amend': False, 'doc_type': '10-Q', 'period_focus': 'Q3', 'fiscal_year': 2012, 'end_date': '2012-09-30', 'revenues': 905089000, 'op_income': 16135000, 'net_income': 7675000, 'eps_basic': 0.14, 'eps_diluted': 0.13, 'dividend': 0.0, 'assets': 3808833000, 'cur_assets': 2225018000, 'cur_liab': 159822300... | assert_* | collection | pystock_crawler/tests/test_loaders.py | test_nflx_20120930 | ReportItemLoaderTest | 2,683 | null |
eliangcs/pystock-crawler | import os
import unittest
SAMPLE_DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sample_data')
class TestCaseBase(unittest.TestCase):
def assert_none_or_almost_equal(self, value, expected_value):
if expected_value is None:
self.assertIsNone(value)
else:
... | expected.get('name')) | self.assertEqual | func_call | pystock_crawler/tests/base.py | assert_item | TestCaseBase | 22 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | { 'symbol': 'SPEX', 'amend': False, 'doc_type': '10-Q', 'period_focus': 'Q1', 'fiscal_year': 2013, 'end_date': '2013-03-31', 'revenues': 5761, 'op_income': -910547, 'net_income': -3696570, 'eps_basic': -5.35, 'eps_diluted': None, 'dividend': 0.0, 'assets': 3572989, 'cur_assets': 3535555, 'cur_liab': 453858, 'equity': 2... | assert_* | collection | pystock_crawler/tests/test_loaders.py | test_spex_20130331 | ReportItemLoaderTest | 3,159 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import TextResponse
from pystock_crawler.spiders.yahoo import make_url, YahooSpider
from pystock_crawler.tests.base import TestCaseBase
class MakeURLTest(TestCaseBase):
def test_only_start_date(self):
self | 'http://ichart.finance.yahoo.com/table.csv?' 's=GOOG&d=&e=&f=&g=d&a=10&b=22&c=2013&ignore=.csv') | self.assertEqual | string_literal | pystock_crawler/tests/test_spiders_yahoo.py | test_only_start_date | MakeURLTest | 19 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import HtmlResponse, XmlResponse
from pystock_crawler.spiders.edgar import EdgarSpider, URLGenerator
from pystock_crawler.tests.base import TestCaseBase
def make_url(symbol, start_date='', end_date=''):
'''A URL that lists all 10-Q and 10-K filings of a company.'''
... | []) | self.assertEqual | collection | pystock_crawler/tests/test_spiders_edgar.py | test_empty_creation | EdgarSpiderTest | 57 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import TextResponse
from pystock_crawler.spiders.yahoo import make_url, YahooSpider
from pystock_crawler.tests.base import TestCaseBase
class MakeURLTest(TestCaseBase):
def test_start_and_end_dates(self):
self | 'http://ichart.finance.yahoo.com/table.csv?' 's=TSLA&d=10&e=22&f=2013&g=d&a=2&b=5&c=2012&ignore=.csv') | self.assertEqual | string_literal | pystock_crawler/tests/test_spiders_yahoo.py | test_start_and_end_dates | MakeURLTest | 31 | null |
eliangcs/pystock-crawler | from scrapy.http import TextResponse
from pystock_crawler.spiders.nasdaq import NasdaqSpider
from pystock_crawler.tests.base import TestCaseBase
class NasdaqSpiderTest(TestCaseBase):
def test_parse(self):
spider = NasdaqSpider()
body = ('"Symbol","Name","Doesnt Matter",\n'
'"DDD"... | 3) | self.assertEqual | numeric_literal | pystock_crawler/tests/test_spiders_nasdaq.py | test_parse | NasdaqSpiderTest | 22 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import HtmlResponse, XmlResponse
from pystock_crawler.spiders.edgar import EdgarSpider, URLGenerator
from pystock_crawler.tests.base import TestCaseBase
def make_url(symbol, start_date='', end_date=''):
'''A URL that lists all 10-Q and 10-K filings of a company.'''
... | [ make_url('AAPL', start_date='20120215'), make_url('AMZN', start_date='20120215'), make_url('GLD', start_date='20120215') ]) | self.assertEqual | collection | pystock_crawler/tests/test_spiders_edgar.py | test_with_start_date | URLGeneratorTest | 30 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | { 'symbol': 'IHC', 'amend': False, 'doc_type': '10-Q', 'period_focus': 'Q1', 'fiscal_year': 2012, 'end_date': '2012-03-31', 'revenues': 102156000, 'op_income': 6416000, 'net_income': 3922000, 'eps_basic': 0.22, 'eps_diluted': 0.22, 'dividend': 0.0, 'assets': 1364411000, 'cur_assets': None, 'cur_liab': None, 'equity': 2... | assert_* | collection | pystock_crawler/tests/test_loaders.py | test_ihc_20120331 | ReportItemLoaderTest | 1,730 | null |
eliangcs/pystock-crawler | from scrapy.http import TextResponse
from pystock_crawler.spiders.nasdaq import NasdaqSpider
from pystock_crawler.tests.base import TestCaseBase
class NasdaqSpiderTest(TestCaseBase):
def test_parse(self):
spider = NasdaqSpider()
body = ('"Symbol","Name","Doesnt Matter",\n'
'"DDD"... | { 'symbol': 'VNO', 'name': 'Vornado Realty Trust' }) | assert_* | collection | pystock_crawler/tests/test_spiders_nasdaq.py | test_parse | NasdaqSpiderTest | 27 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import HtmlResponse, XmlResponse
from pystock_crawler.spiders.edgar import EdgarSpider, URLGenerator
from pystock_crawler.tests.base import TestCaseBase
def make_url(symbol, start_date='', end_date=''):
'''A URL that lists all 10-Q and 10-K filings of a company.'''
... | [ make_url('T', '20110101', '20130630'), make_url('CBS', '20110101', '20130630'), make_url('WMT', '20110101', '20130630') ]) | self.assertEqual | collection | pystock_crawler/tests/test_spiders_edgar.py | test_symbol_file_and_dates | EdgarSpiderTest | 91 | null |
eliangcs/pystock-crawler | from scrapy.http import TextResponse
from pystock_crawler.spiders.nasdaq import NasdaqSpider
from pystock_crawler.tests.base import TestCaseBase
class NasdaqSpiderTest(TestCaseBase):
def test_parse(self):
spider = NasdaqSpider()
body = ('"Symbol","Name","Doesnt Matter",\n'
'"DDD"... | { 'symbol': 'DDD', 'name': '3D Systems Corporation' }) | assert_* | collection | pystock_crawler/tests/test_spiders_nasdaq.py | test_parse | NasdaqSpiderTest | 23 | null |
eliangcs/pystock-crawler | import os
import unittest
SAMPLE_DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sample_data')
class TestCaseBase(unittest.TestCase):
def assert_none_or_almost_equal(self, value, expected_value):
if expected_value is None:
self.assertIsNone(value)
else:
... | expected.get('amend')) | self.assertEqual | func_call | pystock_crawler/tests/base.py | assert_item | TestCaseBase | 23 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import HtmlResponse, XmlResponse
from pystock_crawler.spiders.edgar import EdgarSpider, URLGenerator
from pystock_crawler.tests.base import TestCaseBase
def make_url(symbol, start_date='', end_date=''):
'''A URL that lists all 10-Q and 10-K filings of a company.'''
... | [ 'http://sec.gov/Archives/edgar/data/abc-index.htm', 'http://sec.gov/Archives/edgar/data/123-index.htm', 'http://sec.gov/Archives/edgar/data/123/abc-index.htm', 'http://sec.gov/Archives/edgar/data/123/456/abc123-index.htm', 'http://sec.gov/Archives/edgar/data/123/456/789/HELLO-index.htm' ]) | self.assertEqual | collection | pystock_crawler/tests/test_spiders_edgar.py | test_parse_company_filing_page | EdgarSpiderTest | 128 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | item) | self.assertFalse | variable | pystock_crawler/tests/test_loaders.py | test_adbe_20060914 | ReportItemLoaderTest | 199 | null |
eliangcs/pystock-crawler | import os
import requests
import urlparse
from scrapy.http.response.xml import XmlResponse
from pystock_crawler.loaders import ReportItemLoader
from pystock_crawler.tests.base import SAMPLE_DATA_DIR, TestCaseBase
def create_response(file_path):
with open(file_path) as f:
body = f.read()
return XmlRes... | { 'symbol': 'AIG', 'amend': False, 'doc_type': '10-Q', 'period_focus': 'Q2', 'fiscal_year': 2013, 'end_date': '2013-06-30', 'revenues': 17315000000, 'net_income': 2731000000, 'op_income': None, 'eps_basic': 1.85, 'eps_diluted': 1.84, 'dividend': 0.0, 'assets': 537438000000, 'cur_assets': None, 'cur_liab': None, 'equity... | assert_* | collection | pystock_crawler/tests/test_loaders.py | test_aig_20130630 | ReportItemLoaderTest | 253 | null |
eliangcs/pystock-crawler | import os
import tempfile
from scrapy.http import TextResponse
from pystock_crawler.spiders.yahoo import make_url, YahooSpider
from pystock_crawler.tests.base import TestCaseBase
class MakeURLTest(TestCaseBase):
def test_only_end_date(self):
self | 'http://ichart.finance.yahoo.com/table.csv?' 's=AAPL&d=10&e=22&f=2013&g=d&a=&b=&c=&ignore=.csv') | self.assertEqual | string_literal | pystock_crawler/tests/test_spiders_yahoo.py | test_only_end_date | MakeURLTest | 25 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.