original_docstring: 
          Converts this embedding into a JSON object. If the embedding is 2D, saves
          coordinates as separate x and y fields; otherwise, saves coordinates as
          n x d arrays.
          
          compressed: whether to format JSON objects using base64 strings
              instead of as human-readable float arrays
          
docstring: Converts this embedding into a JSON object. If the embedding is 2D, saves
  coordinates as separate x and y fields; otherwise, saves coordinates as
  n x d arrays.
  
  whether to format JSON objects using base64 strings
  instead of as human-readable float arrays
docstring_tokens: Converts this embedding into a JSON object . If the embedding is 2D saves coordinates as separate x and y fields ; otherwise saves coordinates as n x d arrays . whether to format JSON objects using base64 strings instead of as human - readable float arrays
code: def to_json(self, compressed=True, save_neighbors=True, num_neighbors=None):
          """
          Converts this embedding into a JSON object. If the embedding is 2D, saves
          coordinates as separate x and y fields; otherwise, saves coordinates as
          n x d arrays.
          
          compressed: whether to format JSON objects using base64 strings
              instead of as human-readable float arrays
          """
          result = {}
          indexes = self.index(self.ids)
          
          positions = self.field(Field.POSITION)
          colors = self.field(Field.COLOR)
          alphas = self.field(Field.ALPHA)
          sizes = self.field(Field.RADIUS)
          
          if compressed:
              result["_format"] = "compressed"
              # Specify the type name that will be used to encode the point IDs.
              # This is important because the highlight array takes up the bulk
              # of the space when transferring to file/widget.
              dtype, type_name = choose_integer_type(self.ids)
              result["_idtype"] = type_name
              result["_length"] = len(self)
              result["ids"] = encode_numerical_array(self.ids, dtype)
              
              if self.dimension() == 2:
                  result["x"] = encode_numerical_array(positions[:,0])
                  result["y"] = encode_numerical_array(positions[:,1])
              else:
                  result["position"] = encode_numerical_array(positions, interval=self.dimension())
                  
              result["color"] = encode_object_array(colors)
              if alphas is not None:
                  result["alpha"] = encode_numerical_array(alphas)
              if sizes is not None:
                  result["r"] = encode_numerical_array(sizes)
          else:
              result["points"] = {}
              for id_val, index in zip(self.ids, indexes):
                  obj = {}
                  if self.dimension() == 2:
                      obj["x"] = positions[index, 0]
                      obj["y"] = positions[index, 1]
                  else:
                      obj["position"] = positions[index].tolist()
  
                  obj["color"] = colors[index]
                  if alphas is not None:
                      obj["alpha"] = alphas[index]
                  if sizes is not None:
                      obj["r"] = sizes[index]
                  result["points"][id_val] = obj
  
          if save_neighbors and self.has_neighbors():
              result["neighbors"] = self.get_neighbors().to_json(compressed=compressed, num_neighbors=num_neighbors)
          result["metric"] = self.metric
          result["n_neighbors"] = self.n_neighbors
          return standardize_json(result)
code_tokens: def to_json ( self , compressed = True , save_neighbors = True , num_neighbors = None ) : result = { } indexes = self . index ( self . ids ) positions = self . field ( Field . POSITION ) colors = self . field ( Field . COLOR ) alphas = self . field ( Field . ALPHA ) sizes = self . field ( Field . RADIUS ) if compressed : result [ "_format" ] = "compressed" dtype , type_name = choose_integer_type ( self . ids ) result [ "_idtype" ] = type_name result [ "_length" ] = len ( self ) result [ "ids" ] = encode_numerical_array ( self . ids , dtype ) if self . dimension ( ) == 2 : result [ "x" ] = encode_numerical_array ( positions [ : , 0 ] ) result [ "y" ] = encode_numerical_array ( positions [ : , 1 ] ) else : result [ "position" ] = encode_numerical_array ( positions , interval = self . dimension ( ) ) result [ "color" ] = encode_object_array ( colors ) if alphas is not None : result [ "alpha" ] = encode_numerical_array ( alphas ) if sizes is not None : result [ "r" ] = encode_numerical_array ( sizes ) else : result [ "points" ] = { } for id_val , index in zip ( self . ids , indexes ) : obj = { } if self . dimension ( ) == 2 : obj [ "x" ] = positions [ index , 0 ] obj [ "y" ] = positions [ index , 1 ] else : obj [ "position" ] = positions [ index ] . tolist ( ) obj [ "color" ] = colors [ index ] if alphas is not None : obj [ "alpha" ] = alphas [ index ] if sizes is not None : obj [ "r" ] = sizes [ index ] result [ "points" ] [ id_val ] = obj if save_neighbors and self . has_neighbors ( ) : result [ "neighbors" ] = self . get_neighbors ( ) . to_json ( compressed = compressed , num_neighbors = num_neighbors ) result [ "metric" ] = self . metric result [ "n_neighbors" ] = self . n_neighbors return standardize_json ( result )
short_docstring: Converts this embedding into a JSON object.
short_docstring_tokens: Converts this embedding into a JSON object .
comment: """
          Converts this embedding into a JSON object. If the embedding is 2D, saves
          coordinates as separate x and y fields; otherwise, saves coordinates as
          n x d arrays.
          
          compressed: whether to format JSON objects using base64 strings
              instead of as human-readable float arrays
          """$SEP$# Specify the type name that will be used to encode the point IDs.$SEP$# This is important because the highlight array takes up the bulk$SEP$# of the space when transferring to file/widget.