<commit_before>#
# pytest documentation build configuration file, created by
# sphinx-quickstart on Fri Oct  8 17:54:28 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# 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 full version, including alpha/beta/rc tags.
# The short X.Y version.
import ast
import os
import sys
from typing import List
from typing import TYPE_CHECKING

from _pytest import __version__ as version

if TYPE_CHECKING:
    import sphinx.application

release = ".".join(version.split(".")[:2])

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

autodoc_member_order = "bysource"
autodoc_typehints = "description"
todo_include_todos = 1

# -- General configuration -----------------------------------------------------

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

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    "pallets_sphinx_themes",
    "pygments_pytest",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.intersphinx",
    "sphinx.ext.todo",
    "sphinx.ext.viewcode",
    "sphinx_removed_in",
    "sphinxcontrib_trio",
    "sphinxcontrib.inkscapeconverter",
]

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

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

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

# The master toctree document.
master_doc = "contents"

# General information about the project.
project = "pytest"
copyright = "2015–2021, holger krekel and pytest-dev team"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = [
    "_build",
    "naming20.rst",
    "test/*",
    "old_*",
    "*attic*",
    "*/attic*",
    "funcargs.rst",
    "setup.rst",
    "example/remoteinterp.rst",
]

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

# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = False

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []

# A list of regular expressions that match URIs that should not be checked when
# doing a linkcheck.
linkcheck_ignore = [
    "https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations",
    "https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/",
    "http://pythontesting.net/framework/pytest-introduction/",
    r"https://github.com/pytest-dev/pytest/issues/\d+",
    r"https://github.com/pytest-dev/pytest/pull/\d+",
]

# The number of worker threads to use when checking links (default=5).
linkcheck_workers = 5

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

sys.path.append(os.path.abspath("_themes"))
html_theme_path = ["_themes"]

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

# 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 = {"index_logo": None}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
html_title = "pytest documentation"

# A shorter title for the navigation bar.  Default is the same as html_title.
html_short_title = "pytest-%s" % release

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "img/pytest_logo_curves.svg"

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "img/favicon.png"

# 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']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# html_sidebars = {'index': 'indexsidebar.html'}

html_sidebars = {
    "index": [
        "slim_searchbox.html",
        "sidebarintro.html",
        "globaltoc.html",
        "links.html",
        "sourcelink.html",
    ],
    "**": [
        "slim_searchbox.html",
        "globaltoc.html",
        "relations.html",
        "links.html",
        "sourcelink.html",
    ],
}

# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# html_additional_pages = {'index': 'index.html'}

# If false, no module index is generated.
html_domain_indices = True

# If false, no index is generated.
html_use_index = True

# If true, the index is split into individual pages for each letter.
# html_split_index = False

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None

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

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

# The paper size ('letter' or 'a4').
# latex_paper_size = 'letter'

# The font size ('10pt', '11pt' or '12pt').
# latex_font_size = '10pt'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
    (
        "contents",
        "pytest.tex",
        "pytest Documentation",
        "holger krekel, trainer and consultant, https://merlinux.eu/",
        "manual",
    )
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = "img/pytest1.png"

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False

# If true, show page references after internal links.
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
# latex_show_urls = False

# Additional stuff for the LaTeX preamble.
# latex_preamble = ''

# Documents to append as an appendix to all manuals.
# latex_appendices = []

# If false, no module index is generated.
latex_domain_indices = False

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]

# -- Options for Epub output ---------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = "pytest"
epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013-2021, holger krekel et alii"

# The language of the text. It defaults to the language option
# or en if the language is not set.
# epub_language = ''

# The scheme of the identifier. Typical schemes are ISBN or URL.
# epub_scheme = ''

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
# epub_identifier = ''

# A unique identification for the text.
# epub_uid = ''

# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
# epub_pre_files = []

# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
# epub_post_files = []

# A list of files that should not be packed into the epub file.
# epub_exclude_files = []

# The depth of the table of contents in toc.ncx.
# epub_tocdepth = 3

# Allow duplicate toc entries.
# epub_tocdup = True

# -- Options for texinfo output ------------------------------------------------

texinfo_documents = [
    (
        master_doc,
        "pytest",
        "pytest Documentation",
        (
            "Holger Krekel@*Benjamin Peterson@*Ronny Pfannschmidt@*"
            "Floris Bruynooghe@*others"
        ),
        "pytest",
        "simple powerful testing with Python",
        "Programming",
        1,
    )
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
    "pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
    "python": ("https://docs.python.org/3", None),
}

