code: def write_array_metadata(dataset, array):
      
      for attr in ('unit',) + array._metadata_slots:
          # format attribute
          try:
              value = _format_metadata_attribute(
                  getattr(array, '_%s' % attr, None))
          except IgnoredAttribute:
              continue
  
          # store attribute
          try:
              dataset.attrs[attr] = value
          except (TypeError, ValueError, RuntimeError) as exc:
              exc.args = ("Failed to store {} ({}) for {}: {}".format(
                  attr, type(value).__name__, type(array).__name__, str(exc)))
              raise
docs: Write metadata for ``array`` into the `h5py.Dataset`