Skip to content

Commit

Permalink
New unit tests and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Oct 10, 2017
1 parent be289e6 commit ce3f108
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ install:
before_script:
- git clone -b cosmosuite http://github.com/scidash/scidash ../scidash
script:
- coverage run --source=. setup.py test
- coverage run --source=. --omit=*unit_test* setup.py test
after_success:
- coveralls
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Richard C. Gerkin and Cyrus Omar
Copyright (c) 2011- Richard C. Gerkin and Cyrus Omar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
56 changes: 35 additions & 21 deletions sciunit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def __init__(self, name=None, **params):
def capabilities(self):
capabilities = []
for cls in self.__class__.mro():
if Capability in cls.mro() and cls is not Capability:
if issubclass(cls,Capability) and cls is not Capability \
and not issubclass(cls,Model):
capabilities.append(cls.__name__)
return capabilities

Expand Down Expand Up @@ -367,13 +368,14 @@ def optimize(self, model):

def describe(self):
result = "No description available"
print(self)
if self.description:
result = "%s" % self.description
else:
if self.__doc__:
s = []
s += [self.__doc__.strip().replace('\n','').replace(' ','')]
if self.test.converter:
if self.converter:
s += [self.converter.description]
result = '\n'.join(s)
return result
Expand Down Expand Up @@ -449,7 +451,7 @@ def judge(self, models,
skip = self.is_skipped(model)
for test in self.tests:
if skip:
sm.loc[model,test] = NoneScore(None)
sm.loc[model,test] = score = NoneScore(None)
else:
score = self.judge_one(model,test,sm,skip_incapable,
stop_on_error,deep_error)
Expand Down Expand Up @@ -667,34 +669,46 @@ def __str__(self):
return '%s' % self.score

def __eq__(self, other):
return self.sort_key == other.sort_key
if isinstance(other,Score):
result = self.sort_key == other.sort_key
else:
result = self.score == other
return result

def __ne__(self, other):
return self.sort_key != other.sort_key
if isinstance(other,Score):
result = self.sort_key != other.sort_key
else:
result = self.score != other
return result

def __gt__(self, other):
try:
return self.sort_key > other.sort_key
except TypeError:
return 0
if isinstance(other,Score):
result = self.sort_key > other.sort_key
else:
result = self.score > other
return result

def __ge__(self, other):
try:
return self.sort_key >= other.sort_key
except TypeError:
return 0
if isinstance(other,Score):
result = self.sort_key >= other.sort_key
else:
result = self.score >= other
return result

def __lt__(self, other):
try:
return self.sort_key < other.sort_key
except TypeError:
return 0
if isinstance(other,Score):
result = self.sort_key < other.sort_key
else:
result = self.score < other
return result

def __le__(self, other):
try:
return self.sort_key <= other.sort_key
except TypeError:
return 0
if isinstance(other,Score):
result = self.sort_key <= other.sort_key
else:
result = self.score <= other
return result


class ErrorScore(Score):
Expand Down
4 changes: 2 additions & 2 deletions sciunit/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _convert(self, score):
self.__class__.__name__))

def convert(self, score):
new_score = self._convert(score.score)
new_score = self._convert(score)
new_score.set_raw(score.get_raw())
for key,value in score.__dict__.items():
if key not in ['score','_raw']:
Expand All @@ -59,7 +59,7 @@ def __init__(self, f):
self.f = f

def _convert(self, score):
return self.f(score)
return score.__class__(self.f(score))


class AtMostToBoolean(Converter):
Expand Down
Loading

0 comments on commit ce3f108

Please sign in to comment.