class_docstr: Tests ensuring that when a dataset or samples in a dataset are modified
  all relevant objects are instantly in sync within the same process.
class_docstr_tok: ["Tests","ensuring","that","when","a","dataset","or","samples","in","a","dataset","are","modified","all","relevant","objects","are","instantly","in","sync","within","the","same","process","."]
docstr: Tests that when fields are added or removed from a dataset field
  schema, those changes are reflected on the samples in the dataset.
docstr_tok: ["Tests","that","when","fields","are","added","or","removed","from","a","dataset","field","schema",",","those","changes","are","reflected","on","the","samples","in","the","dataset","."]
code: def test_dataset_add_delete_field(self):
      """Tests that when fields are added or removed from a dataset field
      schema, those changes are reflected on the samples in the dataset.
      """
      dataset = fo.Dataset()
  
      sample = fo.Sample(filepath="test1.png")
      dataset.add_sample(sample)
  
      field_name = "field1"
      ftype = fo.IntField
  
      # Field not in schema
      with self.assertRaises(AttributeError):
          sample.get_field(field_name)
      with self.assertRaises(KeyError):
          sample[field_name]
      with self.assertRaises(AttributeError):
          getattr(sample, field_name)
  
      # Field added to dataset
      dataset.add_sample_field(field_name, ftype)
      self.assertIsNone(sample.get_field(field_name))
      self.assertIsNone(sample[field_name])
      self.assertIsNone(getattr(sample, field_name))
  
      # Field removed from dataset
      dataset.delete_sample_field(field_name)
      with self.assertRaises(AttributeError):
          sample.get_field(field_name)
      with self.assertRaises(KeyError):
          sample[field_name]
      with self.assertRaises(AttributeError):
          getattr(sample, field_name)
  
      # Field added to dataset and sample value set
      value = 51
      dataset.add_sample_field(field_name, ftype)
      sample[field_name] = value
      self.assertEqual(sample.get_field(field_name), value)
      self.assertEqual(sample[field_name], value)
      self.assertEqual(getattr(sample, field_name), value)
  
      # Field removed from dataset
      dataset.delete_sample_field(field_name)
      with self.assertRaises(AttributeError):
          sample.get_field(field_name)
      with self.assertRaises(KeyError):
          sample[field_name]
      with self.assertRaises(AttributeError):
          getattr(sample, field_name)
  
file_path: fiftyone/tests/unittests/synchronization_tests.py
imports: import os
  import unittest
  import fiftyone
  from decorators import drop_datasets
label_desc: Use image node_id 3 for calling the SingleProcessSynchronizationTests obj's underlying member method code with example usage: obj.test_dataset_add_delete_field() without return types