@classmethod
    def from_json(cls, json_thing):
        # Python3 compatibility
        try:
          basestring
        except NameError:
          basestring = str

        if isinstance(json_thing, basestring):
            obj = json.loads(json_thing)
        else:
            obj = json_thing

        if isinstance(obj, list):
            rehydrated = dict((tuple(item[0]), item[1]) for item in obj)
        elif isinstance(obj, dict):
            rehydrated = obj
        else:
            raise ValueError("Object should be dict or list")

        state_size = len(list(rehydrated.keys())[0])

        inst = cls(None, state_size, rehydrated)
        return inst
Compute Non-negative Matrix Factorization (NMF) with Projected Gradient
dataset/ETHPy150Open jsvine/markovify/markovify/chain.py/Chain.from_json--crossover with--dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/decomposition/nmf.py/_fit_projected_gradient