code: def set_coordinates(geometry, coordinates):
      """Adapts the coordinates of a geometry array in-place.
  
      If the coordinates array has shape (N, 2), all returned geometries
      will be two-dimensional, and the third dimension will be discarded,
      if present. If the coordinates array has shape (N, 3), the returned
      geometries preserve the dimensionality of the input geometries.
  
      .. warning::
  
          The geometry array is modified in-place! If you do not want to
          modify the original array, you can do
          ``set_coordinates(arr.copy(), newcoords)``.
  
      Parameters
      ----------
      geometry : Geometry or array_like
      coordinates: array_like
  
      See Also
      --------
      transform : Returns a copy of a geometry array with a function applied to its
          coordinates.
  
      Examples
      --------
      >>> from shapely import LineString, Point
      >>> set_coordinates(Point(0, 0), [[1, 1]])
      <POINT (1 1)>
      >>> set_coordinates([Point(0, 0), LineString([(0, 0), (0, 0)])], [[1, 2], [3, 4], [5, 6]]).tolist()
      [<POINT (1 2)>, <LINESTRING (3 4, 5 6)>]
      >>> set_coordinates([None, Point(0, 0)], [[1, 2]]).tolist()
      [None, <POINT (1 2)>]
  
      Third dimension of input geometry is discarded if coordinates array does
      not include one:
  
      >>> set_coordinates(Point(0, 0, 0), [[1, 1]])
      <POINT (1 1)>
      >>> set_coordinates(Point(0, 0, 0), [[1, 1, 1]])
      <POINT Z (1 1 1)>
      """
      geometry_arr = np.asarray(geometry, dtype=np.object_)
      coordinates = np.atleast_2d(np.asarray(coordinates)).astype(
          np.float64
      )
      if coordinates.ndim != 2:
          raise ValueError(
              "The coordinate array should have dimension of 2 "
              f"(has {coordinates.ndim})"
          )
      n_coords = lib.count_coordinates(geometry_arr)
      if (coordinates.shape[0] != n_coords) or (
          coordinates.shape[1] not in {2, 3}
      ):
          raise ValueError(
              f"The coordinate array has an invalid shape {coordinates.shape}"
          )
      lib.set_coordinates(geometry_arr, coordinates)
      if geometry_arr.ndim == 0 and not isinstance(
          geometry, np.ndarray
      ):
          return geometry_arr.item()
      return geometry_arr
  
file_path: shapely/shapely/coordinates.py
imports: from typing import Optional
  import numpy
  import shapely
  from shapely import lib
label_desc: Use image node_id 4 for calling a global function with example usage: set_coordinates(geometry, coordinates) and returns: geometry_arr, geometry_arr