Skip to content

Commit

Permalink
Fix generate_metadata_table and add test. (#80)
Browse files Browse the repository at this point in the history
* Fix generate_metadata_table and add test.

* remove python 2.7 from travis.yml
  • Loading branch information
schymans authored Apr 28, 2020
1 parent c3751de commit c4e62cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ git:
depth: false

python:
- '2.7'
- '3.6'

sudo: true
Expand Down
2 changes: 1 addition & 1 deletion essm/variables/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def generate_metadata_table(variables=None, include_header=True, cols=None):
name = str(variable)
doc = variable.__doc__
defn1 = Variable.__expressions__.get(variable, '')
if len(defn1) > 1:
if len(str(defn1)) > 1:
defn = '$' + latex(defn1) + '$'
else:
defn = ''
Expand Down
7 changes: 5 additions & 2 deletions tests/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ def test_markdown():

def test_generate_metadata_table():
"""Check display of table of units."""
assert generate_metadata_table([E_l, lambda_E]) \
assert generate_metadata_table([demo_expression_variable, E_l, lambda_E]) \
== [('Symbol', 'Name', 'Description', 'Definition', 'Default value',
'Units'),
('$\\lambda_E$', 'lambda_E', 'Latent heat of evaporation.', '',
'2450000.0', 'J kg$^{-1}$'), ('$E_l$', 'E_l',
'2450000.0', 'J kg$^{-1}$'),
('$demo_expression_variable$', 'demo_expression_variable',
'Test expression variable.', '$2 demo_variable$', '-', 'm'),
('$E_l$', 'E_l',
'Latent heat flux from leaf.', '', '-', 'J s$^{-1}$ m$^{-2}$')]

0 comments on commit c4e62cd

Please sign in to comment.