<commit_before># Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

import pytest
import re
import time

from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
from tests.common.skip import SkipIfNotHdfsMinicluster
from subprocess import check_call, check_output

@SkipIfNotHdfsMinicluster.tuned_for_minicluster
class TestHdfsTimeouts(CustomClusterTestSuite):
  """Test to verify that HDFS operations time out correctly."""

  @classmethod
  def get_workload(self):
    return 'functional-query'

  @pytest.mark.execute_serially
  @CustomClusterTestSuite.with_args(
    impalad_args="--hdfs_operation_timeout_sec=5 --max_cached_file_handles=0")
  def test_hdfs_open_timeout(self, vector):
    """This verifies that hdfsOpenFile times out appropriately. It tests this by
       halting the NameNode, running a query that needs to do hdfsOpenFile,
       and verifying that it times out and throws an error."""

    # Find the NameNode's pid via pgrep. This would raise an error if it did not
    # find a pid, so there is at least one match.
    pgrep_output = check_output(["pgrep", "-f", "namenode.NameNode"])
    # In our test environment, this should only match one pid
    assert(pgrep_output.count("\n") == 1)
    namenode_pid = pgrep_output.strip()

    # Run a query successfully. This fetches metadata from the NameNode,
    # and since this will be cached, a subsequent run will not ask the NameNode
    # for metadata. This means a subsequent execution will only talk to the NameNode
    # for file open.
    self.execute_query_expect_success(self.client,
        "select count(*) from functional.alltypes", vector=vector)

    # Stop the NameNode and execute the query again. Since the file handle cache is off,
    # the query will do hdfsOpenFile calls and talk to the NameNode. Since the NameNode
    # is stopped, those calls will hang, testing the timeout functionality.
    ex = None
    result = None
    try:
      # Stop the NameNode
      check_call(["kill", "-STOP", namenode_pid])
      start_time = time.time()
      result = self.execute_query("select count(*) from functional.alltypes",
          vector=vector)
      end_time = time.time()
    except Exception, e:
      ex = e
    finally:
      end_time = time.time()
      # Always resume the NameNode
      check_call(["kill", "-CONT", namenode_pid])

    # The query should have failed, which raises an exception
    if ex is None:
      assert False, "Query should have failed, but instead returned {0}".format(result)

    # The exception should contain the appropriate error message
    error_pattern = "hdfsOpenFile\(\) for.*failed to finish before the 5 second timeout"
    assert len(re.findall(error_pattern, str(ex))) > 0

    # The timeout is 5 seconds and seems to be enforced within about 20 seconds, so it
    # would be unusual if this query does not finish in 60 seconds.
    assert (end_time - start_time) < 60.0

    # Execute the query a final time to verify that the system recovers.
    self.execute_query_expect_success(self.client,
        "select count(*) from functional.alltypes", vector=vector)
<commit_msg>IMPALA-7945: Fix test_hdfs_timeout.py on python 2.6<commit_after># Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

import pytest
import re
import time

from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
from tests.common.skip import SkipIfNotHdfsMinicluster
from subprocess import check_call
from tests.util.shell_util import exec_process

@SkipIfNotHdfsMinicluster.tuned_for_minicluster
class TestHdfsTimeouts(CustomClusterTestSuite):
  """Test to verify that HDFS operations time out correctly."""

  @classmethod
  def get_workload(self):
    return 'functional-query'

  @pytest.mark.execute_serially
  @CustomClusterTestSuite.with_args(
    impalad_args="--hdfs_operation_timeout_sec=5 --max_cached_file_handles=0")
  def test_hdfs_open_timeout(self, vector):
    """This verifies that hdfsOpenFile times out appropriately. It tests this by
       halting the NameNode, running a query that needs to do hdfsOpenFile,
       and verifying that it times out and throws an error."""

    # Find the NameNode's pid via pgrep. This would raise an error if it did not
    # find a pid, so there is at least one match.
    rc, pgrep_output, stderr = exec_process("pgrep -f namenode.NameNode")
    assert rc == 0, \
        "Error finding NameNode pid\nstdout={0}\nstderr={1}".format(pgrep_output, stderr)
    # In our test environment, this should only match one pid
    assert(pgrep_output.count("\n") == 1)
    namenode_pid = pgrep_output.strip()

    # Run a query successfully. This fetches metadata from the NameNode,
    # and since this will be cached, a subsequent run will not ask the NameNode
    # for metadata. This means a subsequent execution will only talk to the NameNode
    # for file open.
    self.execute_query_expect_success(self.client,
        "select count(*) from functional.alltypes", vector=vector)

    # Stop the NameNode and execute the query again. Since the file handle cache is off,
    # the query will do hdfsOpenFile calls and talk to the NameNode. Since the NameNode
    # is stopped, those calls will hang, testing the timeout functionality.
    ex = None
    result = None
    try:
      # Stop the NameNode
      check_call(["kill", "-STOP", namenode_pid])
      start_time = time.time()
      result = self.execute_query("select count(*) from functional.alltypes",
          vector=vector)
      end_time = time.time()
    except Exception, e:
      ex = e
    finally:
      end_time = time.time()
      # Always resume the NameNode
      check_call(["kill", "-CONT", namenode_pid])

    # The query should have failed, which raises an exception
    if ex is None:
      assert False, "Query should have failed, but instead returned {0}".format(result)

    # The exception should contain the appropriate error message
    error_pattern = "hdfsOpenFile\(\) for.*failed to finish before the 5 second timeout"
    assert len(re.findall(error_pattern, str(ex))) > 0

    # The timeout is 5 seconds and seems to be enforced within about 20 seconds, so it
    # would be unusual if this query does not finish in 60 seconds.
    assert (end_time - start_time) < 60.0

    # Execute the query a final time to verify that the system recovers.
    self.execute_query_expect_success(self.client,
        "select count(*) from functional.alltypes", vector=vector)
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
#
# ConPaaS documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 23 17:40:53 2013.
#
# 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.

