def __init__(self, parameter: Parameter, name: typing.Optional[str]=None, novalue=None):
    domain = parameter.domain
    self.explicit_cm = None
    if (name and name.startswith('{')):
        self.explicit_cm = collections.OrderedDict()
        raw = json.loads(name, object_pairs_hook=collections.OrderedDict)
        if novalue:
            raw.setdefault('None', novalue)
        label_to_code = {v: k for (k, v) in parameter.domain.items()}
        for (v, c) in raw.items():
            if ((v not in parameter.value_to_code) and (v not in label_to_code)):
                raise ValueError('Colormap value "{}" not in domain {}'.format(v, list(parameter.value_to_code.keys())))
            v = parameter.value_to_code.get(v, label_to_code.get(v))
            self.explicit_cm[v] = hextriplet(c)
        vals = list(parameter.value_to_code)
        if (len(vals) > len(self.explicit_cm)):
            raise ValueError('Colormap {} does not cover all values {}!'.format(dict(raw), vals))
        name = None
        parameter.domain = collections.OrderedDict(((c, l) for (c, l) in sorted([i for i in parameter.domain.items() if (i[0] in self.explicit_cm)], key=(lambda i: list(self.explicit_cm.keys()).index(i[0])))))
    self.novalue = (hextriplet(novalue) if novalue else None)
    self._cm = getattr(cm, (name or 'yyy'), cm.jet)
    if isinstance(domain, tuple):
        assert (not self.explicit_cm)
        norm = Normalize(domain[0], domain[1])
        self.cm = (lambda v: to_hex(self._cm(norm(float(v)))))
    elif self.explicit_cm:
        self.cm = (lambda v: self.explicit_cm[v])
    else:
        if (name == 'seq'):
            colors = sequential_colors(len(domain))
        else:
            colors = qualitative_colors(len(domain), set=name)
        self.cm = (lambda v: dict(zip(domain, colors))[v])
def __init__(self, parameter: Parameter, name: typing.Optional[str]=None, novalue=None):
    domain = parameter.domain
    self.explicit_cm = None
    if (name and name.startswith('{')):
        self.explicit_cm = collections.OrderedDict()
        raw = json.loads(name, object_pairs_hook=collections.OrderedDict)
        if novalue:
            raw.setdefault('None', novalue)
        label_to_code = {v: k for (k, v) in parameter.domain.items()}
        for (v, c) in raw.items():
            if ((v not in parameter.value_to_code) and (v not in label_to_code)):
                raise ValueError('Colormap value "{}" not in domain {}'.format(v, list(parameter.value_to_code.keys())))
            v = parameter.value_to_code.get(v, label_to_code.get(v))
            self.explicit_cm[v] = hextriplet(c)
        vals = list(parameter.value_to_code)
        if (len(vals) > len(self.explicit_cm)):
            raise ValueError('Colormap {} does not cover all values {}!'.format(dict(raw), vals))
        name = None
        parameter.domain = collections.OrderedDict(((c, l) for (c, l) in sorted([i for i in parameter.domain.items() if (i[0] in self.explicit_cm)], key=(lambda i: list(self.explicit_cm.keys()).index(i[0])))))
    self.novalue = (hextriplet(novalue) if novalue else None)
    self._cm = getattr(cm, (name or 'yyy'), cm.jet)
    if isinstance(domain, tuple):
        assert (not self.explicit_cm)
        norm = Normalize(domain[0], domain[1])
        self.cm = (lambda v: to_hex(self._cm(norm(float(v)))))
    elif self.explicit_cm:
        self.cm = (lambda v: self.explicit_cm[v])
    else:
        if (name == 'seq'):
            colors = sequential_colors(len(domain))
        else:
            colors = qualitative_colors(len(domain), set=name)
        self.cm = (lambda v: dict(zip(domain, colors))[v])