def compress_signals(signals):
 groups = group_by_all(reversed(signals), key=(lambda sig: (sig.link, sig.id)))
 signals = []
 def has_none(signals):
  return any(((sig.value is None) for sig in signals))
 for ((link, id), signals_grouped) in groups:
  if ((len(signals_grouped) > 1) and has_none(signals_grouped[1:])):
   signals.append(signals_grouped[0])
   signals.append(_Signal(link, None, id))
  else:
   signals.append(signals_grouped[0])
 return list(reversed(signals))

def compress_signals ( signals ) : groups = group_by_all ( reversed ( signals ) , key = ( lambda sig : ( sig . link , sig . id ) ) ) signals = [ ] def has_none ( signals ) : return any ( ( ( sig . value is None ) for sig in signals ) ) for ( ( link , id ) , signals_grouped ) in groups : if ( ( len ( signals_grouped ) > 1 ) and has_none ( signals_grouped [ 1 : ] ) ) : signals . append ( signals_grouped [ 0 ] ) signals . append ( _Signal ( link , None , id ) ) else : signals . append ( signals_grouped [ 0 ] ) return list ( reversed ( signals ) )
compress a list of signals .