nodes: 0, module; 1, function_definition; 2, function_name:multinterp; 3, parameters; 4, block; 5, identifier:x; 6, identifier:y; 7, identifier:xquery; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, assert_statement; 12, assert_statement; 13, assert_statement; 14, comment:# make sure xmin < xquery < xmax in all cases; 15, expression_statement; 16, if_statement; 17, identifier:slow; 18, False; 19, comment:"""Multiple linear interpolations
  
      Parameters
      ----------
      x : array_like, shape=(N,)
          sorted array of x values
      y : array_like, shape=(N, M)
          array of y values corresponding to each x value
      xquery : array_like, shape=(M,)
          array of query values
      slow : boolean, default=False
          if True, use slow method (used mainly for unit testing)
  
      Returns
      -------
      yquery : ndarray, shape=(M,)
          The interpolated values corresponding to each x query.
      """; 20, assignment; 21, comparison_operator:x.ndim == 1; 22, comparison_operator:xquery.ndim == 1; 23, comparison_operator:y.shape == x.shape + xquery.shape; 24, assignment; 25, identifier:slow; 26, block; 27, elif_clause; 28, else_clause; 29, pattern_list; 30, call; 31, attribute; 32, integer:1; 33, attribute; 34, integer:1; 35, attribute; 36, binary_operator:x.shape + xquery.shape; 37, identifier:xquery; 38, call; 39, import_from_statement; 40, return_statement; 41, comparison_operator:len(x) == 3; 42, comment:# Most common case: use a faster approach; 43, block; 44, block; 45, identifier:x; 46, identifier:y; 47, identifier:xquery; 48, identifier:map; 49, argument_list; 50, identifier:x; 51, identifier:ndim; 52, identifier:xquery; 53, identifier:ndim; 54, identifier:y; 55, identifier:shape; 56, attribute; 57, attribute; 58, attribute; 59, argument_list; 60, dotted_name; 61, dotted_name; 62, call; 63, call; 64, integer:3; 65, expression_statement; 66, expression_statement; 67, return_statement; 68, expression_statement; 69, expression_statement; 70, return_statement; 71, attribute; 72, tuple; 73, identifier:x; 74, identifier:shape; 75, identifier:xquery; 76, identifier:shape; 77, identifier:np; 78, identifier:clip; 79, identifier:xquery; 80, call; 81, call; 82, identifier:scipy; 83, identifier:interpolate; 84, identifier:interp1d; 85, attribute; 86, argument_list; 87, identifier:len; 88, argument_list; 89, assignment; 90, assignment; 91, call; 92, assignment; 93, assignment; 94, binary_operator:y[i, j] + ((xquery - x[i]) *
                            (y[i + 1, j] - y[i, j]) / (x[i + 1] - x[i])); 95, identifier:np; 96, identifier:asarray; 97, identifier:x; 98, identifier:y; 99, identifier:xquery; 100, attribute; 101, argument_list; 102, attribute; 103, argument_list; 104, identifier:np; 105, identifier:array; 106, list_comprehension; 107, identifier:x; 108, identifier:yq_lower; 109, binary_operator:y[0] + (xquery - x[0]) * (y[1] - y[0]) / (x[1] - x[0]); 110, identifier:yq_upper; 111, binary_operator:y[1] + (xquery - x[1]) * (y[2] - y[1]) / (x[2] - x[1]); 112, attribute; 113, argument_list; 114, identifier:i; 115, call; 116, identifier:j; 117, call; 118, subscript; 119, parenthesized_expression; 120, identifier:x; 121, identifier:min; 122, identifier:x; 123, identifier:max; 124, call; 125, for_in_clause; 126, subscript; 127, binary_operator:(xquery - x[0]) * (y[1] - y[0]) / (x[1] - x[0]); 128, subscript; 129, binary_operator:(xquery - x[1]) * (y[2] - y[1]) / (x[2] - x[1]); 130, identifier:np; 131, identifier:where; 132, comparison_operator:xquery < x[1]; 133, identifier:yq_lower; 134, identifier:yq_upper; 135, attribute; 136, argument_list; 137, attribute; 138, argument_list; 139, identifier:y; 140, identifier:i; 141, identifier:j; 142, binary_operator:(xquery - x[i]) *
                            (y[i + 1, j] - y[i, j]) / (x[i + 1] - x[i]); 143, call; 144, argument_list; 145, pattern_list; 146, call; 147, identifier:y; 148, integer:0; 149, binary_operator:(xquery - x[0]) * (y[1] - y[0]); 150, parenthesized_expression; 151, identifier:y; 152, integer:1; 153, binary_operator:(xquery - x[1]) * (y[2] - y[1]); 154, parenthesized_expression; 155, identifier:xquery; 156, subscript; 157, identifier:np; 158, identifier:clip; 159, binary_operator:np.searchsorted(x, xquery, side='right') - 1; 160, integer:0; 161, binary_operator:len(x) - 2; 162, identifier:np; 163, identifier:arange; 164, call; 165, binary_operator:(xquery - x[i]) *
                            (y[i + 1, j] - y[i, j]); 166, parenthesized_expression; 167, identifier:interp1d; 168, argument_list; 169, identifier:xq; 170, identifier:xq; 171, identifier:y; 172, identifier:zip; 173, argument_list; 174, parenthesized_expression; 175, parenthesized_expression; 176, binary_operator:x[1] - x[0]; 177, parenthesized_expression; 178, parenthesized_expression; 179, binary_operator:x[2] - x[1]; 180, identifier:x; 181, integer:1; 182, call; 183, integer:1; 184, call; 185, integer:2; 186, identifier:len; 187, argument_list; 188, parenthesized_expression; 189, parenthesized_expression; 190, binary_operator:x[i + 1] - x[i]; 191, identifier:x; 192, identifier:y; 193, identifier:xquery; 194, attribute; 195, binary_operator:xquery - x[0]; 196, binary_operator:y[1] - y[0]; 197, subscript; 198, subscript; 199, binary_operator:xquery - x[1]; 200, binary_operator:y[2] - y[1]; 201, subscript; 202, subscript; 203, attribute; 204, argument_list; 205, identifier:len; 206, argument_list; 207, identifier:xquery; 208, binary_operator:xquery - x[i]; 209, binary_operator:y[i + 1, j] - y[i, j]; 210, subscript; 211, subscript; 212, identifier:y; 213, identifier:T; 214, identifier:xquery; 215, subscript; 216, subscript; 217, subscript; 218, identifier:x; 219, integer:1; 220, identifier:x; 221, integer:0; 222, identifier:xquery; 223, subscript; 224, subscript; 225, subscript; 226, identifier:x; 227, integer:2; 228, identifier:x; 229, integer:1; 230, identifier:np; 231, identifier:searchsorted; 232, identifier:x; 233, identifier:xquery; 234, keyword_argument; 235, identifier:x; 236, identifier:xquery; 237, subscript; 238, subscript; 239, subscript; 240, identifier:x; 241, binary_operator:i + 1; 242, identifier:x; 243, identifier:i; 244, identifier:x; 245, integer:0; 246, identifier:y; 247, integer:1; 248, identifier:y; 249, integer:0; 250, identifier:x; 251, integer:1; 252, identifier:y; 253, integer:2; 254, identifier:y; 255, integer:1; 256, identifier:side; 257, string; 258, identifier:x; 259, identifier:i; 260, identifier:y; 261, binary_operator:i + 1; 262, identifier:j; 263, identifier:y; 264, identifier:i; 265, identifier:j; 266, identifier:i; 267, integer:1; 268, string_content:right; 269, identifier:i; 270, integer:1
code: def multinterp(x, y, xquery, slow=False):
      """Multiple linear interpolations
  
      Parameters
      ----------
      x : array_like, shape=(N,)
          sorted array of x values
      y : array_like, shape=(N, M)
          array of y values corresponding to each x value
      xquery : array_like, shape=(M,)
          array of query values
      slow : boolean, default=False
          if True, use slow method (used mainly for unit testing)
  
      Returns
      -------
      yquery : ndarray, shape=(M,)
          The interpolated values corresponding to each x query.
      """
      x, y, xquery = map(np.asarray, (x, y, xquery))
      assert x.ndim == 1
      assert xquery.ndim == 1
      assert y.shape == x.shape + xquery.shape
  
      # make sure xmin < xquery < xmax in all cases
      xquery = np.clip(xquery, x.min(), x.max())
  
      if slow:
          from scipy.interpolate import interp1d
          return np.array([interp1d(x, y)(xq) for xq, y in zip(xquery, y.T)])
      elif len(x) == 3:
          # Most common case: use a faster approach
          yq_lower = y[0] + (xquery - x[0]) * (y[1] - y[0]) / (x[1] - x[0])
          yq_upper = y[1] + (xquery - x[1]) * (y[2] - y[1]) / (x[2] - x[1])
          return np.where(xquery < x[1], yq_lower, yq_upper)
      else:
          i = np.clip(np.searchsorted(x, xquery, side='right') - 1,
                      0, len(x) - 2)
          j = np.arange(len(xquery))
          return y[i, j] + ((xquery - x[i]) *
                            (y[i + 1, j] - y[i, j]) / (x[i + 1] - x[i]))