Skip to content

Commit 65f4f01

Browse files
authored
Processes classes and variable attributes as attr extension, stores, and way too much!! (#33)
Processes classes and variable attributes as attr extension, stores, and way too much!!
1 parent 25a7a9e commit 65f4f01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4354
-4033
lines changed

.travis.yml

+30-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ language: python
44
sudo: false # use container based build
55
notifications:
66
email: false
7+
branches:
8+
only:
9+
- master
710

811
matrix:
912
fast_finish: True
1013
include:
11-
- python: 3.4
12-
env: CONDA_ENV=py34
1314
- python: 3.5
1415
env: CONDA_ENV=py35
1516
- python: 3.6
1617
env: CONDA_ENV=py36
18+
- python: 3.6
19+
env: CONDA_ENV=py36-xarray-dev
20+
- python: 3.6
21+
env: CONDA_ENV=py36-attrs-dev
22+
- python: 3.5
23+
env: CONDA_ENV=docs
24+
allow_failures:
25+
- python: 3.6
26+
env: CONDA_ENV=py36-xarray-dev
27+
- python: 3.6
28+
env: CONDA_ENV=py36-attrs-dev
1729

1830
before_install:
1931
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
@@ -29,12 +41,24 @@ before_install:
2941
- conda info -a
3042

3143
install:
32-
- conda env create --file ci/requirements-$CONDA_ENV.yml
33-
- source activate test_env_$CONDA_ENV
34-
- python setup.py install
44+
- if [[ "$CONDA_ENV" == "docs" ]]; then
45+
conda env create -n test_env --file doc/environment.yml;
46+
else
47+
conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml;
48+
fi
49+
- source activate test_env
50+
- conda list
51+
- pip install --no-deps -e .
3552

3653
script:
37-
- py.test xsimlab --cov=xsimlab --cov-report term-missing
54+
- python -OO -c "import xsimlab"
55+
- if [[ "$CONDA_ENV" == "docs" ]]; then
56+
conda install -c conda-forge sphinx_rtd_theme;
57+
cd doc;
58+
sphinx-build -n -j auto -b html -d _build/doctrees . _build/html;
59+
else
60+
py.test xsimlab --cov=xsimlab --cov-report term-missing --verbose;
61+
fi
3862

3963
after_success:
4064
- coveralls

ci/requirements-py35.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: test_env_py35
22
channels:
33
- conda-forge
44
dependencies:
5+
- attrs>=18.1.0
56
- python=3.5
67
- pytest
78
- numpy
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: test_env_py34
1+
name: test_env_py36-attrs-dev
22
channels:
33
- conda-forge
44
dependencies:
5-
- python=3.4
5+
- python=3.6
66
- pytest
77
- numpy
88
- xarray
99
- pip:
10+
- git+https://github.com/python-attrs/attrs.git
1011
- coveralls
1112
- pytest-cov

ci/requirements-py36-xarray-dev.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: test_env_py36-xarray-dev
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- attrs>=18.1.0
6+
- python=3.6
7+
- pytest
8+
- numpy
9+
- pip:
10+
- git+https://github.com/pydata/xarray.git
11+
- coveralls
12+
- pytest-cov

ci/requirements-py36.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: test_env_py36
22
channels:
33
- conda-forge
44
dependencies:
5+
- attrs>=18.1.0
56
- python=3.6
67
- pytest
78
- numpy

doc/api.rst

+18-110
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ properties listed below. Proper use of this accessor should be like:
4040

4141
Dataset.xsimlab.clock_coords
4242
Dataset.xsimlab.master_clock_dim
43-
Dataset.xsimlab.snapshot_vars
43+
Dataset.xsimlab.output_vars
4444

4545
**Methods**
4646

@@ -79,14 +79,17 @@ Model introspection
7979
-------------------
8080

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

8585
.. autosummary::
8686
:toctree: _api_generated/
8787

88+
Model.all_vars
89+
Model.all_vars_dict
8890
Model.input_vars
89-
Model.is_input
91+
Model.input_vars_dict
92+
Model.dependent_processes
9093
Model.visualize
9194

9295
Running a model
@@ -109,126 +112,31 @@ interfaces.
109112
Process
110113
=======
111114

112-
Note: ``Process`` is a base class that should be subclassed.
115+
Creating a process
116+
------------------
113117

114118
.. autosummary::
115119
:toctree: _api_generated/
116120

117-
Process
121+
process
118122

119-
Clone a process
120-
---------------
121-
122-
.. autosummary::
123-
:toctree: _api_generated/
124-
125-
Process.clone
126-
127-
Process interface and introspection
123+
Process introspection and variables
128124
-----------------------------------
129125

130-
``Process`` implements an immutable mapping interface where keys are
131-
variable names and values are Variable objects (attribute-style
132-
access is also supported).
133-
134126
.. autosummary::
135127
:toctree: _api_generated/
136128

137-
Process.variables
138-
Process.meta
139-
Process.name
140-
Process.info
141-
142-
Process "abstract" methods
143-
--------------------------
144-
145-
Subclasses of ``Process`` usually implement at least some of the methods below.
146-
147-
.. autosummary::
148-
:toctree: _api_generated/
149-
150-
Process.validate
151-
Process.initialize
152-
Process.run_step
153-
Process.finalize_step
154-
Process.finalize
129+
process_info
130+
variable_info
131+
filter_variables
155132

156133
Variable
157134
========
158135

159-
Base variable class
160-
-------------------
161-
162-
Although it has the same name, this class is different from
163-
:py:class:`xarray.Variable`.
164-
165-
.. autosummary::
166-
:toctree: _api_generated/
167-
168-
Variable
169-
170-
**Attributes**
171-
172-
.. autosummary::
173-
:toctree: _api_generated/
174-
175-
Variable.value
176-
Variable.state
177-
Variable.rate
178-
Variable.change
179-
180-
**Methods**
181-
182-
.. autosummary::
183-
:toctree: _api_generated/
184-
185-
Variable.to_xarray_variable
186-
187-
Derived variable classes
188-
------------------------
189-
190-
These classes inherit from ``Variable``.
191-
192-
.. autosummary::
193-
:toctree: _api_generated/
194-
195-
NumberVariable
196-
FloatVariable
197-
IntegerVariable
198-
199-
Foreign variable
200-
----------------
201-
202-
.. autosummary::
203-
:toctree: _api_generated/
204-
205-
ForeignVariable
206-
207-
**Attributes**
208-
209-
.. autosummary::
210-
:toctree: _api_generated/
211-
212-
ForeignVariable.ref_process
213-
ForeignVariable.ref_var
214-
ForeignVariable.value
215-
ForeignVariable.state
216-
ForeignVariable.rate
217-
ForeignVariable.change
218-
219-
Diagnostic variable
220-
-------------------
221-
222-
.. autosummary::
223-
:toctree: _api_generated/
224-
225-
diagnostic
226-
227-
Collections of variables
228-
------------------------
229-
230136
.. autosummary::
231137
:toctree: _api_generated/
232138

233-
VariableList
234-
VariableGroup
139+
variable
140+
foreign
141+
group
142+
on_demand

doc/conf.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
print("numpy: %s, %s" % (numpy.__version__, numpy.__file__))
2727
except ImportError:
2828
print("no numpy")
29+
try:
30+
import attr
31+
print("attr: %s, %s" % (attr.__version__, attr.__file__))
32+
except ImportError:
33+
print("no attr")
2934
try:
3035
import xarray
3136
print("xarray: %s, %s" % (xarray.__version__, xarray.__file__))
@@ -120,15 +125,7 @@
120125
# The theme to use for HTML and HTML Help pages. See the documentation for
121126
# a list of builtin themes.
122127
#
123-
124-
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from
125-
# docs.readthedocs.org
126-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
127-
128-
if not on_rtd: # only import and set the theme if we're building docs locally
129-
import sphinx_rtd_theme
130-
html_theme = 'sphinx_rtd_theme'
131-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
128+
html_theme = 'sphinx_rtd_theme'
132129

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

0 commit comments

Comments
 (0)