class ControlGroup(set):
    def __init__(self, units):
        super().__init__({unit.tag for unit in units})

    def __hash__(self):
        return hash(tuple(sorted(list(self))))

    def select_units(self, units):
        return units.filter(lambda unit: unit.tag in self)

    def missing_unit_tags(self, units):
        return {t for t in self if units.find_by_tag(t) is None}

    @property
    def empty(self):
        return self.amount == 0

class ControlGroup(set):
    def __init__(self, units):
        super().__init__({unit.tag for unit in units})

    def __hash__(self):
        return hash(tuple(sorted(list(self))))

    def select_units(self, units):
        return units.filter(lambda unit: unit.tag in self)

    def missing_unit_tags(self, units):
        return {t for t in self if units.find_by_tag(t) is None}

    @property
    def empty(self):
        return self.amount == 0

    def add_unit(self, units):
        self.add(unit.tag)

    def add_units(self, units):
        for unit in units:
            self.add_unit(unit)

    def remove_unit(self, units):
        self.remove(unit.tag)

    def remove_units(self, units):
        for unit in units:
            self.remove(unit.tag)

Add modification operations to control groups
Add modification operations to control groups

  class ControlGroup(set):
      def __init__(self, units):
          super().__init__({unit.tag for unit in units})
  
      def __hash__(self):
          return hash(tuple(sorted(list(self))))
  
      def select_units(self, units):
          return units.filter(lambda unit: unit.tag in self)
  
      def missing_unit_tags(self, units):
          return {t for t in self if units.find_by_tag(t) is None}
  
      @property
      def empty(self):
          return self.amount == 0
  
+     def add_unit(self, units):
+         self.add(unit.tag)
+ 
+     def add_units(self, units):
+         for unit in units:
+             self.add_unit(unit)
+ 
+     def remove_unit(self, units):
+         self.remove(unit.tag)
+ 
+     def remove_units(self, units):
+         for unit in units:
+             self.remove(unit.tag)
+ 
Add modification operations to control groups
## Code Before:
class ControlGroup(set):
    def __init__(self, units):
        super().__init__({unit.tag for unit in units})

    def __hash__(self):
        return hash(tuple(sorted(list(self))))

    def select_units(self, units):
        return units.filter(lambda unit: unit.tag in self)

    def missing_unit_tags(self, units):
        return {t for t in self if units.find_by_tag(t) is None}

    @property
    def empty(self):
        return self.amount == 0

## Instruction:
Add modification operations to control groups
## Code After:
class ControlGroup(set):
    def __init__(self, units):
        super().__init__({unit.tag for unit in units})

    def __hash__(self):
        return hash(tuple(sorted(list(self))))

    def select_units(self, units):
        return units.filter(lambda unit: unit.tag in self)

    def missing_unit_tags(self, units):
        return {t for t in self if units.find_by_tag(t) is None}

    @property
    def empty(self):
        return self.amount == 0

    def add_unit(self, units):
        self.add(unit.tag)

    def add_units(self, units):
        for unit in units:
            self.add_unit(unit)

    def remove_unit(self, units):
        self.remove(unit.tag)

    def remove_units(self, units):
        for unit in units:
            self.remove(unit.tag)
