project
stringclasses
17 values
bug_id
int64
1
169
buggy
stringlengths
81
57.2k
fixed
stringlengths
85
31.2k
test_command
stringlengths
44
133
pandas
23
class DatetimeTimedeltaMixin(DatetimeIndexOpsMixin, Int64Index): start = right[0] if end < start: return type(self)(data=[]) else: lslice = slice(*left.slice_locs(start, end)) left_chunk = left.values[lslice] return self._shallow_copy(left_chunk) ...
class DatetimeTimedeltaMixin(DatetimeIndexOpsMixin, Int64Index): start = right[0] if end < start: return type(self)(data=[], dtype=self.dtype, freq=self.freq) else: lslice = slice(*left.slice_locs(start, end)) left_chunk = left._values[lslice] ret...
pytest pandas/tests/indexes/datetimes/test_setops.py::TestCustomDatetimeIndex::test_intersection_bug
pandas
23
class TestGetItem: def test_dti_business_getitem(self): rng = pd.bdate_range(START, END) smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq
class TestGetItem: def test_dti_business_getitem(self): rng = pd.bdate_range(START, END) smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5], freq="B") tm.assert_index_equal(smaller, exp) assert smaller.freq == exp.freq assert smaller.freq == rng.freq
pytest pandas/tests/indexes/datetimes/test_setops.py::TestCustomDatetimeIndex::test_intersection_bug
pandas
23
class TestGetItem: def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq="C") smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5]) tm.assert_index_equal(smaller, exp) assert smaller.freq == rng.freq sliced = rng[::5]
class TestGetItem: def test_dti_custom_getitem(self): rng = pd.bdate_range(START, END, freq="C") smaller = rng[:5] exp = DatetimeIndex(rng.view(np.ndarray)[:5], freq="C") tm.assert_index_equal(smaller, exp) assert smaller.freq == exp.freq assert smaller.freq == rng.fr...
pytest pandas/tests/indexes/datetimes/test_setops.py::TestCustomDatetimeIndex::test_intersection_bug
PySnooper
1
import inspect import sys PY3 = (sys.version_info[0] == 3) if hasattr(abc, 'ABC'): ABC = abc.ABC
import inspect import sys PY3 = (sys.version_info[0] == 3) PY2 = not PY3 if hasattr(abc, 'ABC'): ABC = abc.ABC
pytest -q -s tests/test_chinese.py::test_chinese
PySnooper
1
import traceback from .variables import CommonVariable, Exploding, BaseVariable from . import utils, pycompat ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
import traceback from .variables import CommonVariable, Exploding, BaseVariable from . import utils, pycompat if pycompat.PY2: from io import open ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
pytest -q -s tests/test_chinese.py::test_chinese
PySnooper
1
def get_source_from_frame(frame): # apply tokenize.detect_encoding to decode the source into a # string, then we should do that ourselves. if isinstance(source[0], bytes): encoding = 'ascii' for line in source[:2]: # File coding may be specified. Match pattern from PEP-263 ...
def get_source_from_frame(frame): # apply tokenize.detect_encoding to decode the source into a # string, then we should do that ourselves. if isinstance(source[0], bytes): encoding = 'utf-8' for line in source[:2]: # File coding may be specified. Match pattern from PEP-263 ...
pytest -q -s tests/test_chinese.py::test_chinese
PySnooper
1
class FileWriter(object): self.overwrite = overwrite def write(self, s): with open(self.path, 'w' if self.overwrite else 'a') as output_file: output_file.write(s) self.overwrite = False
class FileWriter(object): self.overwrite = overwrite def write(self, s): with open(self.path, 'w' if self.overwrite else 'a', encoding='utf-8') as output_file: output_file.write(s) self.overwrite = False
pytest -q -s tests/test_chinese.py::test_chinese
PySnooper
1
def assert_output(output, expected_entries, prefix=None): any_mismatch = False result = '' template = '\n{line!s:%s} {expected_entry} {arrow}' % max(map(len, lines)) for expected_entry, line in zip_longest(expected_entries, lines, fillvalue=""): mismatch = not (expected_entry and expected_en...
def assert_output(output, expected_entries, prefix=None): any_mismatch = False result = '' template = u'\n{line!s:%s} {expected_entry} {arrow}' % max(map(len, lines)) for expected_entry, line in zip_longest(expected_entries, lines, fillvalue=""): mismatch = not (expected_entry and expected_e...
pytest -q -s tests/test_chinese.py::test_chinese
PySnooper
1
def assert_sample_output(module): with sys_tools.OutputCapturer(stdout=False, stderr=True) as output_capturer: module.main() time = '21:10:42.298924' time_pattern = re.sub(r'\d', r'\\d', time)
def assert_sample_output(module): with sys_tools.OutputCapturer(stdout=False, stderr=True) as output_capturer: module.main() time = '21:10:42.298924' time_pattern = re.sub(r'\d', r'\\d', time)
pytest -q -s tests/test_chinese.py::test_chinese
scrapy
17
def get_meta_refresh(response): def response_status_message(status): """Return status code plus status text descriptive message >>> response_status_message(200) '200 OK' >>> response_status_message(404) '404 Not Found' """ return '%s %s' % (status, to_native_str(http.RESPONSES.get(int(sta...
def get_meta_refresh(response): def response_status_message(status): """Return status code plus status text descriptive message """ return '%s %s' % (status, to_native_str(http.RESPONSES.get(int(status), "Unknown Status"))) def response_httprepr(response):
python -m unittest -q tests.test_utils_response.ResponseUtilsTest.test_response_status_message
luigi
2
class BeamDataflowJobTask(MixinNaiveBulkComplete, luigi.Task): def __init__(self): if not isinstance(self.dataflow_params, DataflowParamKeys): raise ValueError("dataflow_params must be of type DataflowParamKeys") @abstractmethod def dataflow_executable(self):
class BeamDataflowJobTask(MixinNaiveBulkComplete, luigi.Task): def __init__(self): if not isinstance(self.dataflow_params, DataflowParamKeys): raise ValueError("dataflow_params must be of type DataflowParamKeys") super(BeamDataflowJobTask, self).__init__() @abstractmethod def da...
pytest test/contrib/beam_dataflow_test.py::BeamDataflowTest::test_get_target_path
luigi
2
class BeamDataflowJobTask(MixinNaiveBulkComplete, luigi.Task): @staticmethod def get_target_path(target): if isinstance(target, luigi.LocalTarget) or isinstance(target, gcs.GCSTarget): return target.path elif isinstance(target, bigquery.BigQueryTarget): "{}:{}.{}".format...
class BeamDataflowJobTask(MixinNaiveBulkComplete, luigi.Task): @staticmethod def get_target_path(target): """ Given a luigi Target, determine a stringly typed path to pass as a Dataflow job argument. """ if isinstance(target, luigi.LocalTarget) or isinstance(targ...
pytest test/contrib/beam_dataflow_test.py::BeamDataflowTest::test_get_target_path
keras
24
class TensorBoard(Callback): tf.summary.image(mapped_weight_name, w_img) if hasattr(layer, 'output'): tf.summary.histogram('{}_out'.format(layer.name), layer.output) self.merged = tf.summary.merge_all() ...
class TensorBoard(Callback): tf.summary.image(mapped_weight_name, w_img) if hasattr(layer, 'output'): if isinstance(layer.output, list): for i, output in enumerate(layer.output): tf.summary.histogram('{}_out...
pytest tests/keras/test_callbacks.py::test_TensorBoard_multi_input_output
spacy
3
logger = logging.getLogger(__name__) title_regex = re.compile(r"(?<=<title>).*(?=</title>)") id_regex = re.compile(r"(?<=<id>)\d*(?=</id>)") text_regex = re.compile(r"(?<=<text xml:space=\"preserve\">).*(?=</text)") info_regex = re.compile(r"{[^{]*?}") html_regex = re.compile(r"&lt;!--[^-]*--&gt;") ref_regex = re.comp...
logger = logging.getLogger(__name__) title_regex = re.compile(r"(?<=<title>).*(?=</title>)") id_regex = re.compile(r"(?<=<id>)\d*(?=</id>)") text_tag_regex = re.compile(r"(?<=<text).*?(?=>)") text_regex = re.compile(r"(?<=<text>).*(?=</text)") info_regex = re.compile(r"{[^{]*?}") html_regex = re.compile(r"&lt;!--[^-]*...
py.test spacy/tests/regression/test_issue5314.py::test_issue5314
spacy
3
def _process_wp_text(article_title, article_text, wp_to_id): return None, None # remove the text tags text_search = text_regex.search(article_text) if text_search is None: return None, None text = text_search.group(0)
def _process_wp_text(article_title, article_text, wp_to_id): return None, None # remove the text tags text_search = text_tag_regex.sub("", article_text) text_search = text_regex.search(text_search) if text_search is None: return None, None text = text_search.group(0)
py.test spacy/tests/regression/test_issue5314.py::test_issue5314