<commit_before>import pytest
from hypothesis import given
from hypothesis.extra.pandas import data_frames, columns, range_indexes
import hypothesis.strategies as st

from itertools import product

def mysort(tp):

    if tp[1] == tp[2]:
        tp = (tp[0], tp[1], tp[2] + 1, tp[3])

    key = [-1, tp[1], tp[2], int(1e10)]

    return [x for _, x in sorted(zip(key, tp))]

chromosomes = st.sampled_from(["chr{}".format(str(e)) for e in list(range(1, 23)) + "X Y M".split()])

positions = st.integers(min_value=0, max_value=int(1e7))
strands = st.sampled_from("+ -".split())
dfs = data_frames(columns=columns("Chromosome Start End Strand".split(),
                                  dtype=int), rows=st.tuples(chromosomes, positions, positions,
                                                             strands).map(mysort))
df_minsize = 25
large_dfs = data_frames(index=range_indexes(min_size=df_minsize),
                        columns=columns("Chromosome Start End Strand".split(), dtype=int),
                        rows=st.tuples(chromosomes, positions, positions, strands).map(mysort))

import pyranges as pr
import pandas as pd


df_large_or_small = st.one_of(dfs, large_dfs)

strandedness = [False, "same", "opposite"]
methods = ["set_intersection", "subtraction", "join", "intersection", "overlap"]

@settings(deadline=300)
@pytest.mark.parametrize("strandedness,method", product(strandedness, methods))
@given(df=dfs, df2=dfs)
def test_methods(df, df2, strandedness, method):

    gr = pr.PyRanges(df)
    gr2 = pr.PyRanges(df2)

    method = getattr(gr, method)
    result = method(gr2, strandedness=strandedness)

    assert isinstance(result, pr.PyRanges)

how = [False, "nonoverlapping", "previous_nonoverlapping", "next_nonoverlapping", "next", "previous"]

@settings(deadline=300)
@pytest.mark.parametrize("strandedness,how", product(strandedness, how))
@given(df=dfs, df2=dfs)
def test_nearest_methods_dont_fail(df, df2, strandedness, how):

    gr = pr.PyRanges(df)
    gr2 = pr.PyRanges(df2)

    result = gr.nearest(gr2, strandedness=strandedness, how=how)

    assert isinstance(result, pr.PyRanges)<commit_msg>Fix hypothesis by adding missing import<commit_after>import pytest
from hypothesis import given, settings
from hypothesis.extra.pandas import data_frames, columns, range_indexes
import hypothesis.strategies as st

from itertools import product

def mysort(tp):

    if tp[1] == tp[2]:
        tp = (tp[0], tp[1], tp[2] + 1, tp[3])

    key = [-1, tp[1], tp[2], int(1e10)]

    return [x for _, x in sorted(zip(key, tp))]

chromosomes = st.sampled_from(["chr{}".format(str(e)) for e in list(range(1, 23)) + "X Y M".split()])

positions = st.integers(min_value=0, max_value=int(1e7))
strands = st.sampled_from("+ -".split())
dfs = data_frames(columns=columns("Chromosome Start End Strand".split(),
                                  dtype=int), rows=st.tuples(chromosomes, positions, positions,
                                                             strands).map(mysort))
df_minsize = 25
large_dfs = data_frames(index=range_indexes(min_size=df_minsize),
                        columns=columns("Chromosome Start End Strand".split(), dtype=int),
                        rows=st.tuples(chromosomes, positions, positions, strands).map(mysort))

import pyranges as pr
import pandas as pd


df_large_or_small = st.one_of(dfs, large_dfs)

strandedness = [False, "same", "opposite"]
methods = ["set_intersection", "subtraction", "join", "intersection", "overlap"]

@pytest.mark.parametrize("strandedness,method", product(strandedness, methods))
@settings(deadline=300)
@given(df=dfs, df2=dfs)
def test_methods(df, df2, strandedness, method):

    gr = pr.PyRanges(df)
    gr2 = pr.PyRanges(df2)

    method = getattr(gr, method)
    result = method(gr2, strandedness=strandedness)

    assert isinstance(result, pr.PyRanges)

how = [False, "nonoverlapping", "previous_nonoverlapping", "next_nonoverlapping", "next", "previous"]

@pytest.mark.parametrize("strandedness,how", product(strandedness, how))
@settings(deadline=300)
@given(df=dfs, df2=dfs)
def test_nearest_methods_dont_fail(df, df2, strandedness, how):

    gr = pr.PyRanges(df)
    gr2 = pr.PyRanges(df2)

    result = gr.nearest(gr2, strandedness=strandedness, how=how)

    assert isinstance(result, pr.PyRanges)
{'fraction_non_alphanumeric': 0.13950789229340763, 'fraction_numerical': 0.017177344475394613, 'mean_word_length': 4.016298020954598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1970732', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1476, 'n_words': 317}