Skip to content

Commit

Permalink
Updates for release
Browse files Browse the repository at this point in the history
  • Loading branch information
djcomlab committed Apr 16, 2018
1 parent 7cc2ba3 commit 333a551
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions isatools/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ def __ne__(self, other):
return not self == other


class ParameterValue(object):
class ParameterValue(Commentable):
"""A ParameterValue represents the instance value of a ProtocolParameter,
used in a Process.
Expand Down Expand Up @@ -2377,19 +2377,21 @@ def unit(self, val):

def __repr__(self):
return 'isatools.model.ParameterValue(category={category}, ' \
'value={value}, unit={unit})'.format(
'value={value}, unit={unit}, comments={comments})'.format(
category=repr(self.category), value=repr(self.value),
unit=repr(self.unit))
unit=repr(self.unit), comments=repr(self.comments))

def __str__(self):
return """ParameterValue(
category={category}
value={value}
unit={unit}
comments={num_comments} Comment objects
)""".format(category=self.category.parameter_name.term if self.category else '',
value=self.value.term if isinstance(
self.value, OntologyAnnotation) else repr(self.value),
unit=self.unit.term if self.unit else '')
unit=self.unit.term if self.unit else '',
num_comments=len(self.comments))

def __hash__(self):
return hash(repr(self))
Expand Down
6 changes: 4 additions & 2 deletions tests/test_isatools_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def setUp(self):

def test_repr(self):
self.assertEqual("isatools.model.ParameterValue(category=None, "
"value=None, unit=None)",
"value=None, unit=None, comments=[])",
repr(self.parameter_value_default))
self.assertEqual("isatools.model.ParameterValue("
"category=isatools.model.ProtocolParameter("
Expand All @@ -743,20 +743,22 @@ def test_repr(self):
"comments=[]), comments=[]), value=0, "
"unit=isatools.model.OntologyAnnotation("
"term='U', term_source=None, term_accession='', "
"comments=[]))",
"comments=[]), comments=[])",
repr(self.parameter_value))

def test_str(self):
self.assertEqual("""ParameterValue(
category=
value=None
unit=
comments=0 Comment objects
)""", str(self.parameter_value_default))

self.assertEqual("""ParameterValue(
category=P
value=0
unit=U
comments=0 Comment objects
)""", str(self.parameter_value))

def test_eq(self):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35, py36
envlist = py27, py36

[testenv]
commands=py.test --basetemp=tests
Expand Down

0 comments on commit 333a551

Please sign in to comment.