original_docstring: 
          Builds an Embedding object from the given JSON object.
          
docstring: Builds an Embedding object from the given JSON object.
docstring_tokens: Builds an Embedding object from the given JSON object .
code: def from_json(cls, data, label=None, parent=None):
          """
          Builds an Embedding object from the given JSON object.
          """
          mats = {}
          if data.get("_format", "expanded") == "compressed":
              dtype = np.dtype(data["_idtype"])
              ids = decode_numerical_array(data["ids"], dtype)
              
              if "position" in data:
                  mats[Field.POSITION] = decode_numerical_array(data["position"])
              else:
                  mats[Field.POSITION] = np.hstack([
                      decode_numerical_array(data["x"]).reshape(-1, 1),
                      decode_numerical_array(data["y"]).reshape(-1, 1),
                  ])
  
              mats[Field.COLOR] = np.array(decode_object_array(data["color"]))
              if "alpha" in data:
                  mats[Field.ALPHA] = decode_numerical_array(data["alpha"])
              if "r" in data:
                  mats[Field.RADIUS] = decode_numerical_array(data["r"])
          else:
              point_data = data["points"]
              try:
                  ids = [int(id_val) for id_val in list(point_data.keys())]
                  point_data = {int(k): v for k, v in point_data.items()}
              except:
                  ids = list(point_data.keys())
              ids = sorted(ids)
              
              try:
                  mats[Field.POSITION] = np.array([point_data[id_val]["position"] for id_val in ids])
              except KeyError:   
                  mats[Field.POSITION] = np.array([[point_data[id_val]["x"], point_data[id_val]["y"]] for id_val in ids])
  
              mats[Field.COLOR] = np.array([point_data[id_val]["color"] for id_val in ids])
              if "alpha" in data[ids[0]]:
                  mats[Field.ALPHA] = np.array([point_data[id_val]["alpha"] for id_val in ids])
              if "r" in data[ids[0]]:
                  mats[Field.RADIUS] = np.array([point_data[id_val]["r"] for id_val in ids])
  
          if "neighbors" in data:
              neighbors = Neighbors.from_json(data["neighbors"])
          else:
              neighbors = None
          metric = data.get("metric", "euclidean")
          n_neighbors = data.get("n_neighbors", 100)
          return cls(mats, ids=ids, label=label, metric=metric, n_neighbors=n_neighbors, neighbors=neighbors, parent=parent)
code_tokens: def from_json ( cls , data , label = None , parent = None ) : mats = { } if data . get ( "_format" , "expanded" ) == "compressed" : dtype = np . dtype ( data [ "_idtype" ] ) ids = decode_numerical_array ( data [ "ids" ] , dtype ) if "position" in data : mats [ Field . POSITION ] = decode_numerical_array ( data [ "position" ] ) else : mats [ Field . POSITION ] = np . hstack ( [ decode_numerical_array ( data [ "x" ] ) . reshape ( - 1 , 1 ) , decode_numerical_array ( data [ "y" ] ) . reshape ( - 1 , 1 ) , ] ) mats [ Field . COLOR ] = np . array ( decode_object_array ( data [ "color" ] ) ) if "alpha" in data : mats [ Field . ALPHA ] = decode_numerical_array ( data [ "alpha" ] ) if "r" in data : mats [ Field . RADIUS ] = decode_numerical_array ( data [ "r" ] ) else : point_data = data [ "points" ] try : ids = [ int ( id_val ) for id_val in list ( point_data . keys ( ) ) ] point_data = { int ( k ) : v for k , v in point_data . items ( ) } except : ids = list ( point_data . keys ( ) ) ids = sorted ( ids ) try : mats [ Field . POSITION ] = np . array ( [ point_data [ id_val ] [ "position" ] for id_val in ids ] ) except KeyError : mats [ Field . POSITION ] = np . array ( [ [ point_data [ id_val ] [ "x" ] , point_data [ id_val ] [ "y" ] ] for id_val in ids ] ) mats [ Field . COLOR ] = np . array ( [ point_data [ id_val ] [ "color" ] for id_val in ids ] ) if "alpha" in data [ ids [ 0 ] ] : mats [ Field . ALPHA ] = np . array ( [ point_data [ id_val ] [ "alpha" ] for id_val in ids ] ) if "r" in data [ ids [ 0 ] ] : mats [ Field . RADIUS ] = np . array ( [ point_data [ id_val ] [ "r" ] for id_val in ids ] ) if "neighbors" in data : neighbors = Neighbors . from_json ( data [ "neighbors" ] ) else : neighbors = None metric = data . get ( "metric" , "euclidean" ) n_neighbors = data . get ( "n_neighbors" , 100 ) return cls ( mats , ids = ids , label = label , metric = metric , n_neighbors = n_neighbors , neighbors = neighbors , parent = parent )
short_docstring: Builds an Embedding object from the given JSON object.
short_docstring_tokens: Builds an Embedding object from the given JSON object .
comment: """
          Builds an Embedding object from the given JSON object.
          """