Skip to content

Commit

Permalink
use OrderedDict for process variables and meta (consistent repr)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy committed Jun 28, 2017
1 parent 3ce2d21 commit 0af1665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions xsimlab/process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import inspect
import copy
from collections import OrderedDict

from .variable.base import (AbstractVariable, DiagnosticVariable,
VariableList, VariableGroup)
Expand Down Expand Up @@ -76,12 +77,12 @@ def __new__(cls, name, bases, attrs):
)
meta_dict.update(meta_attrs)

new_attrs['_meta'] = meta_dict
new_attrs['_meta'] = OrderedDict(sorted(meta_dict.items()))

# add variables and diagnostics separately from the rest of
# the attributes and methods defined in the class
vars, novars = _extract_variables(attrs)
new_attrs['_variables'] = vars
new_attrs['_variables'] = OrderedDict(sorted(vars.items()))
for k, v in novars.items():
new_attrs[k] = v

Expand Down
4 changes: 2 additions & 2 deletions xsimlab/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def setUp(self):
self.my_process = MyProcess()
self.my_process_str = dedent("""\
Variables:
* diag DiagnosticVariable
* var Variable ()
var_group VariableGroup 'group'
var_list VariableList
- Variable ('x')
- Variable (), ('x')
var_group VariableGroup 'group'
* diag DiagnosticVariable
Meta:
time_dependent: False""")

Expand Down

0 comments on commit 0af1665

Please sign in to comment.