def configure_logging(app: "sphinx.application.Sphinx") -> None:
    """Configure Sphinx's WarningHandler to handle (expected) missing include."""
    import sphinx.util.logging
    import logging

    class WarnLogFilter(logging.Filter):
        def filter(self, record: logging.LogRecord) -> bool:
            """Ignore warnings about missing include with "only" directive.

            Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
            if (
                record.msg.startswith('Problems with "include" directive path:')
                and "_changelog_towncrier_draft.rst" in record.msg
            ):
                return False
            return True

    logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
    warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
    assert len(warn_handler) == 1, warn_handler
    warn_handler[0].filters.insert(0, WarnLogFilter())

def setup(app: "sphinx.application.Sphinx") -> None:
    # from sphinx.ext.autodoc import cut_lines
    # app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
    app.add_crossref_type(
        "fixture",
        "fixture",
        objname="built-in fixture",
        indextemplate="pair: %s; fixture",
    )

    app.add_object_type(
        "confval",
        "confval",
        objname="configuration value",
        indextemplate="pair: %s; configuration value",
    )

    app.add_object_type(
        "globalvar",
        "globalvar",
        objname="global variable interpreted by pytest",
        indextemplate="pair: %s; global variable interpreted by pytest",
    )

    configure_logging(app)

    # Make Sphinx mark classes with "final" when decorated with @final.
    # We need this because we import final from pytest._compat, not from
    # typing (for Python < 3.8 compat), so Sphinx doesn't detect it.
    # To keep things simple we accept any `@final` decorator.
    # Ref: https://github.com/pytest-dev/pytest/pull/7780
    import sphinx.pycode.ast
    import sphinx.pycode.parser

    original_is_final = sphinx.pycode.parser.VariableCommentPicker.is_final

    def patched_is_final(self, decorators: List[ast.expr]) -> bool:
        if original_is_final(self, decorators):
            return True
        return any(
            sphinx.pycode.ast.unparse(decorator) == "final" for decorator in decorators
        )

    sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final
<commit_msg>Only use inkscapeconverter if inkscape installed<commit_after>#
# pytest documentation build configuration file, created by
# sphinx-quickstart on Fri Oct  8 17:54:28 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# 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 full version, including alpha/beta/rc tags.
# The short X.Y version.
import ast
import os
import shutil
import sys
from typing import List
from typing import TYPE_CHECKING

from _pytest import __version__ as version

if TYPE_CHECKING:
    import sphinx.application

release = ".".join(version.split(".")[:2])

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

autodoc_member_order = "bysource"
autodoc_typehints = "description"
todo_include_todos = 1

# -- General configuration -----------------------------------------------------

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

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    "pallets_sphinx_themes",
    "pygments_pytest",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.intersphinx",
    "sphinx.ext.todo",
    "sphinx.ext.viewcode",
    "sphinx_removed_in",
    "sphinxcontrib_trio",
]

# Building PDF docs on readthedocs requires inkscape for svg to pdf
# conversion. The relevant plugin is not useful for normal HTML builds, but
# it still raises warnings and fails CI if inkscape is not available. So
# only use the plugin if inkscape is actually available.
if shutil.which('inkscape'):
    extensions.append("sphinxcontrib.inkscapeconverter")

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

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

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

# The master toctree document.
master_doc = "contents"

# General information about the project.
project = "pytest"
copyright = "2015–2021, holger krekel and pytest-dev team"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = [
    "_build",
    "naming20.rst",
    "test/*",
    "old_*",
    "*attic*",
    "*/attic*",
    "funcargs.rst",
    "setup.rst",
    "example/remoteinterp.rst",
]

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

# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = False

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []

# A list of regular expressions that match URIs that should not be checked when
# doing a linkcheck.
linkcheck_ignore = [
    "https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations",
    "https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/",
    "http://pythontesting.net/framework/pytest-introduction/",
    r"https://github.com/pytest-dev/pytest/issues/\d+",
    r"https://github.com/pytest-dev/pytest/pull/\d+",
]

# The number of worker threads to use when checking links (default=5).
linkcheck_workers = 5

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

sys.path.append(os.path.abspath("_themes"))
html_theme_path = ["_themes"]

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

# 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 = {"index_logo": None}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
html_title = "pytest documentation"

# A shorter title for the navigation bar.  Default is the same as html_title.
html_short_title = "pytest-%s" % release

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "img/pytest_logo_curves.svg"

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "img/favicon.png"

# 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']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# html_sidebars = {'index': 'indexsidebar.html'}

html_sidebars = {
    "index": [
        "slim_searchbox.html",
        "sidebarintro.html",
        "globaltoc.html",
        "links.html",
        "sourcelink.html",
    ],
    "**": [
        "slim_searchbox.html",
        "globaltoc.html",
        "relations.html",
        "links.html",
        "sourcelink.html",
    ],
}

# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# html_additional_pages = {'index': 'index.html'}

# If false, no module index is generated.
html_domain_indices = True

# If false, no index is generated.
html_use_index = True

# If true, the index is split into individual pages for each letter.
# html_split_index = False

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None

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

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

# The paper size ('letter' or 'a4').
# latex_paper_size = 'letter'

# The font size ('10pt', '11pt' or '12pt').
# latex_font_size = '10pt'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
    (
        "contents",
        "pytest.tex",
        "pytest Documentation",
        "holger krekel, trainer and consultant, https://merlinux.eu/",
        "manual",
    )
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = "img/pytest1.png"

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False

# If true, show page references after internal links.
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
# latex_show_urls = False

# Additional stuff for the LaTeX preamble.
# latex_preamble = ''

# Documents to append as an appendix to all manuals.
# latex_appendices = []

# If false, no module index is generated.
latex_domain_indices = False

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]

# -- Options for Epub output ---------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = "pytest"
epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013-2021, holger krekel et alii"

# The language of the text. It defaults to the language option
# or en if the language is not set.
# epub_language = ''

# The scheme of the identifier. Typical schemes are ISBN or URL.
# epub_scheme = ''

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
# epub_identifier = ''

# A unique identification for the text.
# epub_uid = ''

# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
# epub_pre_files = []

# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
# epub_post_files = []

# A list of files that should not be packed into the epub file.
# epub_exclude_files = []

# The depth of the table of contents in toc.ncx.
# epub_tocdepth = 3

# Allow duplicate toc entries.
# epub_tocdup = True

# -- Options for texinfo output ------------------------------------------------

texinfo_documents = [
    (
        master_doc,
        "pytest",
        "pytest Documentation",
        (
            "Holger Krekel@*Benjamin Peterson@*Ronny Pfannschmidt@*"
            "Floris Bruynooghe@*others"
        ),
        "pytest",
        "simple powerful testing with Python",
        "Programming",
        1,
    )
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
    "pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
    "python": ("https://docs.python.org/3", None),
}

def configure_logging(app: "sphinx.application.Sphinx") -> None:
    """Configure Sphinx's WarningHandler to handle (expected) missing include."""
    import sphinx.util.logging
    import logging

    class WarnLogFilter(logging.Filter):
        def filter(self, record: logging.LogRecord) -> bool:
            """Ignore warnings about missing include with "only" directive.

            Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
            if (
                record.msg.startswith('Problems with "include" directive path:')
                and "_changelog_towncrier_draft.rst" in record.msg
            ):
                return False
            return True

    logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
    warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
    assert len(warn_handler) == 1, warn_handler
    warn_handler[0].filters.insert(0, WarnLogFilter())

def setup(app: "sphinx.application.Sphinx") -> None:
    # from sphinx.ext.autodoc import cut_lines
    # app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
    app.add_crossref_type(
        "fixture",
        "fixture",
        objname="built-in fixture",
        indextemplate="pair: %s; fixture",
    )

    app.add_object_type(
        "confval",
        "confval",
        objname="configuration value",
        indextemplate="pair: %s; configuration value",
    )

    app.add_object_type(
        "globalvar",
        "globalvar",
        objname="global variable interpreted by pytest",
        indextemplate="pair: %s; global variable interpreted by pytest",
    )

    configure_logging(app)

    # Make Sphinx mark classes with "final" when decorated with @final.
    # We need this because we import final from pytest._compat, not from
    # typing (for Python < 3.8 compat), so Sphinx doesn't detect it.
    # To keep things simple we accept any `@final` decorator.
    # Ref: https://github.com/pytest-dev/pytest/pull/7780
    import sphinx.pycode.ast
    import sphinx.pycode.parser

    original_is_final = sphinx.pycode.parser.VariableCommentPicker.is_final

    def patched_is_final(self, decorators: List[ast.expr]) -> bool:
        if original_is_final(self, decorators):
            return True
        return any(
            sphinx.pycode.ast.unparse(decorator) == "final" for decorator in decorators
        )

    sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final
<|endoftext|>


<commit_before>import dj_database_url

from feelings.settings import *

def get_env_variable(var_name):
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = "Set the {} env variable".format(var_name)
        if DEBUG:
            warnings.war(error_msg)
        else:
            raise ImproperlyConfigured(error_msg)

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = [
    'localhost',
    '.herokuapp.com',
]

INSTALLED_APPS += (
    'gunicorn',
)

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

SECRET_KEY = get_env_variable("SECRET_KEY")

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'<commit_msg>debug true<commit_after>import dj_database_url

from feelings.settings import *

def get_env_variable(var_name):
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = "Set the {} env variable".format(var_name)
        if DEBUG:
            warnings.war(error_msg)
        else:
            raise ImproperlyConfigured(error_msg)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = [
    'localhost',
    '.herokuapp.com',
]

INSTALLED_APPS += (
    'gunicorn',
)

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

SECRET_KEY = get_env_variable("SECRET_KEY")

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'<|endoftext|>


<commit_before>import time
import cPickle
import numpy as np
import theano
from theano import tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from load import load_data
from theano.tensor.nnet.conv import conv2d
from theano.tensor.signal.downsample import max_pool_2d
from theano.tensor.signal.downsample import DownsampleFactorMax

theano.config.floatX='float32'

srng = RandomStreams()

def floatX(X):
    """
    Convert X to float32 or float64, depending on how we configure theano.
    """
    return np.asarray(X, dtype=theano.config.floatX)

def init_weights(shape):
    """
    Initialize model parameters.
    """
    return theano.shared(floatX(np.random.randn(*shape) * 0.01))

def rectify(X):
    """
    Rectifier.
    """
    return T.maximum(X, 0.)

def softmax(X):
    """
    Numerically stable softmax.
    """
    e_x = T.exp(X - X.max(axis=1).dimshuffle(0, 'x'))
    return e_x / e_x.sum(axis=1).dimshuffle(0, 'x')

def dropout(X, p=0.):
    """
    Way of injecting noise into our network - help us with overfitting.
    Randomly drop values and scale rest.
    """
    if p > 0:
        retain_prob = 1 - p
        X *= srng.binomial(X.shape, p=retain_prob, dtype=theano.config.floatX)
        X /= retain_prob
    return X

def RMSprop(cost, params, lr=0.001, rho=0.9, epsilon=1e-6):
    """
    Learn different networks better and learning them quicker.
    """
    grads = T.grad(cost=cost, wrt=params)
    updates = []
    for p, g in zip(params, grads):
        acc = theano.shared(p.get_value() * 0.)
        acc_new = rho * acc + (1 - rho) * g ** 2
        gradient_scaling = T.sqrt(acc_new + epsilon)
        g = g / gradient_scaling
        updates.append((acc, acc_new))
        updates.append((p, p - lr * g))
    return updates

def model(X, w, w2, w3, w4, p_drop_conv, p_drop_hidden):
    """
        Perform convolution and everything belonging to it.
        Code is split into 4 "blocks" - 3 blocks of computation and last block where we have fully connected layer.

        In each block we perform convolution, followed by rectify activation function. After that we perform max pool
        and add some noise with dropout. This is repeated for layers 2 and 3.
        Last layer is fully connected layer, which connects all the filters to 500 hidden nodes. These nodes are then
        connected to the output nodes.
    """
    # block of computation
    # border_mode='valid': apply filter wherever it completely overlaps with the input
    l1a = rectify(conv2d(X, w, border_mode='valid', subsample=(1, conv1_stride))) # stride along one (horizontal) dimension only
    l1 = max_pool_2d(l1a, (1, downscale1), st=(1, stride1)) # (1,1)=(vertical, horizontal) downscale, st=(1, step): move to every stride1 column and perform max_pooling there
    l1 = dropout(l1, p_drop_conv)

    # repeat block
    l2a = rectify(conv2d(l1, w2, subsample=(1, 1))) # stride along horizontal
    l2 = max_pool_2d(l2a, (1, downscale2), st=(1, stride2))
    l2 = dropout(l2, p_drop_conv)

    l3a = rectify(conv2d(l2, w3, subsample=(1, 1))) # stride along horizontal
    l3b = max_pool_2d(l3a, (1, downscale3), st=(1, stride3))
    l3 = T.flatten(l3b, outdim=2) # convert from 4tensor to normal matrix
    l3 = dropout(l3, p_drop_conv)

    l4 = rectify(T.dot(l3, w4))
    l4 = dropout(l4, p_drop_hidden)

    pyx = softmax(T.dot(l4, w_o))
    return l1, l2, l3, l4, pyx

# shranjeval bomo train
def save_model(filename, model):
    print "saving model..."
    f = open(filename, 'wb')
    cPickle.dump(model, f, protocol=cPickle.HIGHEST_PROTOCOL)
    f.close()
    print "model saved..."

# loadamo pa filename v train
def load_model(filename):
    f = open(filename, 'rb')
    loaded_obj = cPickle.load(f)
    f.close()
    return loaded_obj

print "start:", time.strftime('%X %x %Z')
#trX, teX, trY, teY, num_of_classes = seq_load(onehot=True, seed=7970223320302509880) # load data
transmission_dict = {'A': [1, 0, 0, 0], 'T': [0, 1, 0, 0], 'C': [0, 0, 1, 0], 'G': [0, 0, 0, 1]}
trX, teX, trY, teY, num_of_classes = load_data(filename="test", test=0.2, transmission_dict=transmission_dict, seed=0, sample=0.2)
#X, Y, num_of_classes = ...
#cross validation oz kakrsnokoli razporejanje (npr 80-20)
#trX, teX, trY, teY = ...

print(trX.shape)
input_len = trX.shape[1] # save input length for further use
trX = trX.reshape(-1, 1, 1, input_len)
teX = teX.reshape(-1, 1, 1, input_len)

# matrix types
X = T.ftensor4()
Y = T.fmatrix()

# size of convolution windows, for each layer different values can be used
cwin1=4*6  # multiples of 4 because of data representation
cwin2=3
cwin3=2

num_filters_1=32 / 2  # how many different filters to learn at each layer
num_filters_2=48 / 2
num_filters_3=64 / 2
w = init_weights((num_filters_1, 1, 1, cwin1)) # first convolution, 32 filters, stack size 1, 1 rows, cwin1 columns
w2 = init_weights((num_filters_2, num_filters_1, 1, cwin2)) # second convolution, 64 filters, stack size 32 (one stack for each filter from previous layer), 1 row, cwin2 columns
w3 = init_weights((num_filters_3, num_filters_2, 1, cwin3)) # third convolution, 128 filters, stack size 64 (one stack for each filter from previous layes), 1 row, cwin3 columns

print "#### CONVOLUTION PARAMETERS ####"
print "cwin1 %d" % cwin1
print "cwin2 %d" % cwin2
print "cwin3 %d" % cwin3
print "num_filters_1 %d" % num_filters_1
print "num_filters_2 %d" % num_filters_2
print "num_filters_3 %d" % num_filters_3

# convolution: filters are moved by one position at a time, see parameter subsample=(1, 1)
#
# max pooling:
#   scaling the input before applying the maxpool filter and
#   displacement (stride) when sliding the max pool filters
conv1_stride=4

stride1=2
downscale1=3

stride2=2
downscale2=2

stride3=2
downscale3=1

# l1 conv:
es = input_len
es = (es - cwin1 + 1)
es = es / conv1_stride
# l1 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale1), st=(1, stride1))[1] # downscale for first layer
print "l1 es:", es

# l2 conv:
es = (es - cwin2 + 1)
# l2 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale2), st=(1, stride2))[1] # downscale for second layer
print "l2 es:", es

# l3 conv:
es = (es - cwin3 + 1)
# l3 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale3), st=(1, stride3))[1] # downscale for third layer
print "l3 es:", es

# downscaling is performed so that we correctly set number of filters in last layer

w4 = init_weights((num_filters_3 * es, 500))  # fully conected last layer, connects the outputs of 128 filters to 500 (arbitrary) hidden nodes, which are then connected to the output nodes
w_o = init_weights((500, num_of_classes))  # number of exptected classes

noise_l1, noise_l2, noise_l3, noise_l4, noise_py_x = model(X, w, w2, w3, w4, 0.2, 0.5) # noise during training
l1, l2, l3, l4, py_x = model(X, w, w2, w3, w4, 0., 0.) # no noise during training
y_x = T.argmax(py_x, axis=1) # maxima predictions

cost = T.mean(T.nnet.categorical_crossentropy(noise_py_x, Y)) # classification matrix to optimize - maximize the value that is actually there and minimize the others
params = [w, w2, w3, w4, w_o]
updates = RMSprop(cost, params, lr=0.001) # update function

train = theano.function(inputs=[X, Y], outputs=cost, updates=updates, allow_input_downcast=True) # compile train function
predict = theano.function(inputs=[X], outputs=y_x, allow_input_downcast=True) # compile predict function

# testing
for i in range(100):
    for start, end in zip(range(0, len(trX), 128), range(128, len(trX), 128)):
        cost = train(trX[start:end], trY[start:end])
    print np.mean(np.argmax(teY, axis=1) == predict(teX))

print "stop:", time.strftime('%X %x %Z')

# do you want to save the model?
save_model("test_saving_model.pkl", train)<commit_msg>commented save_model<commit_after>import time
import cPickle
import numpy as np
import theano
from theano import tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from load import load_data
from theano.tensor.nnet.conv import conv2d
from theano.tensor.signal.downsample import max_pool_2d
from theano.tensor.signal.downsample import DownsampleFactorMax

theano.config.floatX='float32'

srng = RandomStreams()

def floatX(X):
    """
    Convert X to float32 or float64, depending on how we configure theano.
    """
    return np.asarray(X, dtype=theano.config.floatX)

def init_weights(shape):
    """
    Initialize model parameters.
    """
    return theano.shared(floatX(np.random.randn(*shape) * 0.01))

def rectify(X):
    """
    Rectifier.
    """
    return T.maximum(X, 0.)

def softmax(X):
    """
    Numerically stable softmax.
    """
    e_x = T.exp(X - X.max(axis=1).dimshuffle(0, 'x'))
    return e_x / e_x.sum(axis=1).dimshuffle(0, 'x')

def dropout(X, p=0.):
    """
    Way of injecting noise into our network - help us with overfitting.
    Randomly drop values and scale rest.
    """
    if p > 0:
        retain_prob = 1 - p
        X *= srng.binomial(X.shape, p=retain_prob, dtype=theano.config.floatX)
        X /= retain_prob
    return X

def RMSprop(cost, params, lr=0.001, rho=0.9, epsilon=1e-6):
    """
    Learn different networks better and learning them quicker.
    """
    grads = T.grad(cost=cost, wrt=params)
    updates = []
    for p, g in zip(params, grads):
        acc = theano.shared(p.get_value() * 0.)
        acc_new = rho * acc + (1 - rho) * g ** 2
        gradient_scaling = T.sqrt(acc_new + epsilon)
        g = g / gradient_scaling
        updates.append((acc, acc_new))
        updates.append((p, p - lr * g))
    return updates

def model(X, w, w2, w3, w4, p_drop_conv, p_drop_hidden):
    """
        Perform convolution and everything belonging to it.
        Code is split into 4 "blocks" - 3 blocks of computation and last block where we have fully connected layer.

        In each block we perform convolution, followed by rectify activation function. After that we perform max pool
        and add some noise with dropout. This is repeated for layers 2 and 3.
        Last layer is fully connected layer, which connects all the filters to 500 hidden nodes. These nodes are then
        connected to the output nodes.
    """
    # block of computation
    # border_mode='valid': apply filter wherever it completely overlaps with the input
    l1a = rectify(conv2d(X, w, border_mode='valid', subsample=(1, conv1_stride))) # stride along one (horizontal) dimension only
    l1 = max_pool_2d(l1a, (1, downscale1), st=(1, stride1)) # (1,1)=(vertical, horizontal) downscale, st=(1, step): move to every stride1 column and perform max_pooling there
    l1 = dropout(l1, p_drop_conv)

    # repeat block
    l2a = rectify(conv2d(l1, w2, subsample=(1, 1))) # stride along horizontal
    l2 = max_pool_2d(l2a, (1, downscale2), st=(1, stride2))
    l2 = dropout(l2, p_drop_conv)

    l3a = rectify(conv2d(l2, w3, subsample=(1, 1))) # stride along horizontal
    l3b = max_pool_2d(l3a, (1, downscale3), st=(1, stride3))
    l3 = T.flatten(l3b, outdim=2) # convert from 4tensor to normal matrix
    l3 = dropout(l3, p_drop_conv)

    l4 = rectify(T.dot(l3, w4))
    l4 = dropout(l4, p_drop_hidden)

    pyx = softmax(T.dot(l4, w_o))
    return l1, l2, l3, l4, pyx

# shranjeval bomo train
def save_model(filename, model):
    print "saving model..."
    f = open(filename, 'wb')
    cPickle.dump(model, f, protocol=cPickle.HIGHEST_PROTOCOL)
    f.close()
    print "model saved..."

# loadamo pa filename v train
def load_model(filename):
    f = open(filename, 'rb')
    loaded_obj = cPickle.load(f)
    f.close()
    return loaded_obj

print "start:", time.strftime('%X %x %Z')
#trX, teX, trY, teY, num_of_classes = seq_load(onehot=True, seed=7970223320302509880) # load data
transmission_dict = {'A': [1, 0, 0, 0], 'T': [0, 1, 0, 0], 'C': [0, 0, 1, 0], 'G': [0, 0, 0, 1]}
trX, teX, trY, teY, num_of_classes = load_data(filename="test", test=0.2, transmission_dict=transmission_dict, seed=0, sample=0.2)
#X, Y, num_of_classes = ...
#cross validation oz kakrsnokoli razporejanje (npr 80-20)
#trX, teX, trY, teY = ...

print(trX.shape)
input_len = trX.shape[1] # save input length for further use
trX = trX.reshape(-1, 1, 1, input_len)
teX = teX.reshape(-1, 1, 1, input_len)

# matrix types
X = T.ftensor4()
Y = T.fmatrix()

# size of convolution windows, for each layer different values can be used
cwin1=4*6  # multiples of 4 because of data representation
cwin2=3
cwin3=2

num_filters_1=32 / 2  # how many different filters to learn at each layer
num_filters_2=48 / 2
num_filters_3=64 / 2
w = init_weights((num_filters_1, 1, 1, cwin1)) # first convolution, 32 filters, stack size 1, 1 rows, cwin1 columns
w2 = init_weights((num_filters_2, num_filters_1, 1, cwin2)) # second convolution, 64 filters, stack size 32 (one stack for each filter from previous layer), 1 row, cwin2 columns
w3 = init_weights((num_filters_3, num_filters_2, 1, cwin3)) # third convolution, 128 filters, stack size 64 (one stack for each filter from previous layes), 1 row, cwin3 columns

print "#### CONVOLUTION PARAMETERS ####"
print "cwin1 %d" % cwin1
print "cwin2 %d" % cwin2
print "cwin3 %d" % cwin3
print "num_filters_1 %d" % num_filters_1
print "num_filters_2 %d" % num_filters_2
print "num_filters_3 %d" % num_filters_3

# convolution: filters are moved by one position at a time, see parameter subsample=(1, 1)
#
# max pooling:
#   scaling the input before applying the maxpool filter and
#   displacement (stride) when sliding the max pool filters
conv1_stride=4

stride1=2
downscale1=3

stride2=2
downscale2=2

stride3=2
downscale3=1

# l1 conv:
es = input_len
es = (es - cwin1 + 1)
es = es / conv1_stride
# l1 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale1), st=(1, stride1))[1] # downscale for first layer
print "l1 es:", es

# l2 conv:
es = (es - cwin2 + 1)
# l2 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale2), st=(1, stride2))[1] # downscale for second layer
print "l2 es:", es

# l3 conv:
es = (es - cwin3 + 1)
# l3 max_pool:
es = DownsampleFactorMax.out_shape((1, es), (1, downscale3), st=(1, stride3))[1] # downscale for third layer
print "l3 es:", es

# downscaling is performed so that we correctly set number of filters in last layer

w4 = init_weights((num_filters_3 * es, 500))  # fully conected last layer, connects the outputs of 128 filters to 500 (arbitrary) hidden nodes, which are then connected to the output nodes
w_o = init_weights((500, num_of_classes))  # number of exptected classes

noise_l1, noise_l2, noise_l3, noise_l4, noise_py_x = model(X, w, w2, w3, w4, 0.2, 0.5) # noise during training
l1, l2, l3, l4, py_x = model(X, w, w2, w3, w4, 0., 0.) # no noise during training
y_x = T.argmax(py_x, axis=1) # maxima predictions

cost = T.mean(T.nnet.categorical_crossentropy(noise_py_x, Y)) # classification matrix to optimize - maximize the value that is actually there and minimize the others
params = [w, w2, w3, w4, w_o]
updates = RMSprop(cost, params, lr=0.001) # update function

train = theano.function(inputs=[X, Y], outputs=cost, updates=updates, allow_input_downcast=True) # compile train function
predict = theano.function(inputs=[X], outputs=y_x, allow_input_downcast=True) # compile predict function

# testing
for i in range(100):
    for start, end in zip(range(0, len(trX), 128), range(128, len(trX), 128)):
        cost = train(trX[start:end], trY[start:end])
    print np.mean(np.argmax(teY, axis=1) == predict(teX))

print "stop:", time.strftime('%X %x %Z')

# do you want to save the model?
#save_model("test_saving_model.pkl", train)<|endoftext|>


<commit_before>#Test and demonstration of the NumPy Bridge.
from __future__ import print_function

from operator import mul
from numbers import Number
import subprocess
import warnings
import random
import pickle
import time
import uuid
import copy
import sys
import os
from os.path import join
import re
import argparse

import numpy as np
import bohrium as bh
from functools import reduce

class TYPES:
    NORMAL_INT   = ['np.int32','np.int64','np.uint32','np.uint64']
    ALL_INT      = NORMAL_INT + ['np.int8','np.int16','np.uint8','np.uint16']
    SIGNED_INT   = ['np.int8', 'np.int16', 'np.int32','np.int64']
    UNSIGNED_INT = list(set(ALL_INT) - set(SIGNED_INT))
    COMPLEX      = ['np.complex64', 'np.complex128']
    NORMAL_FLOAT = ['np.float32','np.float64']
    ALL_FLOAT    = NORMAL_FLOAT #+ ['np.float16'] float16 is only supported by the GPU
    ALL_SIGNED   = SIGNED_INT + ALL_FLOAT + COMPLEX
    NORMAL       = NORMAL_INT + NORMAL_FLOAT
    ALL          = ALL_INT + ALL_FLOAT + COMPLEX

class _C:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    def disable(self):
        self.HEADER = ''
        self.OKBLUE = ''
        self.OKGREEN = ''
        self.WARNING = ''
        self.FAIL = ''
        self.ENDC = ''

def gen_shapes(max_ndim, max_dim, iters=0, min_ndim=1):
    for ndim in xrange(min_ndim,max_ndim+1):
        shape = [1]*ndim
        if iters:
            yield shape #Min shape
            yield [max_dim]*(ndim) #Max shape
            for _ in xrange(iters):
                for d in xrange(len(shape)):
                    shape[d] = np.random.randint(1,max_dim)
                yield shape
        else:
            finished = False
            while not finished:
                yield shape
                #Find next shape
                d = ndim-1
                while True:
                    shape[d] += 1
                    if shape[d] > max_dim:
                        shape[d] = 1
                        d -= 1
                        if d < 0:
                            finished = True
                            break
                    else:
                        break

def gen_views(max_ndim, max_dim, iters=0, min_ndim=1, dtype="np.float32"):
    for shape in gen_shapes(max_ndim, max_dim, iters, min_ndim):
        #Base array
        cmd = "a[0] = self.array(%s,%s);"%(shape, dtype)
        yield cmd
        #Views with offset per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += "1:,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

        #Views with negative offset per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += ":-1,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

        #Views with steps per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += "::2,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

class numpytest:
    def __init__(self):
        self.config = {'maxerror':0.0}
        self.runtime = {}
        self.random = random.Random()
        self.random.seed(42)

    def init(self):
        pass

    def asarray(self, data, dtype):
        return np.asarray(data, dtype=dtype)

    def ones(self, shape, dtype):
        return np.asarray(shape, dtype=dtype)

    def zeros(self, shape, dtype):
        return np.zeros(shape, dtype=dtype)

    def arange(self, begin, end, step, dtype):
        return np.arange(begin, end, step, dtype=dtype)

    def array(self,dims,dtype,high=False):
        try:
            total = reduce(mul,dims)
        except TypeError:
            total = dims
            dims = (dims,)
        dtype = np.dtype(dtype).type
        if dtype is np.bool:
            res = np.random.random_integers(0,1,dims)
        elif dtype in [np.int8, np.uint8]:
            res = np.random.random_integers(1,3,dims)
        elif dtype is np.int16:
            res = np.random.random_integers(1,5,dims)
        elif dtype is np.uint16:
            res = np.random.random_integers(1,6,dims)
        elif dtype in [np.float32, np.float64]:
            res = np.random.random(size=dims)
            if high:
                res = (res+1)*10
        elif dtype in [np.complex64, np.complex128]:
            res = np.random.random(size=dims)+np.random.random(size=dims)*1j
        else:
            res = np.random.random_integers(1,8,size=dims)
        if len(res.shape) == 0:#Make sure scalars is arrays.
            res = np.asarray(res)
            res.shape = dims
        return np.asarray(res, dtype=dtype)

class BenchHelper:
    """Mixin for numpytest to aid the execution of Benchmarks."""

    def init(self):
        """
        This function is used as a means to control til --dtype argument
        passed to the benchmark script and provide a uuid for benchmark output.
        """
        #Lets make sure that benchpress is installed
        try:
            p = subprocess.Popen(
                ['bp-info', '--benchmarks'],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
            out, err = p.communicate()
            rc = p.returncode
        except OSError:
            print("ERROR: benchpress is not installed -- skipping test.")
            raise StopIteration()

        self.uuid = str(uuid.uuid4())
        for dtype in self.dtypes:
            yield ({0:bh.empty(self.size, bohrium=False, dtype=dtype)},
                   "%s: " % str(dtype)
            )

    def get_meta(self, arrays):
        """Determine target and dtype based on meta-data from pseudo_init."""

        target = "None"
        if 'bohrium.ndarray' in str(type(arrays[0])):
            target = "bhc"

        dtype = str(arrays[0].dtype)

        return (target, dtype)

    def run(self, pseudo_input):
        """
        Run the Benchmark script and return the result.

        Benchmarks are assumed to be installed along with the Bohrium module.
        """

        (target, dtype) = self.get_meta(pseudo_input)

        # Setup output filename
        outputfn = "/tmp/%s_%s_%s_output_%s.npz" % (
            self.script, dtype, target, self.uuid
        )

        benchmarks_dir, err = subprocess.Popen(           # Execute the benchmark
            ['bp-info', '--benchmarks'],
            stdout  = subprocess.PIPE,
            stderr  = subprocess.PIPE,
        ).communicate()

        sys_exec = [sys.executable, "-m", "bohrium"] if target else [sys.executable]
        benchmark_path = os.sep.join([benchmarks_dir.strip(), self.script, "python_numpy", self.script+ ".py"])

        # Setup command
        cmd = sys_exec + [
            benchmark_path,
            '--size='       +self.sizetxt,
            '--dtype='      +str(dtype),
            '--target='    +target,
            '--outputfn='   +outputfn
        ]

        # Setup the inputfn if one is needed/provided
        if self.inputfn:
            npt_path = os.path.dirname(sys.argv[0])
            if not npt_path:
                npt_path = "./"

            inputfn = "%s/datasets/%s" % (
                npt_path,
                self.inputfn.format(dtype)
            )
            cmd.append('--inputfn')
            cmd.append(inputfn)

            if not os.path.exists(inputfn):
                raise Exception('File does not exist: %s' % inputfn)

        p = subprocess.Popen(           # Execute the benchmark
            cmd,
            stdout  = subprocess.PIPE,
            stderr  = subprocess.PIPE,
        )
        out, err = p.communicate()
        if 'elapsed-time' not in out:
            raise Exception("Benchmark error [stdout:%s,stderr:%s]" % (out, err))
        if err and not re.match("\[[0-9]+ refs\]", err): #We accept the Python object count
            raise Exception("Benchmark error[%s]" % err)

        if not os.path.exists(outputfn):
            raise Exception('Benchmark did not produce any output, expected: %s' % outputfn)

        if err and not re.match("\[[0-9]+ refs\]", err): #We accept the Python object count
            err_chunked = ", ".join(err.split("\n"))
            print(_C.OKBLUE + "[CMD] %s" % " ".join(cmd) + _C.ENDC)
            print(_C.WARNING + "[Warning] The CMD above wrote the following to stderr: [%s]" % err_chunked + _C.ENDC)

        npzs    = np.load(outputfn)     # Load the result from disk
        res     = {}
        for k in npzs:
            res[k] = npzs[k]
        del npzs                        # Delete npz

        if os.path.exists(outputfn):    # Delete the result from disk
            os.remove(outputfn)

        # Convert to whatever namespace it ought to be in
        res['res'] = bh.array(res['res'], bohrium=target!="None")

        return (res['res'], ' '.join(cmd))

if __name__ == "__main__":
    warnings.simplefilter('error')#Warnings will raise exceptions
    pydebug = True

    try:
        sys.gettotalrefcount()
    except AttributeError:
        pydebug = False

    parser = argparse.ArgumentParser(description='Runs the test suite, which consist of all the test_*.py files')
    parser.add_argument(
        '--file',
        type=str,
        action='append',
        default=[],
        help='Add test file (supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude',
        type=str,
        action='append',
        default=[],
        help='Exclude test file (supports multiple use of this argument)'
    )
    parser.add_argument(
        '--test',
        type=str,
        action='append',
        default=[],
        help='Only run a specific test method '\
             '(supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude-test',
        type=str,
        action='append',
        default=[],
        help='Only run a specific test method '\
             '(supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude-benchmarks',
        action='store_true',
        help='Excludes all benchmak tests'
    )
    args = parser.parse_args()
    if len(args.file) == 0:
        args.file = os.listdir(os.path.dirname(os.path.abspath(__file__)))

    print("*"*3, "Testing the equivalency of Bohrium-NumPy and NumPy", "*"*3)
    for f in args.file:

        if f.startswith("test_") and f.endswith("py") and f not in args.exclude:
            m = f[:-3]#Remove ".py"
            m = __import__(m)
            #All test classes starts with "test_"
            for cls in [o for o in dir(m) if o.startswith("test_") and \
                        (True if args.test and o in args.test or not args.test else False)]:
                if cls in args.exclude_test:
                    continue

                cls_obj  = getattr(m, cls)
                cls_inst = cls_obj()

                import inspect
                is_benchmark = BenchHelper.__name__ in [c.__name__ for c in inspect.getmro(cls_obj)]
                if args.exclude_benchmarks and is_benchmark:
                    continue

                #All test methods starts with "test_"
                for mth in [o for o in dir(cls_obj) if o.startswith("test_")]:
                    name = "%s/%s/%s"%(f,cls[5:],mth[5:])
                    print("Testing %s"%(name))
                    for (np_arys,cmd) in getattr(cls_inst,"init")():
                        #Get Bohrium arrays
                        bh_arys = []
                        for a in np_arys.values():
                            bh_arys.append(bh.array(a))
                        #Execute using NumPy
                        (res1,cmd1) = getattr(cls_inst,mth)(np_arys)
                        res1 = res1.copy()

                        #Execute using Bohrium
                        (res2,cmd2) = getattr(cls_inst,mth)(bh_arys)
                        cmd += cmd1
                        try:
                            if not np.isscalar(res2):
                                res2 = res2.copy2numpy()
                        except RuntimeError as error_msg:
                            print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                            print(_C.FAIL + str(error_msg) + _C.ENDC)
                        else:
                            rtol = cls_inst.config['maxerror']
                            atol = rtol * 0.1
                            if not np.allclose(res1, res2, rtol=rtol, atol=atol):

                                if 'warn_on_err' in cls_inst.config:
                                    print(_C.WARNING + "[Warning] %s"%(name) + _C.ENDC)
                                    print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                                    print(_C.OKGREEN + str(res1) + _C.ENDC)
                                    print(_C.FAIL + str(res2) + _C.ENDC)
                                    print(_C.WARNING + str(cls_inst.config['warn_on_err']) + _C.ENDC)
                                    print(_C.OKBLUE + str("Manual verification is needed.") + _C.ENDC)
                                else:
                                    print(_C.FAIL + "[Error] %s"%(name) + _C.ENDC)
                                    print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                                    print(_C.OKGREEN + str(res1) + _C.ENDC)
                                    print(_C.FAIL + str(res2) + _C.ENDC)
                                    sys.exit (1)

    print("*"*24, "Finish", "*"*24)
<commit_msg>numpytest: Added silent accept of fuse_model errors.<commit_after>#Test and demonstration of the NumPy Bridge.
from __future__ import print_function

from operator import mul
from numbers import Number
import subprocess
import warnings
import random
import pickle
import time
import uuid
import copy
import sys
import os
from os.path import join
import re
import argparse

import numpy as np
import bohrium as bh
from functools import reduce

class TYPES:
    NORMAL_INT   = ['np.int32','np.int64','np.uint32','np.uint64']
    ALL_INT      = NORMAL_INT + ['np.int8','np.int16','np.uint8','np.uint16']
    SIGNED_INT   = ['np.int8', 'np.int16', 'np.int32','np.int64']
    UNSIGNED_INT = list(set(ALL_INT) - set(SIGNED_INT))
    COMPLEX      = ['np.complex64', 'np.complex128']
    NORMAL_FLOAT = ['np.float32','np.float64']
    ALL_FLOAT    = NORMAL_FLOAT #+ ['np.float16'] float16 is only supported by the GPU
    ALL_SIGNED   = SIGNED_INT + ALL_FLOAT + COMPLEX
    NORMAL       = NORMAL_INT + NORMAL_FLOAT
    ALL          = ALL_INT + ALL_FLOAT + COMPLEX

class _C:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    def disable(self):
        self.HEADER = ''
        self.OKBLUE = ''
        self.OKGREEN = ''
        self.WARNING = ''
        self.FAIL = ''
        self.ENDC = ''

def gen_shapes(max_ndim, max_dim, iters=0, min_ndim=1):
    for ndim in xrange(min_ndim,max_ndim+1):
        shape = [1]*ndim
        if iters:
            yield shape #Min shape
            yield [max_dim]*(ndim) #Max shape
            for _ in xrange(iters):
                for d in xrange(len(shape)):
                    shape[d] = np.random.randint(1,max_dim)
                yield shape
        else:
            finished = False
            while not finished:
                yield shape
                #Find next shape
                d = ndim-1
                while True:
                    shape[d] += 1
                    if shape[d] > max_dim:
                        shape[d] = 1
                        d -= 1
                        if d < 0:
                            finished = True
                            break
                    else:
                        break

def gen_views(max_ndim, max_dim, iters=0, min_ndim=1, dtype="np.float32"):
    for shape in gen_shapes(max_ndim, max_dim, iters, min_ndim):
        #Base array
        cmd = "a[0] = self.array(%s,%s);"%(shape, dtype)
        yield cmd
        #Views with offset per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += "1:,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

        #Views with negative offset per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += ":-1,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

        #Views with steps per dimension
        for d in xrange(len(shape)):
            if shape[d] > 1:
                s = "a[0] = a[0]["
                for _ in xrange(d):
                    s += ":,"
                s += "::2,"
                for _ in xrange(len(shape)-(d+1)):
                    s += ":,"
                s = s[:-1] + "];"
                yield cmd + s

class numpytest:
    def __init__(self):
        self.config = {'maxerror':0.0}
        self.runtime = {}
        self.random = random.Random()
        self.random.seed(42)

    def init(self):
        pass

    def asarray(self, data, dtype):
        return np.asarray(data, dtype=dtype)

    def ones(self, shape, dtype):
        return np.asarray(shape, dtype=dtype)

    def zeros(self, shape, dtype):
        return np.zeros(shape, dtype=dtype)

    def arange(self, begin, end, step, dtype):
        return np.arange(begin, end, step, dtype=dtype)

    def array(self,dims,dtype,high=False):
        try:
            total = reduce(mul,dims)
        except TypeError:
            total = dims
            dims = (dims,)
        dtype = np.dtype(dtype).type
        if dtype is np.bool:
            res = np.random.random_integers(0,1,dims)
        elif dtype in [np.int8, np.uint8]:
            res = np.random.random_integers(1,3,dims)
        elif dtype is np.int16:
            res = np.random.random_integers(1,5,dims)
        elif dtype is np.uint16:
            res = np.random.random_integers(1,6,dims)
        elif dtype in [np.float32, np.float64]:
            res = np.random.random(size=dims)
            if high:
                res = (res+1)*10
        elif dtype in [np.complex64, np.complex128]:
            res = np.random.random(size=dims)+np.random.random(size=dims)*1j
        else:
            res = np.random.random_integers(1,8,size=dims)
        if len(res.shape) == 0:#Make sure scalars is arrays.
            res = np.asarray(res)
            res.shape = dims
        return np.asarray(res, dtype=dtype)

class BenchHelper:
    """Mixin for numpytest to aid the execution of Benchmarks."""

    def init(self):
        """
        This function is used as a means to control til --dtype argument
        passed to the benchmark script and provide a uuid for benchmark output.
        """
        #Lets make sure that benchpress is installed
        try:
            p = subprocess.Popen(
                ['bp-info', '--benchmarks'],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
            out, err = p.communicate()
            rc = p.returncode
        except OSError:
            print("ERROR: benchpress is not installed -- skipping test.")
            raise StopIteration()

        self.uuid = str(uuid.uuid4())
        for dtype in self.dtypes:
            yield ({0:bh.empty(self.size, bohrium=False, dtype=dtype)},
                   "%s: " % str(dtype)
            )

    def get_meta(self, arrays):
        """Determine target and dtype based on meta-data from pseudo_init."""

        target = "None"
        if 'bohrium.ndarray' in str(type(arrays[0])):
            target = "bhc"

        dtype = str(arrays[0].dtype)

        return (target, dtype)

    def run(self, pseudo_input):
        """
        Run the Benchmark script and return the result.

        Benchmarks are assumed to be installed along with the Bohrium module.
        """

        (target, dtype) = self.get_meta(pseudo_input)

        # Setup output filename
        outputfn = "/tmp/%s_%s_%s_output_%s.npz" % (
            self.script, dtype, target, self.uuid
        )

        benchmarks_dir, err = subprocess.Popen(           # Execute the benchmark
            ['bp-info', '--benchmarks'],
            stdout  = subprocess.PIPE,
            stderr  = subprocess.PIPE,
        ).communicate()

        sys_exec = [sys.executable, "-m", "bohrium"] if target else [sys.executable]
        benchmark_path = os.sep.join([benchmarks_dir.strip(), self.script, "python_numpy", self.script+ ".py"])

        # Setup command
        cmd = sys_exec + [
            benchmark_path,
            '--size='       +self.sizetxt,
            '--dtype='      +str(dtype),
            '--target='    +target,
            '--outputfn='   +outputfn
        ]

        # Setup the inputfn if one is needed/provided
        if self.inputfn:
            npt_path = os.path.dirname(sys.argv[0])
            if not npt_path:
                npt_path = "./"

            inputfn = "%s/datasets/%s" % (
                npt_path,
                self.inputfn.format(dtype)
            )
            cmd.append('--inputfn')
            cmd.append(inputfn)

            if not os.path.exists(inputfn):
                raise Exception('File does not exist: %s' % inputfn)

        p = subprocess.Popen(           # Execute the benchmark
            cmd,
            stdout  = subprocess.PIPE,
            stderr  = subprocess.PIPE,
        )
        out, err = p.communicate()
        if 'elapsed-time' not in out:
            raise Exception("Benchmark error [stdout:%s,stderr:%s]" % (out, err))

        if not os.path.exists(outputfn):
            raise Exception('Benchmark did not produce any output, expected: %s' % outputfn)
        #
        # We silently accept these errors when output to stderr:
        #
        #   * The Python object count
        #   * Unsupported fuse model
        #   * Unknown fuse model
        #
        if err and not re.match("\[[0-9]+ refs\]", err) \
               and 'unsupported fuse model' not in err  \
               and 'unknown fuse model' not in err:
            err_chunked = ", ".join(err.split("\n"))
            print(_C.OKBLUE + "[CMD] %s" % " ".join(cmd) + _C.ENDC)
            print(_C.WARNING + "[Warning] The CMD above wrote the following to stderr: [%s]" % err_chunked + _C.ENDC)

        npzs    = np.load(outputfn)     # Load the result from disk
        res     = {}
        for k in npzs:
            res[k] = npzs[k]
        del npzs                        # Delete npz

        if os.path.exists(outputfn):    # Delete the result from disk
            os.remove(outputfn)

        # Convert to whatever namespace it ought to be in
        res['res'] = bh.array(res['res'], bohrium=target!="None")

        return (res['res'], ' '.join(cmd))

if __name__ == "__main__":
    warnings.simplefilter('error')#Warnings will raise exceptions
    pydebug = True

    try:
        sys.gettotalrefcount()
    except AttributeError:
        pydebug = False

    parser = argparse.ArgumentParser(description='Runs the test suite, which consist of all the test_*.py files')
    parser.add_argument(
        '--file',
        type=str,
        action='append',
        default=[],
        help='Add test file (supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude',
        type=str,
        action='append',
        default=[],
        help='Exclude test file (supports multiple use of this argument)'
    )
    parser.add_argument(
        '--test',
        type=str,
        action='append',
        default=[],
        help='Only run a specific test method '\
             '(supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude-test',
        type=str,
        action='append',
        default=[],
        help='Only run a specific test method '\
             '(supports multiple use of this argument)'
    )
    parser.add_argument(
        '--exclude-benchmarks',
        action='store_true',
        help='Excludes all benchmak tests'
    )
    args = parser.parse_args()
    if len(args.file) == 0:
        args.file = os.listdir(os.path.dirname(os.path.abspath(__file__)))

    print("*"*3, "Testing the equivalency of Bohrium-NumPy and NumPy", "*"*3)
    for f in args.file:

        if f.startswith("test_") and f.endswith("py") and f not in args.exclude:
            m = f[:-3]#Remove ".py"
            m = __import__(m)
            #All test classes starts with "test_"
            for cls in [o for o in dir(m) if o.startswith("test_") and \
                        (True if args.test and o in args.test or not args.test else False)]:
                if cls in args.exclude_test:
                    continue

                cls_obj  = getattr(m, cls)
                cls_inst = cls_obj()

                import inspect
                is_benchmark = BenchHelper.__name__ in [c.__name__ for c in inspect.getmro(cls_obj)]
                if args.exclude_benchmarks and is_benchmark:
                    continue

                #All test methods starts with "test_"
                for mth in [o for o in dir(cls_obj) if o.startswith("test_")]:
                    name = "%s/%s/%s"%(f,cls[5:],mth[5:])
                    print("Testing %s"%(name))
                    for (np_arys,cmd) in getattr(cls_inst,"init")():
                        #Get Bohrium arrays
                        bh_arys = []
                        for a in np_arys.values():
                            bh_arys.append(bh.array(a))
                        #Execute using NumPy
                        (res1,cmd1) = getattr(cls_inst,mth)(np_arys)
                        res1 = res1.copy()

                        #Execute using Bohrium
                        (res2,cmd2) = getattr(cls_inst,mth)(bh_arys)
                        cmd += cmd1
                        try:
                            if not np.isscalar(res2):
                                res2 = res2.copy2numpy()
                        except RuntimeError as error_msg:
                            print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                            print(_C.FAIL + str(error_msg) + _C.ENDC)
                        else:
                            rtol = cls_inst.config['maxerror']
                            atol = rtol * 0.1
                            if not np.allclose(res1, res2, rtol=rtol, atol=atol):

                                if 'warn_on_err' in cls_inst.config:
                                    print(_C.WARNING + "[Warning] %s"%(name) + _C.ENDC)
                                    print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                                    print(_C.OKGREEN + str(res1) + _C.ENDC)
                                    print(_C.FAIL + str(res2) + _C.ENDC)
                                    print(_C.WARNING + str(cls_inst.config['warn_on_err']) + _C.ENDC)
                                    print(_C.OKBLUE + str("Manual verification is needed.") + _C.ENDC)
                                else:
                                    print(_C.FAIL + "[Error] %s"%(name) + _C.ENDC)
                                    print(_C.OKBLUE + "[CMD]   %s"%cmd + _C.ENDC)
                                    print(_C.OKGREEN + str(res1) + _C.ENDC)
                                    print(_C.FAIL + str(res2) + _C.ENDC)
                                    sys.exit (1)

    print("*"*24, "Finish", "*"*24)
<|endoftext|>


<commit_before><commit_msg>Removed unnecessary Charge._attach_objects_hook() method<commit_after><|endoftext|>


<commit_before>#!/usr/bin/env python

"""
B.5 Macros for text

