class_docstr: Test the bucket resampler.
class_docstr_tok: ["Test","the","bucket","resampler","."]
docstr: Test bucket resamplers resample method.
code: def test_resample(self, pyresample_bucket):
      """Test bucket resamplers resample method."""
      self.bucket.resampler = mock.MagicMock()
      self.bucket.precompute = mock.MagicMock()
      self.bucket.compute = mock.MagicMock()
  
      # 1D input data
      data = xr.DataArray(
          da.ones((5,)), dims=("foo"), attrs={"bar": "baz"}
      )
      self.bucket.compute.return_value = da.ones((5, 5))
      res = self.bucket.resample(data)
      self.bucket.precompute.assert_called_once()
      self.bucket.compute.assert_called_once()
      assert res.shape == (5, 5)
      assert res.dims == ("y", "x")
      assert "bar" in res.attrs
      assert res.attrs["bar"] == "baz"
  
      # 2D input data
      data = xr.DataArray(da.ones((5, 5)), dims=("foo", "bar"))
      self.bucket.compute.return_value = da.ones((5, 5))
      res = self.bucket.resample(data)
      assert res.shape == (5, 5)
      assert res.dims == ("y", "x")
  
      # 3D input data with 'bands' dim
      data = xr.DataArray(
          da.ones((1, 5, 5)),
          dims=("bands", "foo", "bar"),
          coords={"bands": ["L"]},
      )
      self.bucket.compute.return_value = da.ones((1, 5, 5))
      res = self.bucket.resample(data)
      assert res.shape == (1, 5, 5)
      assert res.dims == ("bands", "y", "x")
      assert res.coords["bands"] == ["L"]
  
      # 3D input data with misc dim names
      data = xr.DataArray(
          da.ones((3, 5, 5)), dims=("foo", "bar", "baz")
      )
      self.bucket.compute.return_value = da.ones((3, 5, 5))
      res = self.bucket.resample(data)
      assert res.shape == (3, 5, 5)
      assert res.dims == ("foo", "bar", "baz")
  
imports: import os
  import shutil
  import tempfile
  import unittest
  from unittest import mock
  import dask.array
  import numpy
  import pytest
  import xarray
  from pyproj import CRS
  from satpy.resample import NativeResampler
label_desc: Use image node_id 7 for calling the TestBucketAvg obj's underlying member method code with example usage: obj.test_resample(pyresample_bucket) without return types