Skip to content

Commit

Permalink
Catch Pandas warnings; change json output
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Jan 19, 2018
1 parent 5467d6c commit 9670908
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sciunit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import inspect
from copy import copy
import warnings
from datetime import datetime
from fnmatch import fnmatchcase
import json
Expand Down Expand Up @@ -138,7 +139,9 @@ def serialize(obj):

@property
def _class(self):
return self.__class__.__name__
url = getattr(self.__class__,'remote_url','')
return {'name':self.__class__.__name__,
'url':url}

@property
def id(self):
Expand Down Expand Up @@ -970,6 +973,10 @@ def __le__(self, other):
result = self.score <= other
return result

@property
def score_type(self):
return self.__class__.__name__


class ErrorScore(Score):
"""A score returned when an error occurs during testing."""
Expand Down Expand Up @@ -1132,10 +1139,14 @@ def __init__(self, tests, models, scores=None, weights=None):
if scores is None:
scores = [[NoneScore for test in tests] for model in models]
super(ScoreMatrix,self).__init__(data=scores, index=models, columns=tests)
self.tests = tests
self.models = models
n = len(tests)
self.weights = np.ones(n) if weights is None else np.array(weights)
with warnings.catch_warnings():
warnings.filterwarnings("ignore",
message=(".*Pandas doesn't allow columns "
"to be created via a new "))
self.tests = tests
self.models = models
self.weights = np.ones(n) if weights is None else np.array(weights)
self.weights /= self.weights.sum()

show_mean = False
Expand Down

0 comments on commit 9670908

Please sign in to comment.