class_docstr: An abstract canvas representing the space in which to bin.
  
  Parameters
  ----------
  plot_width, plot_height : int, optional
      Width and height of the output aggregate in pixels.
  x_range, y_range : tuple, optional
      A tuple representing the bounds inclusive space ``[min, max]`` along
      the axis.
  x_axis_type, y_axis_type : str, optional
      The type of the axis. Valid options are ``'linear'`` [default], and
      ``'log'``.
class_docstr_tok: ["An","abstract","canvas","representing","the","space","in","which","to","bin",".","Parameters","--","--","--","--","--","plot_width",",","plot_height",":","int",",","optional","Width","and","height","of","the","output","aggregate","in","pixels",".","x_range",",","y_range",":","tuple",",","optional","A","tuple","representing","the","bounds","inclusive","space","``","[","min",",","max","]","``","along","the","axis",".","x_axis_type",",","y_axis_type",":","str",",","optional","The","type","of","the","axis",".","Valid","options","are","``","'linear","'","``","[","default","]",",","and","``","'log","'","``","."]
docstr: Samples a recti- or curvi-linear quadmesh by canvas size and bounds.
  
  Parameters
  ----------
  source : xarray.DataArray or Dataset
      The input datasource.
  x, y : str
      Column names for the x and y coordinates of each point.
  agg : Reduction, optional
      Reduction to compute. Default is ``mean()``. Note that agg is ignored when
      upsampling.
  
  Returns
  -------
  data : xarray.DataArray
docstr_tok: ["Samples","a","recti-","or","curvi-linear","quadmesh","by","canvas","size","and","bounds",".","Parameters","--","--","--","--","--","source",":","xarray.DataArray","or","Dataset","The","input","datasource",".","x",",","y",":","str","Column","names","for","the","x","and","y","coordinates","of","each","point",".","agg",":","Reduction",",","optional","Reduction","to","compute",".","Default","is","``","mean","(",")","``",".","Note","that","agg","is","ignored","when","upsampling",".","Returns","--","--","--","-","data",":","xarray.DataArray"]
code: def quadmesh(self, source, x=None, y=None, agg=None):
      """Samples a recti- or curvi-linear quadmesh by canvas size and bounds.
  
      Parameters
      ----------
      source : xarray.DataArray or Dataset
          The input datasource.
      x, y : str
          Column names for the x and y coordinates of each point.
      agg : Reduction, optional
          Reduction to compute. Default is ``mean()``. Note that agg is ignored when
          upsampling.
  
      Returns
      -------
      data : xarray.DataArray
      """
      from .glyphs import (
          QuadMeshRaster,
          QuadMeshRectilinear,
          QuadMeshCurvilinear,
      )
  
      # Determine reduction operation
      from .reductions import mean as mean_rnd
  
      if isinstance(source, Dataset):
          if agg is None or agg.column is None:
              name = list(source.data_vars)[0]
          else:
              name = agg.column
          # Keep as dataset so that source[agg.column] works
          source = source[[name]]
      elif isinstance(source, DataArray):
          # Make dataset so that source[agg.column] works
          name = source.name
          source = source.to_dataset()
      else:
          raise ValueError("Invalid input type")
  
      if agg is None:
          agg = mean_rnd(name)
  
      if x is None and y is None:
          y, x = source[name].dims
      elif not x or not y:
          raise ValueError(
              "Either specify both x and y coordinates"
              "or allow them to be inferred."
          )
      yarr, xarr = source[y], source[x]
  
      if (yarr.ndim > 1 or xarr.ndim > 1) and xarr.dims != yarr.dims:
          raise ValueError(
              "Ensure that x- and y-coordinate arrays "
              "share the same dimensions. x-coordinates "
              "are indexed by %s dims while "
              "y-coordinates are indexed by %s dims."
              % (xarr.dims, yarr.dims)
          )
  
      if (
          name is not None
          and agg.column is not None
          and agg.column != name
      ):
          raise ValueError(
              "DataArray name %r does not match "
              "supplied reduction %s." % (source.name, agg)
          )
  
      if xarr.ndim == 1:
          xaxis_linear = self.x_axis is _axis_lookup["linear"]
          yaxis_linear = self.y_axis is _axis_lookup["linear"]
          even_yspacing = np.allclose(
              yarr, np.linspace(yarr[0], yarr[-1], len(yarr))
          )
          even_xspacing = np.allclose(
              xarr, np.linspace(xarr[0], xarr[-1], len(xarr))
          )
  
          if (
              xaxis_linear
              and yaxis_linear
              and even_xspacing
              and even_yspacing
          ):
              # Source is a raster, where all x and y coordinates are evenly spaced
              glyph = QuadMeshRaster(x, y, name)
              upsample_width, upsample_height = glyph.is_upsample(
                  source,
                  x,
                  y,
                  name,
                  self.x_range,
                  self.y_range,
                  self.plot_width,
                  self.plot_height,
              )
              if upsample_width and upsample_height:
                  # Override aggregate with more efficient one for upsampling
                  agg = rd._upsample(name)
                  return bypixel(source, self, glyph, agg)
              elif not upsample_width and not upsample_height:
                  # Downsample both width and height
                  return bypixel(source, self, glyph, agg)
              else:
                  # Mix of upsampling and downsampling
                  # Use general rectilinear quadmesh implementation
                  glyph = QuadMeshRectilinear(x, y, name)
                  return bypixel(source, self, glyph, agg)
          else:
              # Source is a general rectilinear quadmesh
              glyph = QuadMeshRectilinear(x, y, name)
              return bypixel(source, self, glyph, agg)
      elif xarr.ndim == 2:
          glyph = QuadMeshCurvilinear(x, y, name)
          return bypixel(source, self, glyph, agg)
      else:
          raise ValueError(
              """\
  x- and y-coordinate arrays must have 1 or 2 dimensions.
      Received arrays with dimensions: {dims}""".format(
                  dims=list(xarr.dims)
              )
          )
  
imports: from __future__ import annotations
  from numbers import Number
  from math import log10
  import warnings
  import numpy
  import pandas
  import dask.dataframe
  import dask.array
  from xarray import DataArray, Dataset
  from .utils import Dispatcher, ngjit, calc_res, calc_bbox, orient_array, dshape_from_xarray_dataset
  from .utils import get_indices, dshape_from_pandas, dshape_from_dask
  from .utils import Expr
  from .resampling import resample_2d, resample_2d_distributed
  from .None import reductions
label_desc: Use image node_id 6 for calling the Canvas obj's underlying member method code with example usage: obj.quadmesh(source, x, y, agg) and returns: bypixel, bypixel, bypixel, bypixel, bypixel