code: def test_multi_block_set_get_ers():
      """This puts all of the example data objects into a a MultiBlock container"""
      multi = MultiBlock()
      # Set the number of blocks
      multi.n_blocks = 6
      assert (
          multi.GetNumberOfBlocks() == 6
      )  # Check that VTK side registered it
      assert multi.n_blocks == 6  # Check pyvista side registered it
      # Add data to the MultiBlock
      data = ex.load_rectilinear()
      multi[1] = data
      multi.set_block_name(1, "rect")
      # Make sure number of blocks is constant
      assert multi.n_blocks == 6
      # Check content
      assert isinstance(multi[1], RectilinearGrid)
      for i in [0, 2, 3, 4, 5]:
          assert multi[i] is None
      # Check the bounds
      assert multi.bounds == data.bounds
      multi[5] = ex.load_uniform()
      multi.set_block_name(5, "uni")
      multi.set_block_name(
          5, None
      )  # Make sure it doesn't get overwritten
      assert isinstance(multi.get(5), ImageData)
      # Test get by name
      assert isinstance(multi["uni"], ImageData)
      assert isinstance(multi["rect"], RectilinearGrid)
      assert isinstance(multi.get("uni"), ImageData)
      assert multi.get("no key") is None
      assert multi.get("no key", default=pv.Sphere()) == pv.Sphere()
      # Test the del operator
      del multi[0]
      assert multi.n_blocks == 5
      # Make sure the rect grid was moved up
      assert isinstance(multi[0], RectilinearGrid)
      assert multi.get_block_name(0) == "rect"
      assert multi.get_block_name(2) is None
      # test del by name
      del multi["uni"]
      assert multi.n_blocks == 4
      # test the pop operator
      pop = multi.pop(0)
      assert isinstance(pop, RectilinearGrid)
      assert multi.n_blocks == 3
      assert all(k is None for k in multi.keys())
  
      multi["new key"] = pv.Sphere()
      assert multi.n_blocks == 4
      assert multi[3] == pv.Sphere()
  
      multi["new key"] = pv.Cube()
      assert multi.n_blocks == 4
      assert multi[3] == pv.Cube()
  
      with pytest.raises(KeyError):
          _ = multi.get_index_by_name("foo")
  
      with pytest.raises(IndexError):
          multi[4] = ImageData()
  
      with pytest.raises(KeyError):
          multi["not a key"]
      with pytest.raises(TypeError):
          data = multi[[0, 1]]
  
      with pytest.raises(TypeError):
          multi[1, "foo"] = data
  
imports: import pathlib
  import platform
  import weakref
  import numpy
  import pytest
  import vtk
  import pyvista
  from pyvista import ImageData, MultiBlock, PolyData, RectilinearGrid, StructuredGrid, examples
label_desc: Use image node_id 7 for calling a global function with example usage: test_multi_block_set_get_ers() without return types