Skip to content

Commit

Permalink
Merge pull request #94 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
scprep v1.0.3
  • Loading branch information
scottgigante committed Oct 29, 2019
2 parents 08aadc1 + e037c1a commit 555ceb1
Show file tree
Hide file tree
Showing 56 changed files with 5,227 additions and 3,249 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -42,6 +42,7 @@

script:
- pip install -U .[test]
- if [ "$TRAVIS_PYTHON_VERSION" != "3.5" ]; then black . --check --diff; fi
- python setup.py test
- pip install -U .[doc]
- cd doc; make html
Expand Down
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -20,6 +20,13 @@ up" on issues that others reported and that are relevant to you. It also helps
us if you spread the word: reference the project from your blog and articles,
link to it from your website, or simply star it in GitHub to say "I use it".

Code Style and Testing
----------------------

`scprep` is maintained at close to 100% code coverage. Contributors are encouraged to write tests for their code, but if you do not know how to do so, please do not feel discouraged from contributing code! Others can always help you test your contribution.

Code style is dictated by [`black`](https://pypi.org/project/black/#installation-and-usage). To automatically reformat your code when you run `git commit`, you can run `./autoblack.sh` in the root directory of this project to add a hook to your `git` repository.

Code of Conduct
---------------

Expand All @@ -29,4 +36,4 @@ of the Python Software Foundation: https://www.python.org/psf/codeofconduct/.
Attribution
---------------

This `CONTRIBUTING.md` was adapted from [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md).
This `CONTRIBUTING.md` was adapted from [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md).
14 changes: 14 additions & 0 deletions autoblack.sh
@@ -0,0 +1,14 @@
cat <<EOF >> .git/hooks/pre-commit
#!/bin/sh
set -e
files=\$(git diff --staged --name-only --diff-filter=d -- "*.py")
for file in \$files; do
black -q \$file
git add \$file
done
EOF
chmod +x .git/hooks/pre-commit

81 changes: 43 additions & 38 deletions doc/source/conf.py
Expand Up @@ -22,14 +22,13 @@
import glob
import shutil

root_dir = os.path.abspath(os.path.join(os.path.dirname(
__file__), '..', '..'))
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, root_dir)
# print(sys.path)

# Copy ipython notebooks
dest_dir = "examples"
for file in glob.glob(os.path.join(root_dir, 'examples', '*.ipynb')):
for file in glob.glob(os.path.join(root_dir, "examples", "*.ipynb")):
print("Copy {} to {}".format(file, dest_dir))
shutil.copy(file, dest_dir)

Expand All @@ -42,44 +41,45 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'nbsphinx',
'sphinx.ext.mathjax',
'autodocsumm',
'IPython.sphinxext.ipython_console_highlighting']
extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"nbsphinx",
"sphinx.ext.mathjax",
"autodocsumm",
"IPython.sphinxext.ipython_console_highlighting",
]

autodoc_mock_imports = ["h5py", "tables", "rpy2", "fcsparser"]

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.ipynb']
source_suffix = [".rst", ".ipynb"]

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

# General information about the project.
project = 'scprep'
copyright = '2018 Krishnaswamy Lab, Yale University'
author = 'Scott Gigante, Jay Stanley, Daniel Burkhardt'
project = "scprep"
copyright = "2018 Krishnaswamy Lab, Yale University"
author = "Scott Gigante, Jay Stanley, Daniel Burkhardt"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
version_py = os.path.join(root_dir, 'scprep', 'version.py')
version_py = os.path.join(root_dir, "scprep", "version.py")
# The full version, including alpha/beta/rc tags.
release = open(version_py).read().strip().split(
'=')[-1].replace('"', '').strip()
release = open(version_py).read().strip().split("=")[-1].replace('"', "").strip()
# The short X.Y version.
version = release.split('-')[0]
version = release.split("-")[0]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -91,10 +91,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', '**.ipynb_checkpoints']
exclude_patterns = ["_build", "**.ipynb_checkpoints"]

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

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -105,7 +105,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
html_theme = "default"

# 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
Expand All @@ -116,13 +116,13 @@
# 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 = ['ystatic']
html_static_path = ["ystatic"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'scprepdoc'
htmlhelp_basename = "scprepdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -131,15 +131,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -149,19 +146,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'scprep.tex', 'scprep Documentation',
'Scott Gigante, Jay Stanley, Daniel Burkhardt', 'manual'),
(
master_doc,
"scprep.tex",
"scprep Documentation",
"Scott Gigante, Jay Stanley, Daniel Burkhardt",
"manual",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'scprep', 'scprep Documentation',
[author], 1)
]
man_pages = [(master_doc, "scprep", "scprep Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -170,9 +169,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'scprep', 'scprep Documentation',
author, 'scprep', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"scprep",
"scprep Documentation",
author,
"scprep",
"One line description of project.",
"Miscellaneous",
),
]

nbsphinx_execute = "always"
Expand Down
8 changes: 6 additions & 2 deletions scprep/__init__.py
Expand Up @@ -16,12 +16,16 @@
import scprep.run

import pandas as pd
if int(pd.__version__.split('.')[1]) < 26:

if int(pd.__version__.split(".")[1]) < 26:

def fill_value(self):
# Used in reindex_indexer
try:
return self.values.dtype.fill_value
except AttributeError:
return self.values.dtype.na_value

from pandas.core.internals.blocks import ExtensionBlock
setattr(ExtensionBlock, 'fill_value', property(fill_value))

setattr(ExtensionBlock, "fill_value", property(fill_value))
44 changes: 27 additions & 17 deletions scprep/_lazyload.py
Expand Up @@ -6,39 +6,49 @@
# each module loads submodules on initialization but is only imported
# and loads methods/classes when these are accessed
_importspec = {
'matplotlib': ['colors', 'pyplot', 'animation', 'cm',
'axes', 'lines', 'ticker', 'transforms'],
'mpl_toolkits': ['mplot3d'],
'fcsparser': ['api'],
'rpy2': [{'robjects': ['numpy2ri', 'packages', 'vectors', 'conversion']},
'rinterface',
{'rinterface_lib': ['callbacks']}],
'h5py': [],
'tables': [],
'requests': [],
"matplotlib": [
"colors",
"pyplot",
"animation",
"cm",
"axes",
"lines",
"ticker",
"transforms",
],
"mpl_toolkits": ["mplot3d"],
"fcsparser": ["api"],
"rpy2": [
{"robjects": ["numpy2ri", "packages", "vectors", "conversion"]},
"rinterface",
{"rinterface_lib": ["callbacks"]},
],
"h5py": [],
"tables": [],
"requests": [],
}


class AliasModule(object):

def __init__(self, name, members=None):
# easy access to AliasModule members to avoid recursionerror
super_setattr = super().__setattr__
if members is None:
members = []
builtin_members = ['__class__', '__doc__']
super_setattr('__module_name__', name)
builtin_members = ["__class__", "__doc__"]
super_setattr("__module_name__", name)
# create submodules
submodules = []
for member in members:
if isinstance(member, dict):
for submodule, submembers in member.items():
super_setattr(submodule, AliasModule(
"{}.{}".format(name, submodule), submembers))
super_setattr(
submodule,
AliasModule("{}.{}".format(name, submodule), submembers),
)
submodules.append(submodule)
else:
super_setattr(member, AliasModule(
"{}.{}".format(name, member)))
super_setattr(member, AliasModule("{}.{}".format(name, member)))
submodules.append(member)
super_setattr("__submodules__", submodules)
super_setattr("__builtin_members__", builtin_members)
Expand Down

0 comments on commit 555ceb1

Please sign in to comment.