def merge_ownership_periods(mappings):
 return valmap((lambda v: tuple((OwnershipPeriod(a.start, b.start, a.sid, a.value) for (a, b) in sliding_window(2, concatv(sorted(v), [OwnershipPeriod(pd.Timestamp.max.tz_localize('utc'), None, None, None)]))))), mappings)

def merge_ownership_periods ( mappings ) : return valmap ( ( lambda v : tuple ( ( OwnershipPeriod ( a . start , b . start , a . sid , a . value ) for ( a , b ) in sliding_window ( 2 , concatv ( sorted ( v ) , [ OwnershipPeriod ( pd . Timestamp . max . tz_localize ( 'utc' ) , None , None , None ) ] ) ) ) ) ) , mappings )
given a dict of mappings where the values are lists of ownershipperiod objects .