class_docstr: Test cases for CF spatial dimension and coordinates.
class_docstr_tok: ["Test","cases","for","CF","spatial","dimension","and","coordinates","."]
docstr: Test that created coordinate variables are unique.
docstr_tok: ["Test","that","created","coordinate","variables","are","unique","."]
code: def test_ensure_unique_nondimensional_coords(self):
      """Test that created coordinate variables are unique."""
      from satpy.cf.coords import ensure_unique_nondimensional_coords
  
      data = [[1, 2], [3, 4]]
      y = [1, 2]
      x = [1, 2]
      time1 = [1, 2]
      time2 = [3, 4]
      datasets = {
          "var1": xr.DataArray(
              data=data,
              dims=("y", "x"),
              coords={"y": y, "x": x, "acq_time": ("y", time1)},
          ),
          "var2": xr.DataArray(
              data=data,
              dims=("y", "x"),
              coords={"y": y, "x": x, "acq_time": ("y", time2)},
          ),
      }
  
      # Test that dataset names are prepended to alternative coordinates
      res = ensure_unique_nondimensional_coords(datasets)
      np.testing.assert_array_equal(res["var1"]["var1_acq_time"], time1)
      np.testing.assert_array_equal(res["var2"]["var2_acq_time"], time2)
      assert "acq_time" not in res["var1"].coords
      assert "acq_time" not in res["var2"].coords
  
      # Make sure nothing else is modified
      np.testing.assert_array_equal(res["var1"]["x"], x)
      np.testing.assert_array_equal(res["var1"]["y"], y)
      np.testing.assert_array_equal(res["var2"]["x"], x)
      np.testing.assert_array_equal(res["var2"]["y"], y)
  
      # Coords not unique -> Dataset names must be prepended, even if pretty=True
      with pytest.warns(
          UserWarning, match='Cannot pretty-format "acq_time"'
      ):
          res = ensure_unique_nondimensional_coords(
              datasets, pretty=True
          )
      np.testing.assert_array_equal(res["var1"]["var1_acq_time"], time1)
      np.testing.assert_array_equal(res["var2"]["var2_acq_time"], time2)
      assert "acq_time" not in res["var1"].coords
      assert "acq_time" not in res["var2"].coords
  
      # Coords unique and pretty=True -> Don't modify coordinate names
      datasets["var2"]["acq_time"] = ("y", time1)
      res = ensure_unique_nondimensional_coords(datasets, pretty=True)
      np.testing.assert_array_equal(res["var1"]["acq_time"], time1)
      np.testing.assert_array_equal(res["var2"]["acq_time"], time1)
      assert "var1_acq_time" not in res["var1"].coords
      assert "var2_acq_time" not in res["var2"].coords
  
file_path: satpy/satpy/tests/cf_tests/test_coords.py
imports: import logging
  import numpy
  import pytest
  import xarray
  from pyresample import AreaDefinition
label_desc: Use image node_id 3 for calling the TestCFcoords obj's underlying member method code with example usage: obj.test_ensure_unique_nondimensional_coords() without return types