summaryrefslogtreecommitdiff
path: root/ricky/params/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'ricky/params/__init__.py')
-rw-r--r--ricky/params/__init__.py34
1 files changed, 9 insertions, 25 deletions
diff --git a/ricky/params/__init__.py b/ricky/params/__init__.py
index 53ac530..82cbc79 100644
--- a/ricky/params/__init__.py
+++ b/ricky/params/__init__.py
@@ -25,27 +25,14 @@ class Params(object):
def __len__(self):
return len(self._params)
+
def _load_probabilities_json(self, probabilities_file=None):
- if probabilities_file:
- filepath = probabilities_file
- else:
- filepath = os.path.join(
+ filepath = probabilities_file or \
+ os.path.join(
PROBABILITIES_DIR,
"%s.json" % (self.__class__.__name__)
)
- try:
- f = open(filepath, 'r')
- data = f.read()
- f.close()
- return json.loads(data)
- except json.scanner.JSONDecodeError as e:
- sys.stderr.write("Invalid Json - Problem decoding %s\n" % filepath)
- sys.stderr.write("%s\n" % e)
- sys.exit(1)
- except IOError:
- sys.stderr.write(
- "Could not find probabilities file %s\n" % filepath)
- sys.exit(1)
+ return json.load(open(filepath))
def randomize(
self,
@@ -65,7 +52,6 @@ class Params(object):
param.randomize(probabilities=probabilities_dict.get(param.name))
-
def execute(self):
"""calls the associated api"""
if OFFLINE:
@@ -94,12 +80,6 @@ class Params(object):
result[param.name] = param.value
return result
- def as_normalized(self):
- return tuple([
- {'name': param.name, 'normalized': param.as_normalized()}
- for param in self._params
- ])
-
def as_serialized(self):
"""
returns params in serialized form to use in a dataset
@@ -120,7 +100,11 @@ class Params(object):
param.value = params_dict[param.name]
@classmethod
- def from_classname(cls, classname):
+ def new_class_from_classname(cls, classname):
+ """
+ #FIXME make this class a plugin parent class
+ anything else look weird here?
+ """
for subclass in cls.__subclasses__():
if subclass.__name__ == classname:
return subclass()