# Path: tests/helpers.py
# def assert_df_equal(df1, df2):
# 
#     print("-"*100)
#     print("df1")
#     print(df1)
#     print("df2")
#     print(df2)
# 
#     # df1.loc[:, "Start"] = df1.Start.astype(np.int64)
#     # df2.loc[:, "Start"] = df1.Start.astype(np.int64)
#     # df1.loc[:, "End"] = df1.End.astype(np.int64)
#     # df2.loc[:, "End"] = df1.End.astype(np.int64)
# 
#     pd.options.mode.chained_assignment = None
#     if "Strand" in df1 and "Strand" in df2:
#         sort_on = "Chromosome Start End Strand".split()
#         df1.Strand = df1.Strand.astype("object")
#         df2.Strand = df2.Strand.astype("object")
#     else:
#         sort_on = "Chromosome Start End".split()
# 
#     if "Strand_b" in df1:
#         sort_on += "Start_b End_b Strand_b".split()
#         df1.Strand_b = df1.Strand_b.astype("object")
#         df2.Strand_b = df2.Strand_b.astype("object")
#     elif "Start_b" in df2:
#         sort_on += "Start_b End_b".split()
# 
#     df1 = df1.sort_values(sort_on)
#     df2 = df2.sort_values(sort_on)
# 
#     df1 = df1.reset_index(drop=True)
#     df2 = df2.reset_index(drop=True)
# 
#     df1.Chromosome = df1.Chromosome.astype("object")
#     df2.Chromosome = df2.Chromosome.astype("object")
# 
#     print("Actual")
#     print(df1.to_csv(sep=" "))
#     print("Expected")
#     print(df2.to_csv(sep=" "))
# 
#     print("Actual dtypes")
#     print(df1.dtypes)
#     print("Expected dtypes")
#     print(df2.dtypes)
#     # print("dtypes Strand\n", "1",  df1.Strand.dtype, "2", df2.Strand.dtype)
#     # print("dtypes Strand\n", df1.Strand.dtype == df2.Strand.dtype)
#     # print("dtypes equal\n", df1.dtypes == df2.dtypes)
# 
#     print("Actual index")
#     print(df1.index)
#     print("Expected index")
#     print(df2.index)
#     print("index equal", df1.index == df2.index)
# 
#     pd.testing.assert_frame_equal(df1, df2)
# 
#     pd.options.mode.chained_assignment = "warn"
# 
# Path: tests/hypothesis_helper.py
# def dfs_min2(draw):  # nosec
# def dfs_min(draw):  # nosec
# def dfs_no_min(draw):  # nosec
# def dfs_min_with_id(draw):  # nosec
# def dfs_min_with_gene_id(draw):  # nosec
# def df_data(draw):
# def dfs_min_single_chromosome(draw):
# def genomicfeature(draw):
# def selector(draw):


import pytest
import tempfile
import subprocess  # nosec
import numpy as np
import pandas as pd
import pyranges as pr
from natsort import natsorted
from hypothesis import given, settings, HealthCheck  #, assume
from hypothesis import reproduce_failure  # pylint: disable=unused-import
from io import StringIO
from tests.helpers import assert_df_equal
from tests.hypothesis_helper import dfs_min, df_data, selector, dfs_min_with_id, max_examples, deadline
    deadline=deadline,
    suppress_health_check=HealthCheck.all())
@given(gr=df_data())  # pylint: disable=no-value-for-parameter
def test_init(gr, strand):

    c, s, e, strands = gr

    if strand:
        pr.PyRanges(chromosomes=c, starts=s, ends=e, strands=strands)
    else:
        pr.PyRanges(chromosomes=c, starts=s, ends=e)


chipseq = pr.data.chipseq()


@settings(
    max_examples=max_examples,
    deadline=deadline,
    suppress_health_check=HealthCheck.all())
@given(selector=selector())  # pylint: disable=no-value-for-parameter
def test_getitem(selector):

    # have these weird returns to avoid being flagged as unused code
    if len(selector) == 3:
        a, b, c = selector
        return chipseq[a, b, c]
    elif len(selector) == 2:
        a, b = selector
        return chipseq[a, b]

