Skip to content

Commit

Permalink
Missed running black on test files
Browse files Browse the repository at this point in the history
  • Loading branch information
jrm5100 committed Oct 19, 2020
1 parent 610c353 commit f0472d9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 56 deletions.
48 changes: 25 additions & 23 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

# -- Project information -----------------------------------------------------

project = 'pandas-genomics'
copyright = '2020, John McGuigan'
author = 'John McGuigan'
project = "pandas-genomics"
copyright = "2020, John McGuigan"
author = "John McGuigan"

import pandas_genomics

# The short X.Y version.
version = pandas_genomics.__version__
# The full version, including alpha/beta/rc tags.
Expand All @@ -34,15 +35,15 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.githubpages',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'IPython.sphinxext.ipython_directive',
'IPython.sphinxext.ipython_console_highlighting',
'numpydoc',
'sphinx_copybutton'
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"IPython.sphinxext.ipython_directive",
"IPython.sphinxext.ipython_console_highlighting",
"numpydoc",
"sphinx_copybutton",
]

# Configuration options for plot_directive. See:
Expand All @@ -55,41 +56,42 @@
numpydoc_show_class_members = False

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
import sphinx_rtd_theme

html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_logo = '_static/logo.png'
html_logo = "_static/logo.png"
html_theme_options = {
'logo_only': True,
"logo_only": True,
}

# Custom sidebar templates, must be a dictionary that maps document names
Expand All @@ -98,8 +100,8 @@
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
]
}
64 changes: 41 additions & 23 deletions tests/genotype_array/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def all_boolean_reductions(request):
# Implement the required fixtures
@pytest.fixture
def dtype():
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
return GenotypeDtype(variant=variant)


Expand All @@ -79,11 +81,15 @@ def data():
* data[0] and data[1] should both be non missing
* data[0] and data[1] should not be equal
"""
alleles = ['A', 'T', 'G']
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
genotypes = [variant.make_genotype('A', 'T'), variant.make_genotype('T', 'T')]
alleles = ["A", "T", "G"]
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
genotypes = [variant.make_genotype("A", "T"), variant.make_genotype("T", "T")]
for i in range(98):
genotypes.append(variant.make_genotype(random.choice(alleles), random.choice(alleles)))
genotypes.append(
variant.make_genotype(random.choice(alleles), random.choice(alleles))
)
return GenotypeArray(values=genotypes)


Expand All @@ -97,8 +103,10 @@ def data_for_twos():
@pytest.fixture
def data_missing():
"""Length-2 array with [NA, Valid]"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
genotypes = [variant.make_genotype(), variant.make_genotype('T', 'T')]
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
genotypes = [variant.make_genotype(), variant.make_genotype("T", "T")]
return GenotypeArray(values=genotypes)


Expand All @@ -108,10 +116,12 @@ def data_for_sorting():
This should be three items [B, C, A] with
A < B < C
"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
a = variant.make_genotype('A', 'A')
b = variant.make_genotype('A', 'T')
c = variant.make_genotype('T', 'T')
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
a = variant.make_genotype("A", "A")
b = variant.make_genotype("A", "T")
c = variant.make_genotype("T", "T")
return GenotypeArray(values=[b, c, a])


Expand All @@ -121,9 +131,11 @@ def data_missing_for_sorting():
This should be three items [B, NA, A] with
A < B and NA missing.
"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
a = variant.make_genotype('A', 'A')
b = variant.make_genotype('A', 'T')
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
a = variant.make_genotype("A", "A")
b = variant.make_genotype("A", "T")
na = variant.make_genotype()
return GenotypeArray(values=[b, na, a])

Expand All @@ -141,7 +153,9 @@ def na_cmp():
@pytest.fixture
def na_value():
"""The scalar missing value for this type. Default 'None'"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
return variant.make_genotype()


Expand All @@ -151,10 +165,12 @@ def data_for_grouping():
Expected to be like [B, B, NA, NA, A, A, B, C]
Where A < B < C and NA is missing
"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T', 'G'])
a = variant.make_genotype('A', 'A')
b = variant.make_genotype('A', 'T')
c = variant.make_genotype('T', 'T')
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T", "G"]
)
a = variant.make_genotype("A", "A")
b = variant.make_genotype("A", "T")
c = variant.make_genotype("T", "T")
na = variant.make_genotype()
return GenotypeArray([b, b, na, na, a, a, b, c])

Expand All @@ -165,9 +181,11 @@ def data_for_encoding():
Contains one alt allele.
Variants are Homozygouse Ref, Heterozygous, Homozygous Alt, and Missing
"""
variant = Variant(chromosome='chr1', position=123456, id='rs12345', ref='A', alt=['T'])
a = variant.make_genotype('A', 'A')
b = variant.make_genotype('A', 'T')
c = variant.make_genotype('T', 'T')
variant = Variant(
chromosome="chr1", position=123456, id="rs12345", ref="A", alt=["T"]
)
a = variant.make_genotype("A", "A")
b = variant.make_genotype("A", "T")
c = variant.make_genotype("T", "T")
na = variant.make_genotype()
return GenotypeArray([a, b, c, na])
2 changes: 1 addition & 1 deletion tests/genotype_array/test_ExtensionArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class TestParsing(base.BaseParsingTests):


