def _validate_type_dwtsub(self, x): # check size if self.__validate_enums(x, WaveletSubband): return True elif not isdict(x) or len(x) != 3: return False elif not contains(x, "values", "min-length", "max-length"): return False elif not self.__validate_enums(x["values"], WaveletSubband): return False return True
def __validate_type_range(self, x, test_fn=None): # check size if not isdict(x) or len(x) > 3: return False elif not contains(x, "start", "stop"): return False elif len(x) == 3 and "step" not in x: return False elif test_fn and not all(map(test_fn, x.values())): return False return True
def _normalize_coerce_dwtsub(self, x): if isdict(x) and contains(x, "values", "min-length", "max-length"): combs = [] values, min_len, max_len = x["values"], x["min-length"], x[ "max-length"] values = list(map(WaveletSubband, values)) for i in range(min_len, max_len + 1): combs.extend(combinations(values, i)) return combs values = self._normalize_coerce_aslist(x) return [[WaveletSubband(v)] for v in values]
def from_dict(data): watermarks = [] for k, v in data.items(): type_ = WatermarkType(k) for x in v: if isdict(x): path = x.pop("path") holder = WatermarkHolder(type_, path, x) watermarks.append(holder) elif isstr(x): watermarks.append(WatermarkHolder(type_, x)) return watermarks
def _normalize_coerce_asrange(self, x): if isdict(x) and contains(x, "start", "stop"): return np.arange(**x) return self._normalize_coerce_aslist(x)