import sys, os

# 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('.'))
sys.path.append(os.path.abspath('../conpaas-services/config'))
sys.path.append(os.path.abspath('../conpaas-services/contrib'))
sys.path.append(os.path.abspath('/usr/local/lib/python2.6/dist-packages'))

# -- 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 = ['sphinx.ext.viewcode']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']

# 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 = 'index'

# General information about the project.
project = u'ConPaaS'
copyright = u'2013, Contrail consortium'

# 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 = '1.3.1'
# The full version, including alpha/beta/rc tags.
release = '1.3.1'

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

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

# 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 = True

# 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 = []

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

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

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
html_theme_options = {
    'stickysidebar': True
}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# 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 = '../conpaas-frontend/www/images/conpaas.ico'

# 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_style = '/default.css'

# 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 = {}

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

# 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 = True

# 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 = 'ConPaaSdoc'

# -- 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 = [
  ('manual', 'ConPaaS.tex', u'ConPaaS Documentation',
   u'The ConPaaS team <info@conpaas.eu>', 'manual'),
  #('installation', 'installation.tex', u'ConPaaS Installation HOWTO',
  # u'Emanuele Rocca, Guillaume Pierre', 'howto'),
  #('userguide', 'userguide.tex', u'ConPaaS User Guide',
  # u'Emanuele Rocca, Guillaume Pierre', 'howto'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'conpaas', u'ConPaaS Documentation',
     [u'Emanuele Rocca, Guillaume Pierre'], 1)
]

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

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'ConPaaS', u'ConPaaS Documentation',
   u'Emanuele Rocca, Guillaume Pierre', 'ConPaaS', 'One line description of project.',
   'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
<commit_msg>updated docs version<commit_after># -*- coding: utf-8 -*-
#
# ConPaaS documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 23 17:40:53 2013.
#
# 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.

import sys, os

# 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('.'))
sys.path.append(os.path.abspath('../conpaas-services/config'))
sys.path.append(os.path.abspath('../conpaas-services/contrib'))
sys.path.append(os.path.abspath('/usr/local/lib/python2.6/dist-packages'))

# -- 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 = ['sphinx.ext.viewcode']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']

# 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 = 'index'

# General information about the project.
project = u'ConPaaS'
copyright = u'2013, Contrail consortium'

# 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 = '1.4.1'
# The full version, including alpha/beta/rc tags.
release = '1.4.1-rc2'

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

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

# 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 = True

# 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 = []

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

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

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
html_theme_options = {
    'stickysidebar': True
}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# 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 = '../conpaas-frontend/www/images/conpaas.ico'

# 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_style = '/default.css'

# 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 = {}

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

# 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 = True

# 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 = 'ConPaaSdoc'

# -- 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 = [
  ('manual', 'ConPaaS.tex', u'ConPaaS Documentation',
   u'The ConPaaS team <info@conpaas.eu>', 'manual'),
  #('installation', 'installation.tex', u'ConPaaS Installation HOWTO',
  # u'Emanuele Rocca, Guillaume Pierre', 'howto'),
  #('userguide', 'userguide.tex', u'ConPaaS User Guide',
  # u'Emanuele Rocca, Guillaume Pierre', 'howto'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'conpaas', u'ConPaaS Documentation',
     [u'Emanuele Rocca, Guillaume Pierre'], 1)
]

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

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'ConPaaS', u'ConPaaS Documentation',
   u'Emanuele Rocca, Guillaume Pierre', 'ConPaaS', 'One line description of project.',
   'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
<|endoftext|>


<commit_before>import discretize
from SimPEG import maps, utils, tests
from SimPEG.electromagnetics import frequency_domain as fdem
import numpy as np
from scipy.constants import mu_0

import unittest

MuMax = 50.0
TOL = 1e-7
EPS = 1e-9

np.random.seed(105)

def setupMeshModel():
    cs = 10.0
    nc = 20.0
    npad = 15.0
    hx = [(cs, nc), (cs, npad, 1.3)]
    hz = [(cs, npad, -1.3), (cs, nc), (cs, npad, 1.3)]

    mesh = discretize.CylMesh([hx, 1.0, hz], "0CC")
    muMod = 1 + MuMax * np.random.randn(mesh.nC)
    sigmaMod = np.random.randn(mesh.nC)

    return mesh, muMod, sigmaMod

