Skip to content

Commit

Permalink
Apply python package "black" to tsfresh repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mendel5 committed Jul 1, 2021
1 parent 44fdeb5 commit 46a6735
Show file tree
Hide file tree
Showing 50 changed files with 5,572 additions and 2,112 deletions.
81 changes: 43 additions & 38 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
# DON'T FORGET: Check the box "Install your project inside a virtualenv using
# setup.py install" in the RTD Advanced Settings.
import os
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if on_rtd:
import inspect
from sphinx import apidoc

__location__ = os.path.join(os.getcwd(), os.path.dirname(
inspect.getfile(inspect.currentframe())))
__location__ = os.path.join(
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
)

output_dir = os.path.join(__location__, "../docs/api")
module_dir = os.path.join(__location__, "../tsfresh")
Expand All @@ -40,40 +42,48 @@
# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.6.4'
needs_sphinx = "1.6.4"

# 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.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage',
'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.imgmath',
'sphinx.ext.napoleon']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.ifconfig",
"sphinx.ext.imgmath",
"sphinx.ext.napoleon",
]

# 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.
now = datetime.datetime.today()
project = 'tsfresh'
copyright = '2016-{}, Maximilian Christ et al./ Blue Yonder GmbH'.format(now.year)
project = "tsfresh"
copyright = "2016-{}, Maximilian Christ et al./ Blue Yonder GmbH".format(now.year)

# 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 = '' # Is set by calling `setup.py docs`
version = "" # Is set by calling `setup.py docs`
# The full version, including alpha/beta/rc tags.
release = '' # Is set by calling `setup.py docs`
release = "" # Is set by calling `setup.py docs`

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -87,7 +97,7 @@

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

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
Expand All @@ -104,7 +114,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 = ["tsfresh", "tsfresh.convenience"]
Expand All @@ -121,14 +131,12 @@

# 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
# documentation.
html_theme_options = {
"style_nav_header_background": "#51b63c"
}
html_theme_options = {"style_nav_header_background": "#51b63c"}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down Expand Up @@ -157,13 +165,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 = ['_static']
html_static_path = ["_static"]

# From https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html
html_context = {
'css_files': [
'_static/theme_override.css', # override wide tables in RTD theme
],
"css_files": [
"_static/theme_override.css", # override wide tables in RTD theme
],
}

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
Expand Down Expand Up @@ -208,27 +216,24 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'tsfresh-doc'
htmlhelp_basename = "tsfresh-doc"


# -- 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': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'user_guide.tex', 'tsfresh Documentation',
'', 'manual'),
("index", "user_guide.tex", "tsfresh Documentation", "", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -252,13 +257,13 @@
# latex_domain_indices = True

# -- External mapping ------------------------------------------------------------
python_version = '.'.join(map(str, sys.version_info[0:2]))
python_version = ".".join(map(str, sys.version_info[0:2]))
intersphinx_mapping = {
'sphinx': ('http://sphinx.pocoo.org', None),
'python': ('http://docs.python.org/' + python_version, None),
'matplotlib': ('http://matplotlib.sourceforge.net', None),
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'sklearn': ('http://scikit-learn.org/stable', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
"sphinx": ("http://sphinx.pocoo.org", None),
"python": ("http://docs.python.org/" + python_version, None),
"matplotlib": ("http://matplotlib.sourceforge.net", None),
"numpy": ("http://docs.scipy.org/doc/numpy", None),
"sklearn": ("http://scikit-learn.org/stable", None),
"pandas": ("http://pandas.pydata.org/pandas-docs/stable", None),
"scipy": ("http://docs.scipy.org/doc/scipy/reference/", None),
}
56 changes: 41 additions & 15 deletions tests/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,67 @@
import numpy as np

from tsfresh import extract_features, extract_relevant_features
from tsfresh.feature_extraction.settings import ComprehensiveFCParameters, MinimalFCParameters
from tsfresh.feature_extraction.settings import (
ComprehensiveFCParameters,
MinimalFCParameters,
)


def create_data(time_series_length, num_ids, random_seed=42):
np.random.seed(random_seed)

df = pd.concat([
pd.DataFrame({
"id": [i] * time_series_length,
"time": range(time_series_length),
"value": np.random.randn(time_series_length).cumsum()
})
for i in range(num_ids)
])
df = pd.concat(
[
pd.DataFrame(
{
"id": [i] * time_series_length,
"time": range(time_series_length),
"value": np.random.randn(time_series_length).cumsum(),
}
)
for i in range(num_ids)
]
)

return df


def test_benchmark_small_data(benchmark):
df = create_data(5, 200)

benchmark(extract_features, df, column_id="id", column_sort="time", n_jobs=0,
disable_progressbar=True)
benchmark(
extract_features,
df,
column_id="id",
column_sort="time",
n_jobs=0,
disable_progressbar=True,
)


def test_benchmark_large_data(benchmark):
df = create_data(500, 20)

benchmark(extract_features, df, column_id="id", column_sort="time", n_jobs=0,
disable_progressbar=True)
benchmark(
extract_features,
df,
column_id="id",
column_sort="time",
n_jobs=0,
disable_progressbar=True,
)


def test_benchmark_with_selection(benchmark):
df = create_data(500, 20)
y = pd.Series(np.random.choice([0, 1], 20))

benchmark(extract_relevant_features, df, y, column_id="id", column_sort="time", n_jobs=0,
disable_progressbar=True)
benchmark(
extract_relevant_features,
df,
y,
column_id="id",
column_sort="time",
n_jobs=0,
disable_progressbar=True,
)
Loading

0 comments on commit 46a6735

Please sign in to comment.