class TestMethods(base.BaseMethodsTests):

def test_combine_add(self, data_repeated):
"""Addition of Genotypes isn't valid"""
pass
Expand Down Expand Up @@ -65,6 +64,7 @@ class TestComparisonOps(base.BaseComparisonOpsTests):
class TestOpsUtil(base.BaseOpsUtil):
pass


# No way to invert a genotype
# class TestUnaryOps(base.BaseUnaryOpsTests):
# pass
Expand Down
26 changes: 18 additions & 8 deletions tests/genotype_array/test_GenotypeArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,53 @@ def test_encoding_extra_alt(data):

def test_encoding_additive(data_for_encoding):
# Test arrays directly
expected = pd.array([0, 1, 2, None], dtype='UInt8')
expected = pd.array([0, 1, 2, None], dtype="UInt8")
result = data_for_encoding.encode_additive()
assert_extension_array_equal(result, expected)
# Test using series accessor
expected = pd.Series(result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}")
expected = pd.Series(
result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}"
)
result_series = pd.Series(data_for_encoding).genotype.encode_additive()
assert_series_equal(result_series, expected)


def test_encoding_dominant(data_for_encoding):
# Test arrays directly
expected = pd.array([0, 1, 1, None], dtype='UInt8')
expected = pd.array([0, 1, 1, None], dtype="UInt8")
result = data_for_encoding.encode_dominant()
assert_extension_array_equal(result, expected)
# Test using series accessor
expected = pd.Series(result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}")
expected = pd.Series(
result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}"
)
result_series = pd.Series(data_for_encoding).genotype.encode_dominant()
assert_series_equal(result_series, expected)


def test_encoding_recessive(data_for_encoding):
# Test arrays directly
expected = pd.array([0, 0, 1, None], dtype='UInt8')
expected = pd.array([0, 0, 1, None], dtype="UInt8")
result = data_for_encoding.encode_recessive()
assert_extension_array_equal(result, expected)
# Test using series accessor
expected = pd.Series(result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}")
expected = pd.Series(
result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}"
)
result_series = pd.Series(data_for_encoding).genotype.encode_recessive()
assert_series_equal(result_series, expected)


def test_encoding_codominant(data_for_encoding):
# Test arrays directly
expected = pd.Categorical(["Ref", "Het", "Hom", None], categories=["Ref", "Het", "Hom"], ordered=True)
expected = pd.Categorical(
["Ref", "Het", "Hom", None], categories=["Ref", "Het", "Hom"], ordered=True
)
result = data_for_encoding.encode_codominant()
assert_extension_array_equal(result, expected)
# Test using series accessor
expected = pd.Series(result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}")
expected = pd.Series(
result, name=f"{data_for_encoding.variant.id}_{data_for_encoding.variant.alt}"
)
result_series = pd.Series(data_for_encoding).genotype.encode_codominant()
assert_series_equal(result_series, expected)
1 change: 1 addition & 0 deletions tests/io/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def vcf_test():
pytest.skip("VCF IO requires HTSLIB, which isn't easy to install on Windows")
# Run otherwise
import cyvcf2

VCF_DIR = Path(cyvcf2.__file__).parent / "tests"
vcf_filename = VCF_DIR / "test.vcf.gz"
result = io.from_vcf(vcf_filename)
Expand Down
2 changes: 1 addition & 1 deletion tests/scalars/test_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


def test_create_variant():
variant = Variant('12', 112161652, 'rs12462', ref='C', alt=['T'])
variant = Variant("12", 112161652, "rs12462", ref="C", alt=["T"])
print(variant)

0 comments on commit f0472d9

Please sign in to comment.