code: def test_extend(self):
      sdict = PerArrayDict(
          len(DATA["tractogram"]), DATA["data_per_streamline"]
      )
  
      new_data = {
          "mean_curvature": 2 * np.array(DATA["mean_curvature"]),
          "mean_torsion": 3 * np.array(DATA["mean_torsion"]),
          "mean_colors": 4 * np.array(DATA["mean_colors"]),
      }
      sdict2 = PerArrayDict(len(DATA["tractogram"]), new_data)
  
      sdict.extend(sdict2)
      assert len(sdict) == len(sdict2)
      for k in DATA["tractogram"].data_per_streamline:
          assert_arrays_equal(
              sdict[k][: len(DATA["tractogram"])],
              DATA["tractogram"].data_per_streamline[k],
          )
          assert_arrays_equal(
              sdict[k][len(DATA["tractogram"]) :], new_data[k]
          )
  
      # Extending with an empty PerArrayDict should change nothing.
      sdict_orig = copy.deepcopy(sdict)
      sdict.extend(PerArrayDict())
      for k in sdict_orig.keys():
          assert_arrays_equal(sdict[k], sdict_orig[k])
  
      # Test incompatible PerArrayDicts.
      # Other dict has more entries.
      new_data = {
          "mean_curvature": 2 * np.array(DATA["mean_curvature"]),
          "mean_torsion": 3 * np.array(DATA["mean_torsion"]),
          "mean_colors": 4 * np.array(DATA["mean_colors"]),
          "other": 5 * np.array(DATA["mean_colors"]),
      }
      sdict2 = PerArrayDict(len(DATA["tractogram"]), new_data)
  
      with pytest.raises(ValueError):
          sdict.extend(sdict2)
      # Other dict has not the same entries (key mistmached).
      new_data = {
          "mean_curvature": 2 * np.array(DATA["mean_curvature"]),
          "mean_torsion": 3 * np.array(DATA["mean_torsion"]),
          "other": 4 * np.array(DATA["mean_colors"]),
      }
      sdict2 = PerArrayDict(len(DATA["tractogram"]), new_data)
      with pytest.raises(ValueError):
          sdict.extend(sdict2)
  
      # Other dict has the right number of entries but wrong shape.
      new_data = {
          "mean_curvature": 2 * np.array(DATA["mean_curvature"]),
          "mean_torsion": 3 * np.array(DATA["mean_torsion"]),
          "mean_colors": 4 * np.array(DATA["mean_torsion"]),
      }
      sdict2 = PerArrayDict(len(DATA["tractogram"]), new_data)
      with pytest.raises(ValueError):
          sdict.extend(sdict2)
  
imports: import copy
  import operator
  import sys
  import unittest
  import warnings
  from collections import defaultdict
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ...testing import assert_arrays_equal, clear_and_catch_warnings
  from ..None import tractogram
  from ..tractogram import LazyDict, LazyTractogram, PerArrayDict, PerArraySequenceDict, Tractogram, TractogramItem, is_data_dict, is_lazy_dict
label_desc: Use image node_id 3 for calling the TestPerArrayDict obj's underlying member method code with example usage: obj.test_extend() without return types