# Path: tests/helpers.py
# def assert_df_equal(df1, df2):
# 
#     print("-"*100)
#     print("df1")
#     print(df1)
#     print("df2")
#     print(df2)
# 
#     # df1.loc[:, "Start"] = df1.Start.astype(np.int64)
#     # df2.loc[:, "Start"] = df1.Start.astype(np.int64)
#     # df1.loc[:, "End"] = df1.End.astype(np.int64)
#     # df2.loc[:, "End"] = df1.End.astype(np.int64)
# 
#     pd.options.mode.chained_assignment = None
#     if "Strand" in df1 and "Strand" in df2:
#         sort_on = "Chromosome Start End Strand".split()
#         df1.Strand = df1.Strand.astype("object")
#         df2.Strand = df2.Strand.astype("object")
#     else:
#         sort_on = "Chromosome Start End".split()
# 
#     if "Strand_b" in df1:
#         sort_on += "Start_b End_b Strand_b".split()
#         df1.Strand_b = df1.Strand_b.astype("object")
#         df2.Strand_b = df2.Strand_b.astype("object")
#     elif "Start_b" in df2:
#         sort_on += "Start_b End_b".split()
# 
#     df1 = df1.sort_values(sort_on)
#     df2 = df2.sort_values(sort_on)
# 
#     df1 = df1.reset_index(drop=True)
#     df2 = df2.reset_index(drop=True)
# 
#     df1.Chromosome = df1.Chromosome.astype("object")
#     df2.Chromosome = df2.Chromosome.astype("object")
# 
#     print("Actual")
#     print(df1.to_csv(sep=" "))
#     print("Expected")
#     print(df2.to_csv(sep=" "))
# 
#     print("Actual dtypes")
#     print(df1.dtypes)
#     print("Expected dtypes")
#     print(df2.dtypes)
#     # print("dtypes Strand\n", "1",  df1.Strand.dtype, "2", df2.Strand.dtype)
#     # print("dtypes Strand\n", df1.Strand.dtype == df2.Strand.dtype)
#     # print("dtypes equal\n", df1.dtypes == df2.dtypes)
# 
#     print("Actual index")
#     print(df1.index)
#     print("Expected index")
#     print(df2.index)
#     print("index equal", df1.index == df2.index)
# 
#     pd.testing.assert_frame_equal(df1, df2)
# 
#     pd.options.mode.chained_assignment = "warn"
# 
# Path: tests/hypothesis_helper.py
# def dfs_min2(draw):  # nosec
# def dfs_min(draw):  # nosec
# def dfs_no_min(draw):  # nosec
# def dfs_min_with_id(draw):  # nosec
# def dfs_min_with_gene_id(draw):  # nosec
# def df_data(draw):
# def dfs_min_single_chromosome(draw):
# def genomicfeature(draw):
# def selector(draw):


# Path: tests/test_unary.py
import pytest
import tempfile
import subprocess  # nosec
import numpy as np
import pandas as pd
import pyranges as pr
from natsort import natsorted
from hypothesis import given, settings, HealthCheck  #, assume
from hypothesis import reproduce_failure  # pylint: disable=unused-import
from io import StringIO
from tests.helpers import assert_df_equal
from tests.hypothesis_helper import dfs_min, df_data, selector, dfs_min_with_id, max_examples, deadline

    deadline=deadline,
    suppress_health_check=HealthCheck.all())
@given(gr=df_data())  # pylint: disable=no-value-for-parameter
def test_init(gr, strand):

    c, s, e, strands = gr

    if strand:
        pr.PyRanges(chromosomes=c, starts=s, ends=e, strands=strands)
    else:
        pr.PyRanges(chromosomes=c, starts=s, ends=e)


chipseq = pr.data.chipseq()


@settings(
    max_examples=max_examples,
    deadline=deadline,
    suppress_health_check=HealthCheck.all())
@given(selector=selector())  # pylint: disable=no-value-for-parameter
def test_getitem(selector):

    # have these weird returns to avoid being flagged as unused code
    if len(selector) == 3:
        a, b, c = selector
        return chipseq[a, b, c]
    elif len(selector) == 2:
        a, b = selector
        return chipseq[a, b]

    elif len(selector) == 1: