aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorshivesh <s.p.mandalia@qmul.ac.uk>2018-04-04 11:20:25 -0500
committershivesh <s.p.mandalia@qmul.ac.uk>2018-04-04 11:20:25 -0500
commit9b12d2bf5d2047539dbb85ed3c218114cf1406d7 (patch)
tree2f1fb616cb90088e823a86013c053f59d1efd12c /utils
parenta6ced28fe29f5dc82108f14e310a0c6b5f04b3c7 (diff)
downloadGolemFlavor-9b12d2bf5d2047539dbb85ed3c218114cf1406d7.tar.gz
GolemFlavor-9b12d2bf5d2047539dbb85ed3c218114cf1406d7.zip
add misc methods
Diffstat (limited to 'utils')
-rw-r--r--utils/enums.py3
-rw-r--r--utils/misc.py16
2 files changed, 17 insertions, 2 deletions
diff --git a/utils/enums.py b/utils/enums.py
index e154d0f..7798cca 100644
--- a/utils/enums.py
+++ b/utils/enums.py
@@ -45,7 +45,8 @@ class ParamTag(Enum):
MMANGLES = 2
SCALE = 3
SRCANGLES = 4
- NONE = 5
+ BESTFIT = 5
+ NONE = 6
class Priors(Enum):
diff --git a/utils/misc.py b/utils/misc.py
index 108a458..ebc66e2 100644
--- a/utils/misc.py
+++ b/utils/misc.py
@@ -57,7 +57,7 @@ class Param(object):
def tag(self):
return self._tag
- @tex.setter
+ @tag.setter
def tag(self, t):
if t is None: self._tag = ParamTag.NONE
else:
@@ -150,10 +150,24 @@ class ParamSet(Sequence):
def from_tag(self, tag):
return tuple([obj for obj in self._params if obj.tag is tag])
+ def remove_tag(self, tag):
+ return tuple([obj for obj in self._params if obj.tag is not tag])
+
def idx_from_tag(self, tag):
return tuple([idx for idx, obj in enumerate(self._params)
if obj.tag is tag])
+ def not_idx_from_tag(self, tag):
+ return tuple([idx for idx, obj in enumerate(self._params)
+ if obj.tag is not tag])
+
+ def slice_from_tag(self, array, tags):
+ tags = [tags]
+ idxs = []
+ for tag in tags:
+ idxs.extend(self.idx_from_tag(tag))
+ return array[idxs,]
+
class SortingHelpFormatter(argparse.HelpFormatter):
"""Sort argparse help options alphabetically."""