def setupProblem(
    mesh,
    muMod,
    sigmaMod,
    prbtype="ElectricField",
    invertMui=False,
    sigmaInInversion=False,
    freq=1.0,
):
    rxcomp = ["real", "imag"]

    loc = utils.ndgrid([mesh.vectorCCx, np.r_[0.0], mesh.vectorCCz])

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        rxfields_y = ["ElectricField", "CurrentDensity"]
        rxfields_xz = ["MagneticFluxDensity", "MagneticField"]

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        rxfields_y = ["MagneticFluxDensity", "MagneticField"]
        rxfields_xz = ["ElectricField", "CurrentDensity"]

    receiver_list_edge = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(
            loc, component=comp, orientation=orient
        )
        for f in rxfields_y
        for comp in rxcomp
        for orient in ["y"]
    ]

    receiver_list_face = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(
            loc, component=comp, orientation=orient
        )
        for f in rxfields_xz
        for comp in rxcomp
        for orient in ["x", "z"]
    ]

    receiver_list = receiver_list_edge + receiver_list_face

    src_loc = np.r_[0.0, 0.0, 0.0]

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        src = fdem.sources.MagDipole(
            receiver_list=receiver_list, location=src_loc, frequency=freq
        )

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        ind = utils.closestPoints(mesh, src_loc, "Fz") + mesh.vnF[0]
        vec = np.zeros(mesh.nF)
        vec[ind] = 1.0

        src = fdem.sources.RawVec_e(
            receiver_list=receiver_list, frequency=freq, s_e=vec
        )

    survey = fdem.Survey([src])

    if sigmaInInversion:

        wires = maps.Wires(("mu", mesh.nC), ("sigma", mesh.nC))

        muMap = maps.MuRelative(mesh) * wires.mu
        sigmaMap = maps.ExpMap(mesh) * wires.sigma

        if invertMui:
            muiMap = maps.ReciprocalMap(mesh) * muMap
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, muiMap=muiMap, sigmaMap=sigmaMap
            )
            # m0 = np.hstack([1./muMod, sigmaMod])
        else:
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, muMap=muMap, sigmaMap=sigmaMap
            )
        m0 = np.hstack([muMod, sigmaMod])

    else:
        muMap = maps.MuRelative(mesh)

        if invertMui:
            muiMap = maps.ReciprocalMap(mesh) * muMap
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, sigma=sigmaMod, muiMap=muiMap
            )
            # m0 = 1./muMod
        else:
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, sigma=sigmaMod, muMap=muMap
            )
        m0 = muMod

    prob.survey = survey

    return m0, prob, survey

