Skip to content

Commit

Permalink
Processes classes and variable attributes as attr extension, stores, …
Browse files Browse the repository at this point in the history
…and way too much!! (#33)

Processes classes and variable attributes as attr extension, stores, and way too much!!
  • Loading branch information
benbovy authored May 7, 2018
1 parent 25a7a9e commit 65f4f01
Show file tree
Hide file tree
Showing 46 changed files with 4,354 additions and 4,033 deletions.
36 changes: 30 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@ language: python
sudo: false # use container based build
notifications:
email: false
branches:
only:
- master

matrix:
fast_finish: True
include:
- python: 3.4
env: CONDA_ENV=py34
- python: 3.5
env: CONDA_ENV=py35
- python: 3.6
env: CONDA_ENV=py36
- python: 3.6
env: CONDA_ENV=py36-xarray-dev
- python: 3.6
env: CONDA_ENV=py36-attrs-dev
- python: 3.5
env: CONDA_ENV=docs
allow_failures:
- python: 3.6
env: CONDA_ENV=py36-xarray-dev
- python: 3.6
env: CONDA_ENV=py36-attrs-dev

before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
Expand All @@ -29,12 +41,24 @@ before_install:
- conda info -a

install:
- conda env create --file ci/requirements-$CONDA_ENV.yml
- source activate test_env_$CONDA_ENV
- python setup.py install
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda env create -n test_env --file doc/environment.yml;
else
conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml;
fi
- source activate test_env
- conda list
- pip install --no-deps -e .

script:
- py.test xsimlab --cov=xsimlab --cov-report term-missing
- python -OO -c "import xsimlab"
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda install -c conda-forge sphinx_rtd_theme;
cd doc;
sphinx-build -n -j auto -b html -d _build/doctrees . _build/html;
else
py.test xsimlab --cov=xsimlab --cov-report term-missing --verbose;
fi

after_success:
- coveralls
1 change: 1 addition & 0 deletions ci/requirements-py35.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: test_env_py35
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- python=3.5
- pytest
- numpy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: test_env_py34
name: test_env_py36-attrs-dev
channels:
- conda-forge
dependencies:
- python=3.4
- python=3.6
- pytest
- numpy
- xarray
- pip:
- git+https://github.com/python-attrs/attrs.git
- coveralls
- pytest-cov
12 changes: 12 additions & 0 deletions ci/requirements-py36-xarray-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test_env_py36-xarray-dev
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- python=3.6
- pytest
- numpy
- pip:
- git+https://github.com/pydata/xarray.git
- coveralls
- pytest-cov
1 change: 1 addition & 0 deletions ci/requirements-py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: test_env_py36
channels:
- conda-forge
dependencies:
- attrs>=18.1.0
- python=3.6
- pytest
- numpy
Expand Down
128 changes: 18 additions & 110 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ properties listed below. Proper use of this accessor should be like:

Dataset.xsimlab.clock_coords
Dataset.xsimlab.master_clock_dim
Dataset.xsimlab.snapshot_vars
Dataset.xsimlab.output_vars

**Methods**

Expand Down Expand Up @@ -79,14 +79,17 @@ Model introspection
-------------------

``Model`` implements an immutable mapping interface where keys are
process names and values are objects of ``Process`` subclasses (attribute-style
access is also supported).
process names and values are objects of ``Process`` subclasses
(attribute-style access is also supported).

.. autosummary::
:toctree: _api_generated/

Model.all_vars
Model.all_vars_dict
Model.input_vars
Model.is_input
Model.input_vars_dict
Model.dependent_processes
Model.visualize

Running a model
Expand All @@ -109,126 +112,31 @@ interfaces.
Process
=======

Note: ``Process`` is a base class that should be subclassed.
Creating a process
------------------

.. autosummary::
:toctree: _api_generated/

Process
process

Clone a process
---------------

.. autosummary::
:toctree: _api_generated/

Process.clone

Process interface and introspection
Process introspection and variables
-----------------------------------

``Process`` implements an immutable mapping interface where keys are
variable names and values are Variable objects (attribute-style
access is also supported).

.. autosummary::
:toctree: _api_generated/

Process.variables
Process.meta
Process.name
Process.info

Process "abstract" methods
--------------------------

Subclasses of ``Process`` usually implement at least some of the methods below.

.. autosummary::
:toctree: _api_generated/

Process.validate
Process.initialize
Process.run_step
Process.finalize_step
Process.finalize
process_info
variable_info
filter_variables

Variable
========

Base variable class
-------------------

Although it has the same name, this class is different from
:py:class:`xarray.Variable`.

.. autosummary::
:toctree: _api_generated/

Variable

**Attributes**

.. autosummary::
:toctree: _api_generated/

Variable.value
Variable.state
Variable.rate
Variable.change

**Methods**

.. autosummary::
:toctree: _api_generated/

Variable.to_xarray_variable

Derived variable classes
------------------------

These classes inherit from ``Variable``.

.. autosummary::
:toctree: _api_generated/

NumberVariable
FloatVariable
IntegerVariable

Foreign variable
----------------

.. autosummary::
:toctree: _api_generated/

ForeignVariable

**Attributes**

.. autosummary::
:toctree: _api_generated/

ForeignVariable.ref_process
ForeignVariable.ref_var
ForeignVariable.value
ForeignVariable.state
ForeignVariable.rate
ForeignVariable.change

Diagnostic variable
-------------------

.. autosummary::
:toctree: _api_generated/

diagnostic

Collections of variables
------------------------

.. autosummary::
:toctree: _api_generated/

VariableList
VariableGroup
variable
foreign
group
on_demand
16 changes: 7 additions & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
print("numpy: %s, %s" % (numpy.__version__, numpy.__file__))
except ImportError:
print("no numpy")
try:
import attr
print("attr: %s, %s" % (attr.__version__, attr.__file__))
except ImportError:
print("no attr")
try:
import xarray
print("xarray: %s, %s" % (xarray.__version__, xarray.__file__))
Expand Down Expand Up @@ -120,15 +125,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#

# on_rtd is whether we are on readthedocs.org, this line of code grabbed from
# docs.readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme = 'sphinx_rtd_theme'

# otherwise, readthedocs.org uses their theme by default, so no need
# to specify it
Expand Down Expand Up @@ -205,6 +202,7 @@
intersphinx_mapping = {
'python': ('https://docs.python.org/3.6/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'attr': ('http://www.attrs.org/en/stable/', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
'xarray': ('http://xarray.pydata.org/en/stable/', None)
}
Expand Down
Loading

0 comments on commit 65f4f01

Please sign in to comment.