code: def sweep_to_proto_dict(sweep: Sweep, repetitions: int=1) -> Dict:
      
      msg = {}  # type: Dict
      if not sweep == UnitSweep:
          sweep = _to_zip_product(sweep)
          msg['sweep'] = {
              'factors': [_sweep_zip_to_proto_dict(cast(Zip, factor)) for factor
                          in sweep.factors]
          }
      msg['repetitions'] = repetitions
      return msg
docs: Converts sweep into an equivalent protobuf representation.