Skip to content

Commit

Permalink
Merge pull request #2 from KevinCawley/documentation
Browse files Browse the repository at this point in the history
Fixing Issue tardis-sn#680
  • Loading branch information
KevinCawley authored Nov 22, 2020
2 parents 8d5948e + 9181a7c commit d4a7a7c
Show file tree
Hide file tree
Showing 35 changed files with 280 additions and 425 deletions.
6 changes: 0 additions & 6 deletions ah_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,6 @@ def use_astropy_helpers(**kwargs):
Parameters
----------
path : str or None, optional
A filesystem path relative to the root of the project's source code
that should be added to `sys.path` so that `astropy_helpers` can be
Expand All @@ -933,32 +932,27 @@ def use_astropy_helpers(**kwargs):
archive.
If `None` skip straight to downloading.
download_if_needed : bool, optional
If the provided filesystem path is not found an attempt will be made to
download astropy_helpers from PyPI. It will then be made temporarily
available on `sys.path` as a ``.egg`` archive (using the
``setup_requires`` feature of setuptools. If the ``--offline`` option
is given at the command line the value of this argument is overridden
to `False`.
index_url : str, optional
If provided, use a different URL for the Python package index than the
main PyPI server.
use_git : bool, optional
If `False` no git commands will be used--this effectively disables
support for git submodules. If the ``--no-git`` option is given at the
command line the value of this argument is overridden to `False`.
auto_upgrade : bool, optional
By default, when installing a package from a non-development source
distribution ah_boostrap will try to automatically check for patch
releases to astropy-helpers on PyPI and use the patched version over
any bundled versions. Setting this to `False` will disable that
functionality. If the ``--offline`` option is given at the command line
the value of this argument is overridden to `False`.
offline : bool, optional
If `False` disable all actions that require an internet connection,
including downloading packages from the package index and fetching
Expand Down
12 changes: 0 additions & 12 deletions tardis/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,52 +57,41 @@ def test(
package : str, optional
The name of a specific package to test, e.g. 'io.fits' or 'utils'.
If nothing is specified all default tests are run.
test_path : str, optional
Specify location to test by path. May be a single file or
directory. Must be specified absolutely or relative to the
calling directory.
args : str, optional
Additional arguments to be passed to pytest.main_ in the ``args``
keyword argument.
plugins : list, optional
Plugins to be passed to pytest.main_ in the ``plugins`` keyword
argument.
verbose : bool, optional
Convenience option to turn on verbose output from py.test_. Passing
True is the same as specifying ``'-v'`` in ``args``.
pastebin : {'failed','all',None}, optional
Convenience option for turning on py.test_ pastebin output. Set to
``'failed'`` to upload info for failed tests, or ``'all'`` to upload
info for all tests.
remote_data : bool, optional
Controls whether to run tests marked with @remote_data. These
tests use online data and are not run by default. Set to True to
run these tests.
pep8 : bool, optional
Turn on PEP8 checking via the `pytest-pep8 plugin
<http://pypi.python.org/pypi/pytest-pep8>`_ and disable normal
tests. Same as specifying ``'--pep8 -k pep8'`` in ``args``.
pdb : bool, optional
Turn on PDB post-mortem analysis for failing tests. Same as
specifying ``'--pdb'`` in ``args``.
coverage : bool, optional
Generate a test coverage report. The result will be placed in
the directory htmlcov.
open_files : bool, optional
Fail when any tests leave files open. Off by default, because
this adds extra run time to the test suite. Requires the
`psutil` package.
parallel : int, optional
When provided, run the tests in parallel on the specified
number of CPUs. If parallel is negative, it will use the all
Expand All @@ -115,7 +104,6 @@ def test(
on to the astropy test runner. This allows use of test-related
functionality implemented in later versions of astropy without
explicitly updating the package template.
"""
test_runner = _get_test_runner()
return test_runner.run_tests(
Expand Down
6 changes: 2 additions & 4 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ def run_tardis(
Parameters
----------
config: ~str or ~dict
config: str or dict
filename of configuration yaml file or dictionary
atom_data: ~str or ~tardis.atomic.AtomData
atom_data: str or tardis.atomic.AtomData
if atom_data is a string it is interpreted as a path to a file storing
the atomic data. Atomic data to use for this TARDIS simulation. If set to None, the
atomic data will be loaded according to keywords set in the configuration
Expand Down
89 changes: 36 additions & 53 deletions tardis/gui/datahandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from PySide2 import QtGui, QtCore, QtWidgets
else:
raise ImportError(
"QT_API was not set! Please exit the IPython console\n"
" and at the bash prompt use : \n\n export QT_API=pyside \n or\n"
" export QT_API=pyqt \n\n For more information refer to user guide."
"""QT_API was not set! Please exit the IPython console\n
and at the bash prompt use : \n\n export QT_API=pyside \n or\n
export QT_API=pyqt \n\n For more information refer to user guide."""
)
import yaml

Expand All @@ -39,31 +39,30 @@ class Node(object):
Attributes
----------
parent: None/Node
The parent of the node.
children: list of Node
The children of the node.
data: list of string
The data stored on the node. Can be a key or a value.
siblings: dictionary
A dictionary of nodes that are siblings of this node. The
keys are the values of the nodes themselves. This is
used to keep track of which value the user has selected
if the parent of this node happens to be a key that can
take values from a list.
parent : None/Node
The parent of the node.
children : list of Node
The children of the node.
data : list of string
The data stored on the node. Can be a key or a value.
siblings : dictionary
A dictionary of nodes that are siblings of this node. The
keys are the values of the nodes themselves. This is
used to keep track of which value the user has selected
if the parent of this node happens to be a key that can
take values from a list.
"""

def __init__(self, data, parent=None):
"""Create one node with the data and parent provided.
Parameters
----------
data: list of string
The data that is intended to be stored on the node.
parent: Node
Another node which is the parent of this node. The
root node has parent set to None.
data : list of string
The data that is intended to be stored on the node.
parent : Node
Another node which is the parent of this node. The
root node has parent set to None.
Note
----
Expand Down Expand Up @@ -91,7 +90,6 @@ def __init__(self, data, parent=None):
of the form valx are leaf nodes and are not dictionaries
themselves. If the keys have non-dictionary values then they
have a leaf attached. And no leaf can have a child.
"""
self.parent = parent
self.children = []
Expand All @@ -109,7 +107,6 @@ def get_child(self, i):
No error is raised if the cild requested doesn't exist. A
None is returned in such cases.
"""
if i < self.num_children():
return self.children[i]
Expand All @@ -129,7 +126,6 @@ def get_data(self, i):
No error is raised if the data list index is exceeded. A None is
returned in such cases.
"""
try:
return self.data[i]
Expand All @@ -143,7 +139,6 @@ def get_parent(self):
def get_index_of_self(self):
"""Returns the number at which it comes in the list of its
parent's children. For root the index 0 is returned.
"""
if self.parent:
return self.parent.children.index(self)
Expand All @@ -153,7 +148,6 @@ def get_index_of_self(self):
def set_data(self, column, value):
"""Set the data for the ith index to the provided value. Returns
true if the data was set successfully.
"""
if column < 0 or column >= self.num_columns():
return False
Expand All @@ -168,27 +162,25 @@ class TreeModel(QtCore.QAbstractItemModel):
Parameters
----------
root: Node
Root node of the tree.
disabledNodes: list of Node
List of leaf nodes that are not editable currently.
typenodes: list of Node
List of nodes that correspond to keys that set container
types. Look at tardis configuration template. These are the
nodes that have values that can be set from a list.
root : Node
Root node of the tree.
disabledNodes : list of Node
List of leaf nodes that are not editable currently.
typenodes : list of Node
List of nodes that correspond to keys that set container
types. Look at tardis configuration template. These are the
nodes that have values that can be set from a list.
"""

def __init__(self, dictionary, parent=None):
"""Create a tree of tardis configuration dictionary.
Parameters
----------
dictionary: dictionary
The dictionary that needs to be converted to the tree.
parent: None
Used to instantiate the QAbstractItemModel
dictionary : dictionary
The dictionary that needs to be converted to the tree.
parent : None
Used to instantiate the QAbstractItemModel
"""
QtCore.QAbstractItemModel.__init__(self, parent)

Expand All @@ -201,7 +193,6 @@ def __init__(self, dictionary, parent=None):
def columnCount(self, index):
"""Return the number of columns in the node pointed to by
the given model index.
"""
if index.isValid():
return index.internalPointer().num_columns()
Expand Down Expand Up @@ -256,7 +247,6 @@ def getItem(self, index):
def headerData(self, section, orientation, role):
"""Returns header data. This is not used in QColumnView. But will
be needed for QTreeView.
"""
if (
orientation == QtCore.Qt.Horizontal
Expand All @@ -270,7 +260,6 @@ def index(self, row, column, parent=QtCore.QModelIndex()):
"""Create a model index for the given row and column. For a
tree model, the row is the set of nodes with the same parents and
the column indexes the data in the node.
"""
if parent.isValid() and parent.column() != 0:
return QtCore.QModelIndex()
Expand Down Expand Up @@ -318,7 +307,6 @@ def rowCount(self, parent=QtCore.QModelIndex()):
"""The number of rows for a given node.
(The number of rows is just the number of children for a node.)
"""
parentItem = self.getItem(parent)

Expand All @@ -327,7 +315,6 @@ def rowCount(self, parent=QtCore.QModelIndex()):
def setData(self, index, value, role=QtCore.Qt.EditRole):
"""Set the value as the data at the location pointed by the
index.
"""
if role != QtCore.Qt.EditRole:
return False
Expand Down Expand Up @@ -358,11 +345,10 @@ def dict_to_tree(self, dictionary, root):
Parameters
----------
dictionary: dictionary
The dictionary that is to be converted to the tree.
root: Node
The root node of the tree.
dictionary : dictionary
The dictionary that is to be converted to the tree.
root : Node
The root node of the tree.
"""
# Construct tree with all nodes
self.tree_from_node(dictionary, root)
Expand Down Expand Up @@ -413,7 +399,6 @@ def tree_from_node(self, dictionary, root):
def dict_from_node(self, node):
"""Take a node and convert the whole subtree rooted at it into a
dictionary.
"""
children = [node.get_child(i) for i in range(node.num_children())]
if len(children) > 1:
Expand All @@ -431,7 +416,6 @@ def dict_from_node(self, node):
class TreeDelegate(QtWidgets.QStyledItemDelegate):
"""Create a custom delegate to modify the columnview that displays the
TreeModel.
"""

def __init__(self, parent=None):
Expand Down Expand Up @@ -459,7 +443,6 @@ def setModelData(self, editor, model, index):
"""Called when new data id set in the model. This is where the
siblings of type nodes are enabled or disabled according to the
new choice made.
"""
node = index.internalPointer()

Expand Down
8 changes: 3 additions & 5 deletions tardis/gui/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from PySide2 import QtCore, QtWidgets
else:
raise ImportError(
"QT_API was not set! Please exit the IPython console\n"
" and at the bash prompt use : \n\n export QT_API=pyside \n or\n"
" export QT_API=pyqt \n\n For more information refer to user guide."
"""QT_API was not set! Please exit the IPython console\n
and at the bash prompt use : \n\n export QT_API=pyside \n or\n
export QT_API=pyqt \n\n For more information refer to user guide."""
)
import sys

Expand Down Expand Up @@ -37,7 +37,6 @@ def show(model):
Finally the eventloop is started using IPython functions (which start them
consistently) if they were imported. Otherwise it is started explicitly.
"""
if importFailed:
app = QtWidgets.QApplication([])
Expand All @@ -64,7 +63,6 @@ def show(model):
if __name__ == "__main__":
"""When this module is executed as script, take arguments, calculate model
and call the show function.
"""
yamlfile = sys.argv[1]
atomfile = sys.argv[2]
Expand Down
Loading

0 comments on commit d4a7a7c

Please sign in to comment.