code: def test_extend(self):
      total_nb_rows = DATA["tractogram"].streamlines.total_nb_rows
      sdict = PerArraySequenceDict(
          total_nb_rows, DATA["data_per_point"]
      )
  
      # Test compatible PerArraySequenceDicts.
      list_nb_points = [2, 7, 4]
      data_per_point_shapes = {
          "colors": DATA["colors"][0].shape[1:],
          "fa": DATA["fa"][0].shape[1:],
      }
      _, new_data, _ = make_fake_tractogram(
          list_nb_points, data_per_point_shapes, rng=DATA["rng"]
      )
      sdict2 = PerArraySequenceDict(np.sum(list_nb_points), new_data)
  
      sdict.extend(sdict2)
      assert len(sdict) == len(sdict2)
      for k in DATA["tractogram"].data_per_point:
          assert_arrays_equal(
              sdict[k][: len(DATA["tractogram"])],
              DATA["tractogram"].data_per_point[k],
          )
          assert_arrays_equal(
              sdict[k][len(DATA["tractogram"]) :], new_data[k]
          )
  
      # Extending with an empty PerArraySequenceDicts should change nothing.
      sdict_orig = copy.deepcopy(sdict)
      sdict.extend(PerArraySequenceDict())
      for k in sdict_orig.keys():
          assert_arrays_equal(sdict[k], sdict_orig[k])
  
      # Test incompatible PerArraySequenceDicts.
      # Other dict has more entries.
      data_per_point_shapes = {
          "colors": DATA["colors"][0].shape[1:],
          "fa": DATA["fa"][0].shape[1:],
          "other": (7,),
      }
      _, new_data, _ = make_fake_tractogram(
          list_nb_points, data_per_point_shapes, rng=DATA["rng"]
      )
      sdict2 = PerArraySequenceDict(np.sum(list_nb_points), new_data)
      with pytest.raises(ValueError):
          sdict.extend(sdict2)
  
      # Other dict has not the same entries (key mistmached).
      data_per_point_shapes = {
          "colors": DATA["colors"][0].shape[1:],
          "other": DATA["fa"][0].shape[1:],
      }
      _, new_data, _ = make_fake_tractogram(
          list_nb_points, data_per_point_shapes, rng=DATA["rng"]
      )
      sdict2 = PerArraySequenceDict(np.sum(list_nb_points), new_data)
      with pytest.raises(ValueError):
          sdict.extend(sdict2)
  
      # Other dict has the right number of entries but wrong shape.
      data_per_point_shapes = {
          "colors": DATA["colors"][0].shape[1:],
          "fa": DATA["fa"][0].shape[1:] + (3,),
      }
      _, new_data, _ = make_fake_tractogram(
          list_nb_points, data_per_point_shapes, rng=DATA["rng"]
      )
      sdict2 = PerArraySequenceDict(np.sum(list_nb_points), 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 TestPerArraySequenceDict obj's underlying member method code with example usage: obj.test_extend() without return types