class MuTests(unittest.TestCase):
    def setUpProb(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.mesh, muMod, sigmaMod = setupMeshModel()
        self.m0, self.simulation, self.survey = setupProblem(
            self.mesh,
            muMod,
            sigmaMod,
            prbtype=prbtype,
            sigmaInInversion=sigmaInInversion,
            invertMui=invertMui,
        )

    def test_mats_cleared(self):
        self.setUpProb()
        u = self.simulation.fields(self.m0)

        MeMu = self.simulation.MeMu
        MeMuI = self.simulation.MeMuI
        MfMui = self.simulation.MfMui
        MfMuiI = self.simulation.MfMuiI
        MeMuDeriv = self.simulation.MeMuDeriv(u[:, "e"])
        MfMuiDeriv = self.simulation.MfMuiDeriv(u[:, "b"])
        MfMuiDeriv_zero = self.simulation.MfMuiDeriv(utils.Zero())
        MfMuiIDeriv_zero = self.simulation.MfMuiIDeriv(utils.Zero())
        MeMuDeriv_zero = self.simulation.MeMuDeriv(utils.Zero())

        m1 = np.random.rand(self.mesh.nC)
        self.simulation.model = m1

        self.assertTrue(getattr(self, "_MeMu", None) is None)
        self.assertTrue(getattr(self, "_MeMuI", None) is None)
        self.assertTrue(getattr(self, "_MfMui", None) is None)
        self.assertTrue(getattr(self, "_MfMuiI", None) is None)
        self.assertTrue(getattr(self, "_MfMuiDeriv", None) is None)
        self.assertTrue(getattr(self, "_MeMuDeriv", None) is None)
        self.assertTrue(isinstance(MfMuiDeriv_zero, utils.Zero))
        self.assertTrue(isinstance(MfMuiIDeriv_zero, utils.Zero))
        self.assertTrue(isinstance(MeMuDeriv_zero, utils.Zero))

    def JvecTest(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.setUpProb(prbtype, sigmaInInversion, invertMui)
        print("Testing Jvec {}".format(prbtype))

        def fun(x):
            return (
                self.simulation.dpred(x),
                lambda x: self.simulation.Jvec(self.m0, x),
            )

        return tests.checkDerivative(fun, self.m0, num=3, plotIt=False)

    def JtvecTest(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.setUpProb(prbtype, sigmaInInversion, invertMui)
        print("Testing Jvec {}".format(prbtype))

        m = np.random.rand(self.simulation.muMap.nP)
        v = np.random.rand(self.survey.nD)

        self.simulation.model = self.m0

        V1 = v.dot(self.simulation.Jvec(self.m0, m))
        V2 = m.dot(self.simulation.Jtvec(self.m0, v))
        diff = np.abs(V1 - V2)
        tol = TOL * (np.abs(V1) + np.abs(V2)) / 2.0
        passed = (diff < tol) | (diff < EPS)
        print(
            "AdjointTest {prbtype} {v1} {v2} {diff} {tol} {passed}".format(
                prbtype=prbtype, v1=V1, v2=V2, diff=diff, tol=tol, passed=passed
            )
        )
        return passed

    def test_Jvec_e(self):
        self.assertTrue(self.JvecTest("ElectricField", sigmaInInversion=False))

    def test_Jvec_b(self):
        self.assertTrue(self.JvecTest("MagneticFluxDensity", sigmaInInversion=False))

    def test_Jvec_j(self):
        self.assertTrue(self.JvecTest("CurrentDensity", sigmaInInversion=False))

    def test_Jvec_h(self):
        self.assertTrue(self.JvecTest("MagneticField", sigmaInInversion=False))

    def test_Jtvec_e(self):
        self.assertTrue(self.JtvecTest("ElectricField", sigmaInInversion=False))

    def test_Jtvec_b(self):
        self.assertTrue(self.JtvecTest("MagneticFluxDensity", sigmaInInversion=False))

    def test_Jtvec_j(self):
        self.assertTrue(self.JtvecTest("CurrentDensity", sigmaInInversion=False))

    def test_Jtvec_h(self):
        self.assertTrue(self.JtvecTest("MagneticField", sigmaInInversion=False))

    def test_Jvec_musig_e(self):
        self.assertTrue(self.JvecTest("ElectricField", sigmaInInversion=True))

    def test_Jvec_musig_b(self):
        self.assertTrue(self.JvecTest("MagneticFluxDensity", sigmaInInversion=True))

    def test_Jvec_musig_j(self):
        self.assertTrue(self.JvecTest("CurrentDensity", sigmaInInversion=True))

    def test_Jvec_musig_h(self):
        self.assertTrue(self.JvecTest("MagneticField", sigmaInInversion=True))

    def test_Jtvec_musig_e(self):
        self.assertTrue(self.JtvecTest("ElectricField", sigmaInInversion=True))

    def test_Jtvec_musig_b(self):
        self.assertTrue(self.JtvecTest("MagneticFluxDensity", sigmaInInversion=True))

    def test_Jtvec_musig_j(self):
        self.assertTrue(self.JtvecTest("CurrentDensity", sigmaInInversion=True))

    def test_Jtvec_musig_h(self):
        self.assertTrue(self.JtvecTest("MagneticField", sigmaInInversion=True))

    def test_Jvec_e_mui(self):
        self.assertTrue(
            self.JvecTest("ElectricField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_b_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticFluxDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_j_mui(self):
        self.assertTrue(
            self.JvecTest("CurrentDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_h_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_e_mui(self):
        self.assertTrue(
            self.JtvecTest("ElectricField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_b_mui(self):
        self.assertTrue(
            self.JtvecTest(
                "MagneticFluxDensity", sigmaInInversion=False, invertMui=True
            )
        )

    def test_Jtvec_j_mui(self):
        self.assertTrue(
            self.JtvecTest("CurrentDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_h_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_musig_e_mui(self):
        self.assertTrue(
            self.JvecTest("ElectricField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_b_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticFluxDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_j_mui(self):
        self.assertTrue(
            self.JvecTest("CurrentDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_h_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_e_mui(self):
        self.assertTrue(
            self.JtvecTest("ElectricField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_b_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticFluxDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_j_mui(self):
        self.assertTrue(
            self.JtvecTest("CurrentDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_h_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticField", sigmaInInversion=True, invertMui=True)
        )

if __name__ == "__main__":
    unittest.main()
<commit_msg>even higher tolerance<commit_after>import discretize
from SimPEG import maps, utils, tests
from SimPEG.electromagnetics import frequency_domain as fdem
import numpy as np
from scipy.constants import mu_0

import unittest

MuMax = 50.0
TOL = 1e-4
EPS = 1e-6

np.random.seed(105)

def setupMeshModel():
    cs = 10.0
    nc = 20.0
    npad = 15.0
    hx = [(cs, nc), (cs, npad, 1.3)]
    hz = [(cs, npad, -1.3), (cs, nc), (cs, npad, 1.3)]

    mesh = discretize.CylMesh([hx, 1.0, hz], "0CC")
    muMod = 1 + MuMax * np.random.randn(mesh.nC)
    sigmaMod = np.random.randn(mesh.nC)

    return mesh, muMod, sigmaMod

def setupProblem(
    mesh,
    muMod,
    sigmaMod,
    prbtype="ElectricField",
    invertMui=False,
    sigmaInInversion=False,
    freq=1.0,
):
    rxcomp = ["real", "imag"]

    loc = utils.ndgrid([mesh.vectorCCx, np.r_[0.0], mesh.vectorCCz])

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        rxfields_y = ["ElectricField", "CurrentDensity"]
        rxfields_xz = ["MagneticFluxDensity", "MagneticField"]

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        rxfields_y = ["MagneticFluxDensity", "MagneticField"]
        rxfields_xz = ["ElectricField", "CurrentDensity"]

    receiver_list_edge = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(
            loc, component=comp, orientation=orient
        )
        for f in rxfields_y
        for comp in rxcomp
        for orient in ["y"]
    ]

    receiver_list_face = [
        getattr(fdem.receivers, "Point{f}".format(f=f))(
            loc, component=comp, orientation=orient
        )
        for f in rxfields_xz
        for comp in rxcomp
        for orient in ["x", "z"]
    ]

    receiver_list = receiver_list_edge + receiver_list_face

    src_loc = np.r_[0.0, 0.0, 0.0]

    if prbtype in ["ElectricField", "MagneticFluxDensity"]:
        src = fdem.sources.MagDipole(
            receiver_list=receiver_list, location=src_loc, frequency=freq
        )

    elif prbtype in ["MagneticField", "CurrentDensity"]:
        ind = utils.closestPoints(mesh, src_loc, "Fz") + mesh.vnF[0]
        vec = np.zeros(mesh.nF)
        vec[ind] = 1.0

        src = fdem.sources.RawVec_e(
            receiver_list=receiver_list, frequency=freq, s_e=vec
        )

    survey = fdem.Survey([src])

    if sigmaInInversion:

        wires = maps.Wires(("mu", mesh.nC), ("sigma", mesh.nC))

        muMap = maps.MuRelative(mesh) * wires.mu
        sigmaMap = maps.ExpMap(mesh) * wires.sigma

        if invertMui:
            muiMap = maps.ReciprocalMap(mesh) * muMap
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, muiMap=muiMap, sigmaMap=sigmaMap
            )
            # m0 = np.hstack([1./muMod, sigmaMod])
        else:
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, muMap=muMap, sigmaMap=sigmaMap
            )
        m0 = np.hstack([muMod, sigmaMod])

    else:
        muMap = maps.MuRelative(mesh)

        if invertMui:
            muiMap = maps.ReciprocalMap(mesh) * muMap
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, sigma=sigmaMod, muiMap=muiMap
            )
            # m0 = 1./muMod
        else:
            prob = getattr(fdem, "Simulation3D{}".format(prbtype))(
                mesh, sigma=sigmaMod, muMap=muMap
            )
        m0 = muMod

    prob.survey = survey

    return m0, prob, survey

class MuTests(unittest.TestCase):
    def setUpProb(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.mesh, muMod, sigmaMod = setupMeshModel()
        self.m0, self.simulation, self.survey = setupProblem(
            self.mesh,
            muMod,
            sigmaMod,
            prbtype=prbtype,
            sigmaInInversion=sigmaInInversion,
            invertMui=invertMui,
        )

    def test_mats_cleared(self):
        self.setUpProb()
        u = self.simulation.fields(self.m0)

        MeMu = self.simulation.MeMu
        MeMuI = self.simulation.MeMuI
        MfMui = self.simulation.MfMui
        MfMuiI = self.simulation.MfMuiI
        MeMuDeriv = self.simulation.MeMuDeriv(u[:, "e"])
        MfMuiDeriv = self.simulation.MfMuiDeriv(u[:, "b"])
        MfMuiDeriv_zero = self.simulation.MfMuiDeriv(utils.Zero())
        MfMuiIDeriv_zero = self.simulation.MfMuiIDeriv(utils.Zero())
        MeMuDeriv_zero = self.simulation.MeMuDeriv(utils.Zero())

        m1 = np.random.rand(self.mesh.nC)
        self.simulation.model = m1

        self.assertTrue(getattr(self, "_MeMu", None) is None)
        self.assertTrue(getattr(self, "_MeMuI", None) is None)
        self.assertTrue(getattr(self, "_MfMui", None) is None)
        self.assertTrue(getattr(self, "_MfMuiI", None) is None)
        self.assertTrue(getattr(self, "_MfMuiDeriv", None) is None)
        self.assertTrue(getattr(self, "_MeMuDeriv", None) is None)
        self.assertTrue(isinstance(MfMuiDeriv_zero, utils.Zero))
        self.assertTrue(isinstance(MfMuiIDeriv_zero, utils.Zero))
        self.assertTrue(isinstance(MeMuDeriv_zero, utils.Zero))

    def JvecTest(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.setUpProb(prbtype, sigmaInInversion, invertMui)
        print("Testing Jvec {}".format(prbtype))

        def fun(x):
            return (
                self.simulation.dpred(x),
                lambda x: self.simulation.Jvec(self.m0, x),
            )

        return tests.checkDerivative(fun, self.m0, num=3, plotIt=False)

    def JtvecTest(
        self, prbtype="ElectricField", sigmaInInversion=False, invertMui=False
    ):
        self.setUpProb(prbtype, sigmaInInversion, invertMui)
        print("Testing Jvec {}".format(prbtype))

        m = np.random.rand(self.simulation.muMap.nP)
        v = np.random.rand(self.survey.nD)

        self.simulation.model = self.m0

        V1 = v.dot(self.simulation.Jvec(self.m0, m))
        V2 = m.dot(self.simulation.Jtvec(self.m0, v))
        diff = np.abs(V1 - V2)
        tol = TOL * (np.abs(V1) + np.abs(V2)) / 2.0
        passed = (diff < tol) | (diff < EPS)
        print(
            "AdjointTest {prbtype} {v1} {v2} {diff} {tol} {passed}".format(
                prbtype=prbtype, v1=V1, v2=V2, diff=diff, tol=tol, passed=passed
            )
        )
        return passed

    def test_Jvec_e(self):
        self.assertTrue(self.JvecTest("ElectricField", sigmaInInversion=False))

    def test_Jvec_b(self):
        self.assertTrue(self.JvecTest("MagneticFluxDensity", sigmaInInversion=False))

    def test_Jvec_j(self):
        self.assertTrue(self.JvecTest("CurrentDensity", sigmaInInversion=False))

    def test_Jvec_h(self):
        self.assertTrue(self.JvecTest("MagneticField", sigmaInInversion=False))

    def test_Jtvec_e(self):
        self.assertTrue(self.JtvecTest("ElectricField", sigmaInInversion=False))

    def test_Jtvec_b(self):
        self.assertTrue(self.JtvecTest("MagneticFluxDensity", sigmaInInversion=False))

    def test_Jtvec_j(self):
        self.assertTrue(self.JtvecTest("CurrentDensity", sigmaInInversion=False))

    def test_Jtvec_h(self):
        self.assertTrue(self.JtvecTest("MagneticField", sigmaInInversion=False))

    def test_Jvec_musig_e(self):
        self.assertTrue(self.JvecTest("ElectricField", sigmaInInversion=True))

    def test_Jvec_musig_b(self):
        self.assertTrue(self.JvecTest("MagneticFluxDensity", sigmaInInversion=True))

    def test_Jvec_musig_j(self):
        self.assertTrue(self.JvecTest("CurrentDensity", sigmaInInversion=True))

    def test_Jvec_musig_h(self):
        self.assertTrue(self.JvecTest("MagneticField", sigmaInInversion=True))

    def test_Jtvec_musig_e(self):
        self.assertTrue(self.JtvecTest("ElectricField", sigmaInInversion=True))

    def test_Jtvec_musig_b(self):
        self.assertTrue(self.JtvecTest("MagneticFluxDensity", sigmaInInversion=True))

    def test_Jtvec_musig_j(self):
        self.assertTrue(self.JtvecTest("CurrentDensity", sigmaInInversion=True))

    def test_Jtvec_musig_h(self):
        self.assertTrue(self.JtvecTest("MagneticField", sigmaInInversion=True))

    def test_Jvec_e_mui(self):
        self.assertTrue(
            self.JvecTest("ElectricField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_b_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticFluxDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_j_mui(self):
        self.assertTrue(
            self.JvecTest("CurrentDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_h_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_e_mui(self):
        self.assertTrue(
            self.JtvecTest("ElectricField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_b_mui(self):
        self.assertTrue(
            self.JtvecTest(
                "MagneticFluxDensity", sigmaInInversion=False, invertMui=True
            )
        )

    def test_Jtvec_j_mui(self):
        self.assertTrue(
            self.JtvecTest("CurrentDensity", sigmaInInversion=False, invertMui=True)
        )

    def test_Jtvec_h_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticField", sigmaInInversion=False, invertMui=True)
        )

    def test_Jvec_musig_e_mui(self):
        self.assertTrue(
            self.JvecTest("ElectricField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_b_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticFluxDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_j_mui(self):
        self.assertTrue(
            self.JvecTest("CurrentDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jvec_musig_h_mui(self):
        self.assertTrue(
            self.JvecTest("MagneticField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_e_mui(self):
        self.assertTrue(
            self.JtvecTest("ElectricField", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_b_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticFluxDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_j_mui(self):
        self.assertTrue(
            self.JtvecTest("CurrentDensity", sigmaInInversion=True, invertMui=True)
        )

    def test_Jtvec_musig_h_mui(self):
        self.assertTrue(
            self.JtvecTest("MagneticField", sigmaInInversion=True, invertMui=True)
        )

if __name__ == "__main__":
    unittest.main()
<|endoftext|>


<commit_before># Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))

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

project = 'convertdate'
copyright = '2020, Neil Freeman'
author = 'Neil Freeman'

# The full version, including alpha/beta/rc tags
release = '2.2.2'

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

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

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

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

html_sidebars = {'*': ['globaltoc.html', 'sourcelink.html']}

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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme_options = {
    'display_version': True,
}

# 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']<commit_msg>update docs for rtd<commit_after># Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))

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

project = 'convertdate'
copyright = '2020, Neil Freeman'
author = 'Neil Freeman'

# The full version, including alpha/beta/rc tags
release = '2.2.2'

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

master_doc = 'index'

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

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

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

html_sidebars = {'*': ['globaltoc.html', 'sourcelink.html']}

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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme_options = {
    'display_version': True,
}

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


<commit_before>import argparse
import csv
import datetime
import time

def migrate():
    pass

def run_main():
    path = file_path()
    not_yet, succeeds, fails = _read_file(path)
    # evaluate measurements
    now = datetime.datetime.now()
    for row in list(not_yet):
        evaluate_time = datetime.datetime(*(time.strptime(row[1], "%Y-%m-%d %H:%M")[:6]))
        if evaluate_time < now:
            print("Time to evaluate: {}\n Is it true? (Yes/No/Delay)".format(row[2]))
            user_input = input().capitalize()
            if user_input.startswith("Y"):
                row[0] = "S"
                succeeds.append(row)
            elif user_input.startswith("D"):
                print("When to evaluate (YYYY-mm-dd HH:MM):")
                eval_time = input()
                not_yet.append(["N", eval_time, row[2]])
            else:
                row[0] = "F"
                fails.append(row)
            not_yet.remove(row)
    # print total statistics
    total_done = len(fails) + len(succeeds)
    if total_done > 0:
        percentage = "%d%%" % (float(100 * len(succeeds)) / float(total_done))
    else:
        percentage = "N/A"
    print("Succesful predictions:", percentage, ", not done yet:", len(not_yet))
    # add another prediction when needed
    print("Add another prediction? Y/N")
    user_input = input()
    if user_input.capitalize().startswith("Y"):
        print("Prediction:")
        prediction = input()
        print("When to evaluate (YYYY-mm-dd HH:MM):")
        eval_time = input()
        not_yet.append(["N", eval_time, prediction])
    # overwrite predictions file
    all_rows = list()
    all_rows.extend(fails)
    all_rows.extend(succeeds)
    all_rows.extend(not_yet)
    with open(path, "wt") as f:
        writer = csv.writer(f)
        for row in all_rows:
            writer.writerow(row)

def _read_file(path):
    fails = list()
    succeeds = list()
    not_yet = list()
    try:
        with open(path) as f:
            reader = csv.reader(f)
            for row in reader:
                status = row[0]
                if status == "F":
                    fails.append(row)
                elif status == "S":
                    succeeds.append(row)
                else:
                    not_yet.append(row)
    except FileNotFoundError:
        pass
    return not_yet, succeeds, fails

def file_path():
    parser = argparse.ArgumentParser()
    parser.add_argument("path")
    args = parser.parse_args()
    return args.path
<commit_msg>Rename inner function<commit_after>import argparse
import csv
import datetime
import time

def migrate():
    pass

def run_main():
    path = _file_path()
    not_yet, succeeds, fails = _read_file(path)
    # evaluate measurements
    now = datetime.datetime.now()
    for row in list(not_yet):
        evaluate_time = datetime.datetime(*(time.strptime(row[1], "%Y-%m-%d %H:%M")[:6]))
        if evaluate_time < now:
            print("Time to evaluate: {}\n Is it true? (Yes/No/Delay)".format(row[2]))
            user_input = input().capitalize()
            if user_input.startswith("Y"):
                row[0] = "S"
                succeeds.append(row)
            elif user_input.startswith("D"):
                print("When to evaluate (YYYY-mm-dd HH:MM):")
                eval_time = input()
                not_yet.append(["N", eval_time, row[2]])
            else:
                row[0] = "F"
                fails.append(row)
            not_yet.remove(row)
    # print total statistics
    total_done = len(fails) + len(succeeds)
    if total_done > 0:
        percentage = "%d%%" % (float(100 * len(succeeds)) / float(total_done))
    else:
        percentage = "N/A"
    print("Succesful predictions:", percentage, ", not done yet:", len(not_yet))
    # add another prediction when needed
    print("Add another prediction? Y/N")
    user_input = input()
    if user_input.capitalize().startswith("Y"):
        print("Prediction:")
        prediction = input()
        print("When to evaluate (YYYY-mm-dd HH:MM):")
        eval_time = input()
        not_yet.append(["N", eval_time, prediction])
    # overwrite predictions file
    all_rows = list()
    all_rows.extend(fails)
    all_rows.extend(succeeds)
    all_rows.extend(not_yet)
    with open(path, "wt") as f:
        writer = csv.writer(f)
        for row in all_rows:
            writer.writerow(row)

def _read_file(path):
    fails = list()
    succeeds = list()
    not_yet = list()
    try:
        with open(path) as f:
            reader = csv.reader(f)
            for row in reader:
                status = row[0]
                if status == "F":
                    fails.append(row)
                elif status == "S":
                    succeeds.append(row)
                else:
                    not_yet.append(row)
    except FileNotFoundError:
        pass
    return not_yet, succeeds, fails

def _file_path():
    parser = argparse.ArgumentParser()
    parser.add_argument("path")
    args = parser.parse_args()
    return args.path
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
#
# django-oscar-paypal documentation build configuration file, created by
# sphinx-quickstart on Wed Aug 22 20:12:56 2012.
#
# 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.

import sys, os

# 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.
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), '..')
sys.path.insert(0, PROJECT_ROOT)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings')

# -- 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 = ['sphinx.ext.autodoc']

# 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 = 'index'

# General information about the project.
project = u'django-oscar-paypal'
copyright = u'2012, David Winterbottom'

# 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.
from paypal import VERSION
version = VERSION
# The full version, including alpha/beta/rc tags.
release = VERSION

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

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

# 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 = True

# 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 = []

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

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

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# 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 = None

# 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 = {}

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

# 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 = True

# 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 = 'django-oscar-paypaldoc'

# -- 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', 'django-oscar-paypal.tex', u'django-oscar-paypal Documentation',
   u'David Winterbottom', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'django-oscar-paypal', u'django-oscar-paypal Documentation',
     [u'David Winterbottom'], 1)
]

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

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'django-oscar-paypal', u'django-oscar-paypal Documentation',
   u'David Winterbottom', 'django-oscar-paypal', 'One line description of project.',
   'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
<commit_msg>Fix sphinx build issue with missing settings<commit_after># -*- coding: utf-8 -*-
#
# django-oscar-paypal documentation build configuration file, created by
# sphinx-quickstart on Wed Aug 22 20:12:56 2012.
#
# 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.

import sys, os

# 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.
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), '..')
sys.path.insert(0, PROJECT_ROOT)

from django.conf import settings
if not settings.configured:
    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                }
            },
    )

#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings')

# -- 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 = ['sphinx.ext.autodoc']

# 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 = 'index'

# General information about the project.
project = u'django-oscar-paypal'
copyright = u'2012, David Winterbottom'

# 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.
from paypal import VERSION
version = VERSION
# The full version, including alpha/beta/rc tags.
release = VERSION

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

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

# 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 = True

# 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 = []

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

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

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# 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 = None

# 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 = {}

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

# 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 = True

# 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 = 'django-oscar-paypaldoc'

# -- 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', 'django-oscar-paypal.tex', u'django-oscar-paypal Documentation',
   u'David Winterbottom', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'django-oscar-paypal', u'django-oscar-paypal Documentation',
     [u'David Winterbottom'], 1)
]

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

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'django-oscar-paypal', u'django-oscar-paypal Documentation',
   u'David Winterbottom', 'django-oscar-paypal', 'One line description of project.',
   'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# pmareport documentation build configuration file, created by
# sphinx-quickstart on Tue Jul  9 22:26:36 2013.
#
# 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.

import sys
import os

# To get scipy to load for readthedocs:
class Mock(object):
    def __init__(self, *args, **kwargs):
        pass

    def __call__(self, *args, **kwargs):
        return Mock()

    @classmethod
    def __getattr__(cls, name):
        if name in ('__file__', '__path__'):
            return '/dev/null'
        elif name[0] == name[0].upper():
            return type(name, (), {})
        else:
            return Mock()

MOCK_MODULES = [
    'scipy',
    'sklearn',
    'sklearn.naive_bayes',
    'sklearn.feature_extraction',
    'seaborn'
    ]
for mod_name in MOCK_MODULES:
    sys.modules[mod_name] = Mock()

# 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('.'))

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
project_root = os.path.dirname(cwd)

# Insert the project root dir as the first element in the PYTHONPATH.
# This lets us ensure that the source package is imported, and that its
# version is used.
sys.path.insert(0, project_root)

import pmareport

# -- 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 = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']

# 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 = 'index'

# General information about the project.
project = u'PMA report'
copyright = u'2015, Gautam Sisodia'

# 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 = pmareport.__version__
# The full version, including alpha/beta/rc tags.
release = pmareport.__version__

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

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

# 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 = True

# 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 = []

# If true, keep warnings as "system message" paragraphs in the built
# documents.
#keep_warnings = False

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

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

# Theme options are theme-specific and customize the look and feel of a
# theme further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as
# html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the
# top of the sidebar.
#html_logo = None

# 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 = None

# 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 = {}

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

# 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 = True

# 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 = 'pmareportdoc'

# -- 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', 'pmareport.tex',
     u'PMA report Documentation',
     u'Gautam Sisodia', 'manual'),
]

# The name of an image file (relative to this directory) to place at
# the top of the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'pmareport',
     u'PMA report Documentation',
     [u'Gautam Sisodia'], 1)
]

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

# -- Options for Texinfo output ----------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    ('index', 'pmareport',
     u'PMA report Documentation',
     u'Gautam Sisodia',
     'pmareport',
     'One line description of project.',
     'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
<commit_msg>mocked matplotlib<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# pmareport documentation build configuration file, created by
# sphinx-quickstart on Tue Jul  9 22:26:36 2013.
#
# 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.

import sys
import os

# To get scipy to load for readthedocs:
class Mock(object):
    def __init__(self, *args, **kwargs):
        pass

    def __call__(self, *args, **kwargs):
        return Mock()

    @classmethod
    def __getattr__(cls, name):
        if name in ('__file__', '__path__'):
            return '/dev/null'
        elif name[0] == name[0].upper():
            return type(name, (), {})
        else:
            return Mock()

MOCK_MODULES = [
    'scipy',
    'sklearn',
    'sklearn.naive_bayes',
    'sklearn.feature_extraction',
    'seaborn',
    'matplotlib.pyplot'
    ]
for mod_name in MOCK_MODULES:
    sys.modules[mod_name] = Mock()

# 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('.'))

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
project_root = os.path.dirname(cwd)

# Insert the project root dir as the first element in the PYTHONPATH.
# This lets us ensure that the source package is imported, and that its
# version is used.
sys.path.insert(0, project_root)

import pmareport

# -- 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 = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']

# 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 = 'index'

# General information about the project.
project = u'PMA report'
copyright = u'2015, Gautam Sisodia'

# 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 = pmareport.__version__
# The full version, including alpha/beta/rc tags.
release = pmareport.__version__

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

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

# 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 = True

# 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 = []

# If true, keep warnings as "system message" paragraphs in the built
# documents.
#keep_warnings = False

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

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

# Theme options are theme-specific and customize the look and feel of a
# theme further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# 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 = None

# A shorter title for the navigation bar.  Default is the same as
# html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the
# top of the sidebar.
#html_logo = None

# 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 = None

# 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 = {}

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

# 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 = True

# 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 = 'pmareportdoc'

# -- 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', 'pmareport.tex',
     u'PMA report Documentation',
     u'Gautam Sisodia', 'manual'),
]

# The name of an image file (relative to this directory) to place at
# the top of the title page.
#latex_logo = None

# 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

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

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

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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'pmareport',
     u'PMA report Documentation',
     [u'Gautam Sisodia'], 1)
]

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

# -- Options for Texinfo output ----------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    ('index', 'pmareport',
     u'PMA report Documentation',
     u'Gautam Sisodia',
     'pmareport',
     'One line description of project.',
     'Miscellaneous'),
]

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

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

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
<|endoftext|>