"""

from plasTeX import Command, Environment, sourceChildren

class frenchspacing(Command):
    unicode = u''

class nonfrenchspacing(Command):
    unicode = u''

class normalbaselines(Command):
    unicode = u''

class lq(Command):
    unicode = unichr(8216)

class rq(Command):
    unicode = unichr(8217)

class lbrack(Command):
    unicode = u'['

class rbrack(Command):
    unicode = u']'

class space(Command):
    unicode = u' '

class empty(Command):
    unicode = u''

class null(Command):
    unicode = u''

class bgroup(Command):

    def invoke(self, tex):
        self.ownerDocument.context.push()

    def digest(self, tokens):
        # Absorb the tokens that belong to us
        for item in tokens:
            if item.nodeType == Command.ELEMENT_NODE:
                if item.level < self.ENDSECTIONS_LEVEL:
                    tokens.push(item)
                    break
                if isinstance(item, (egroup,endgroup)):
                    break
                if item.contextDepth < self.contextDepth:
                    tokens.push(item)
                    break
                item.parentNode = self
                item.digest(tokens)
            self.appendChild(item)
        self.paragraphs(force=False)

    @property
    def source(self):
        if self.hasChildNodes():
            return '{%s}' % sourceChildren(self)
        return '{'

class begingroup(bgroup):
    pass

class egroup(Command):
    unicode = u''

    def invoke(self, tex):
        self.ownerDocument.context.pop()

    @property
    def source(self):
        return '}'

    def digest(self, tokens):
        return

class endgroup(egroup):
    unicode = u''

class obeyspaces(Command):
    unicode = u''

class loop(Command):
    args = 'var:Tok'
    unicode = u''

class iterate(Command):
    unicode = u''

class repeat(Command):
    unicode = u''

class enskip(Command):
    pass

class enspace(Command):
    pass

class quad(Command):
    pass

class qquad(Command):
    pass

class thinspace(Command):
    pass

class negthinspace(Command):
    pass

class hglue(Command):
    pass

class vglue(Command):
    pass

class topglue(Command):
    pass

class nointerlineskip(Command):
    pass

class offinterlineskip(Command):
    pass

class smallskip(Command):
    pass

class medskip(Command):
    pass

class bigskip(Command):
    pass

class TeXBreak(Command):
    macroName = 'break'
    unicode = u''

class allowbreak(Command):
    unicode = u''

class ControlSpace(Command):
    macroName = 'active::~'

class slash(Command):
    pass

class filbreak(Command):
    pass

class goodbreak(Command):
    pass

class eject(Command):
    unicode = u''

class supereject(Command):
    unicode = u''

class removelastskip(Command):
    pass

class smallbreak(Command):
    pass

class medbreak(Command):
    pass

class bigbreak(Command):
    pass

class line(Command):
    pass

class leftline(Command):
    args = 'self'

class llap(Command):
    args = 'self'

class centerline(Command):
    args = 'self'

class underbar(Command):
    args = 'self'

class hang(Command):
    pass

class textindent(Command):
    args = 'self'

class narrower(Command):
    pass

class raggedright(Environment):
    pass

#
# Accents are done in the LaTeX package
#

class dots(Command):
    unicode = unichr(8230)
<commit_msg>Fix sourcing of empty tokens<commit_after>#!/usr/bin/env python

"""
B.5 Macros for text

