Skip to content

Commit

Permalink
Merge branch 'master' into upload-release-to-pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
jnothman committed Dec 28, 2023
2 parents e291fb2 + fd2f525 commit 435f8b7
Show file tree
Hide file tree
Showing 22 changed files with 1,527 additions and 1,141 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
@@ -1,4 +1,4 @@
name: Lintbb
name: Lint
on: [push]
jobs:
lint:
Expand All @@ -17,4 +17,5 @@ jobs:
run: |
pip install ruff
ruff --output-format=github .
continue-on-error: true
- name: Check format with ruff
run: ruff format --check
7 changes: 4 additions & 3 deletions conftest.py
Expand Up @@ -5,6 +5,7 @@

def pytest_runtest_setup(item):
if isinstance(item, DoctestItem):
if sys.version_info.major < 3 or (sys.version_info.major == 3
and sys.version_info.minor < 6):
pytest.skip('Doctests are disabled in Python < 3.6')
if sys.version_info.major < 3 or (
sys.version_info.major == 3 and sys.version_info.minor < 6
):
pytest.skip("Doctests are disabled in Python < 3.6")
75 changes: 36 additions & 39 deletions doc/conf.py
Expand Up @@ -17,11 +17,11 @@
import re

# project root
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))

import matplotlib # noqa

matplotlib.use('agg')
matplotlib.use("agg")

import sphinx_rtd_theme # noqa
from upsetplot import __version__ as release # noqa
Expand All @@ -40,42 +40,42 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_gallery.gen_gallery',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'numpydoc',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx_issues',
'nbsphinx',
"sphinx_gallery.gen_gallery",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"numpydoc",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx_issues",
"nbsphinx",
]

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

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

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

# General information about the project.
project = u'upsetplot'
copyright = u'2018-2023, Joel Nothman'
project = "upsetplot"
copyright = "2018-2023, Joel Nothman"

# 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.
#
# The short X.Y version.

version = re.match(r'^\d+(\.\d+)*', release).group()
version = re.match(r"^\d+(\.\d+)*", release).group()

# version = upsetplot.__version__
# The full version, including alpha/beta/rc tags.
Expand All @@ -93,11 +93,11 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
default_role = 'any'
default_role = "any"

# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
Expand All @@ -111,7 +111,7 @@
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -124,7 +124,7 @@

# 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"

# 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 Down Expand Up @@ -153,7 +153,7 @@
# 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"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -202,18 +202,16 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'project-templatedoc'
htmlhelp_basename = "project-templatedoc"


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

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

# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
Expand All @@ -222,8 +220,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'upsetplot.tex', u'upsetplot Documentation',
u'Joel Nothman', 'manual'),
("index", "upsetplot.tex", "upsetplot Documentation", "Joel Nothman", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -261,24 +258,24 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('http://docs.python.org/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'matplotlib': ('https://matplotlib.org/', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
"python": ("http://docs.python.org/", None),
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
"matplotlib": ("https://matplotlib.org/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
}


# Config for sphinx_issues

issues_uri = 'https://github.com/jnothman/upsetplot/issues/{issue}'
issues_github_path = 'jnothman/upsetplot'
issues_user_uri = 'https://github.com/{user}'
issues_uri = "https://github.com/jnothman/upsetplot/issues/{issue}"
issues_github_path = "jnothman/upsetplot"
issues_user_uri = "https://github.com/{user}"


sphinx_gallery_conf = {
# path to your examples scripts
'examples_dirs': '../examples',
"examples_dirs": "../examples",
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
'backreferences_dir': '_modules',
"gallery_dirs": "auto_examples",
"backreferences_dir": "_modules",
}
28 changes: 16 additions & 12 deletions examples/plot_diabetes.py
Expand Up @@ -31,18 +31,18 @@
diabetes_df = pd.DataFrame(diabetes.data, columns=diabetes.feature_names)

# Get five features most correlated with median house value
correls = diabetes_df.corrwith(pd.Series(diabetes.target),
method='spearman').sort_values()
correls = diabetes_df.corrwith(
pd.Series(diabetes.target), method="spearman"
).sort_values()
top_features = correls.index[-5:]

# Get a binary indicator of whether each top feature is above average
diabetes_above_avg = diabetes_df > diabetes_df.median(axis=0)
diabetes_above_avg = diabetes_above_avg[top_features]
diabetes_above_avg = diabetes_above_avg.rename(columns=lambda x: x + '>')
diabetes_above_avg = diabetes_above_avg.rename(columns=lambda x: x + ">")

# Make this indicator mask an index of diabetes_df
diabetes_df = pd.concat([diabetes_df, diabetes_above_avg],
axis=1)
diabetes_df = pd.concat([diabetes_df, diabetes_above_avg], axis=1)
diabetes_df = diabetes_df.set_index(list(diabetes_above_avg.columns))

# Also give us access to the target (median house value)
Expand All @@ -51,10 +51,10 @@
##########################################################################

# UpSet plot it!
upset = UpSet(diabetes_df, subset_size='count', intersection_plot_elements=3)
upset.add_catplot(value='progression', kind='strip', color='blue')
upset = UpSet(diabetes_df, subset_size="count", intersection_plot_elements=3)
upset.add_catplot(value="progression", kind="strip", color="blue")
print(diabetes_df)
upset.add_catplot(value='bmi', kind='strip', color='black')
upset.add_catplot(value="bmi", kind="strip", color="black")
upset.plot()
plt.title("UpSet with catplots, for orientation='horizontal'")
plt.show()
Expand All @@ -63,10 +63,14 @@

# And again in vertical orientation

upset = UpSet(diabetes_df, subset_size='count', intersection_plot_elements=3,
orientation='vertical')
upset.add_catplot(value='progression', kind='strip', color='blue')
upset.add_catplot(value='bmi', kind='strip', color='black')
upset = UpSet(
diabetes_df,
subset_size="count",
intersection_plot_elements=3,
orientation="vertical",
)
upset.add_catplot(value="progression", kind="strip", color="blue")
upset.add_catplot(value="bmi", kind="strip", color="black")
upset.plot()
plt.title("UpSet with catplots, for orientation='vertical'")
plt.show()
22 changes: 13 additions & 9 deletions examples/plot_discrete.py
Expand Up @@ -11,24 +11,28 @@
from matplotlib import pyplot as plt
from matplotlib import cm

TITANIC_URL = 'https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv' # noqa
TITANIC_URL = (
"https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv" # noqa
)
df = pd.read_csv(TITANIC_URL)
# Show UpSet on survival and first classs
df = df.set_index(df.Survived == 1).set_index(df.Pclass == 1, append=True)

upset = UpSet(df,
intersection_plot_elements=0) # disable the default bar chart
upset.add_stacked_bars(by="Sex", colors=cm.Pastel1,
title="Count by gender", elements=10)
upset = UpSet(df, intersection_plot_elements=0) # disable the default bar chart
upset.add_stacked_bars(
by="Sex", colors=cm.Pastel1, title="Count by gender", elements=10
)
upset.plot()
plt.suptitle("Gender for first class and survival on Titanic")
plt.show()


upset = UpSet(df, show_counts=True, orientation="vertical",
intersection_plot_elements=0)
upset.add_stacked_bars(by="Sex", colors=cm.Pastel1,
title="Count by gender", elements=10)
upset = UpSet(
df, show_counts=True, orientation="vertical", intersection_plot_elements=0
)
upset.add_stacked_bars(
by="Sex", colors=cm.Pastel1, title="Count by gender", elements=10
)
upset.plot()
plt.suptitle("Same, but vertical, with counts shown")
plt.show()
16 changes: 8 additions & 8 deletions examples/plot_generated.py
Expand Up @@ -15,29 +15,29 @@
##########################################################################

plot(example)
plt.suptitle('Ordered by degree')
plt.suptitle("Ordered by degree")
plt.show()

##########################################################################

plot(example, sort_by='cardinality')
plt.suptitle('Ordered by cardinality')
plot(example, sort_by="cardinality")
plt.suptitle("Ordered by cardinality")
plt.show()

##########################################################################

plot(example, show_counts='{:d}')
plt.suptitle('With counts shown')
plot(example, show_counts="{:d}")
plt.suptitle("With counts shown")
plt.show()

##########################################################################

plot(example, show_counts='%d', show_percentages=True)
plt.suptitle('With counts and % shown')
plot(example, show_counts="%d", show_percentages=True)
plt.suptitle("With counts and % shown")
plt.show()

##########################################################################

plot(example, show_percentages="{:.2%}")
plt.suptitle('With fraction shown in custom format')
plt.suptitle("With fraction shown in custom format")
plt.show()
10 changes: 5 additions & 5 deletions examples/plot_hide.py
Expand Up @@ -13,29 +13,29 @@
example = generate_counts()

plot(example, show_counts=True)
plt.suptitle('Nothing hidden')
plt.suptitle("Nothing hidden")
plt.show()

##########################################################################

plot(example, show_counts=True, min_subset_size=100)
plt.suptitle('Small subsets hidden')
plt.suptitle("Small subsets hidden")
plt.show()

##########################################################################

plot(example, show_counts=True, max_subset_size=500)
plt.suptitle('Large subsets hidden')
plt.suptitle("Large subsets hidden")
plt.show()

##########################################################################

plot(example, show_counts=True, min_degree=2)
plt.suptitle('Degree <2 hidden')
plt.suptitle("Degree <2 hidden")
plt.show()

##########################################################################

plot(example, show_counts=True, max_degree=2)
plt.suptitle('Degree >2 hidden')
plt.suptitle("Degree >2 hidden")
plt.show()

0 comments on commit 435f8b7

Please sign in to comment.