code: def test_write_scalars_and_properties_name_too_long(self):
      # TRK supports data_per_point name up to 20 characters.
      # However, we reserve the last two characters to store
      # the number of values associated to each data_per_point.
      # So in reality we allow name of 18 characters, otherwise
      # the name is truncated and warning is issue.
      for nb_chars in range(22):
          data_per_point = {"A" * nb_chars: DATA["colors"]}
          tractogram = Tractogram(
              DATA["streamlines"],
              data_per_point=data_per_point,
              affine_to_rasmm=np.eye(4),
          )
  
          trk = TrkFile(tractogram)
          if nb_chars > 18:
              with pytest.raises(ValueError):
                  trk.save(BytesIO())
          else:
              trk.save(BytesIO())
  
          data_per_point = {"A" * nb_chars: DATA["fa"]}
          tractogram = Tractogram(
              DATA["streamlines"],
              data_per_point=data_per_point,
              affine_to_rasmm=np.eye(4),
          )
  
          trk = TrkFile(tractogram)
          if nb_chars > 20:
              with pytest.raises(ValueError):
                  trk.save(BytesIO())
          else:
              trk.save(BytesIO())
  
      # TRK supports data_per_streamline name up to 20 characters.
      # However, we reserve the last two characters to store
      # the number of values associated to each data_per_streamline.
      # So in reality we allow name of 18 characters, otherwise
      # the name is truncated and warning is issue.
      for nb_chars in range(22):
          data_per_streamline = {"A" * nb_chars: DATA["mean_colors"]}
          tractogram = Tractogram(
              DATA["streamlines"],
              data_per_streamline=data_per_streamline,
              affine_to_rasmm=np.eye(4),
          )
  
          trk = TrkFile(tractogram)
          if nb_chars > 18:
              with pytest.raises(ValueError):
                  trk.save(BytesIO())
          else:
              trk.save(BytesIO())
  
          data_per_streamline = {"A" * nb_chars: DATA["mean_torsion"]}
          tractogram = Tractogram(
              DATA["streamlines"],
              data_per_streamline=data_per_streamline,
              affine_to_rasmm=np.eye(4),
          )
  
          trk = TrkFile(tractogram)
          if nb_chars > 20:
              with pytest.raises(ValueError):
                  trk.save(BytesIO())
          else:
              trk.save(BytesIO())
  
imports: import copy
  import os
  import sys
  import unittest
  from io import BytesIO
  from os.path import join
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ...testing import assert_arr_dict_equal, clear_and_catch_warnings, data_path, error_warnings
  from ..None import trk
  from ..header import Field
  from ..tractogram import Tractogram
  from ..tractogram_file import HeaderError, HeaderWarning
  from ..trk import TrkFile, decode_value_from_name, encode_value_in_name, get_affine_trackvis_to_rasmm
  from .test_tractogram import assert_tractogram_equal
label_desc: Use image node_id 16 for calling the TestTRK obj's underlying member method code with example usage: obj.test_write_scalars_and_properties_name_too_long() without return types