"""

from plasTeX import Command, Environment, sourceChildren

class frenchspacing(Command):
    unicode = u''

class nonfrenchspacing(Command):
    unicode = u''

class normalbaselines(Command):
    unicode = u''

class lq(Command):
    unicode = unichr(8216)

class rq(Command):
    unicode = unichr(8217)

class lbrack(Command):
    unicode = u'['

class rbrack(Command):
    unicode = u']'

class space(Command):
    unicode = u' '

class empty(Command):
    unicode = u''

class null(Command):
    unicode = u''

class bgroup(Command):

    def invoke(self, tex):
        self.ownerDocument.context.push()

    def digest(self, tokens):
        # Absorb the tokens that belong to us
        for item in tokens:
            if item.nodeType == Command.ELEMENT_NODE:
                if item.level < self.ENDSECTIONS_LEVEL:
                    tokens.push(item)
                    break
                if isinstance(item, (egroup,endgroup)):
                    self.endit = True
                    break
                if item.contextDepth < self.contextDepth:
                    tokens.push(item)
                    break
                item.parentNode = self
                item.digest(tokens)
            self.appendChild(item)
        self.paragraphs(force=False)

    @property
    def source(self):
        if self.hasChildNodes():
            return '{%s}' % sourceChildren(self)
        elif hasattr(self, 'endit'):
            return '{}'
        return '{'

class begingroup(bgroup):
    pass

class egroup(Command):
    unicode = u''

    def invoke(self, tex):
        self.ownerDocument.context.pop()

    @property
    def source(self):
        return '}'

    def digest(self, tokens):
        return

class endgroup(egroup):
    unicode = u''

class obeyspaces(Command):
    unicode = u''

class loop(Command):
    args = 'var:Tok'
    unicode = u''

class iterate(Command):
    unicode = u''

class repeat(Command):
    unicode = u''

class enskip(Command):
    pass

class enspace(Command):
    pass

class quad(Command):
    pass

class qquad(Command):
    pass

class thinspace(Command):
    pass

class negthinspace(Command):
    pass

class hglue(Command):
    pass

class vglue(Command):
    pass

class topglue(Command):
    pass

class nointerlineskip(Command):
    pass

class offinterlineskip(Command):
    pass

class smallskip(Command):
    pass

class medskip(Command):
    pass

class bigskip(Command):
    pass

class TeXBreak(Command):
    macroName = 'break'
    unicode = u''

class allowbreak(Command):
    unicode = u''

class ControlSpace(Command):
    macroName = 'active::~'

class slash(Command):
    pass

class filbreak(Command):
    pass

class goodbreak(Command):
    pass

class eject(Command):
    unicode = u''

class supereject(Command):
    unicode = u''

class removelastskip(Command):
    pass

class smallbreak(Command):
    pass

class medbreak(Command):
    pass

class bigbreak(Command):
    pass

class line(Command):
    pass

class leftline(Command):
    args = 'self'

class llap(Command):
    args = 'self'

class centerline(Command):
    args = 'self'

class underbar(Command):
    args = 'self'

class hang(Command):
    pass

class textindent(Command):
    args = 'self'

class narrower(Command):
    pass

class raggedright(Environment):
    pass

#
# Accents are done in the LaTeX package
#

class dots(Command):
    unicode = unichr(8230)
<|endoftext|>