human
Complete the below
def compareEvents(test, actualEvents, expectedEvents):

    ''''Compare two sequences of log events, examining only the the keys which are
    present in both.
    @param test: a test case doing the comparison
    @type test: L{unittest.TestCase}
    @param actualEvents: A list of log events that were emitted by a logger.
    @type actualEvents: L{list} of L{dict}
    @param expectedEvents: A list of log events that were expected by a test.
    @type expected: L{list} of L{dict}'
    '''

=====
Give me a Python code to compare two sequences of log events, examining only the the keys which are?
assistant
#Here is Python code to compare two sequences of log events, examining only the the keys which are
.
    if (len(actualEvents) != len(expectedEvents)):
        test.assertEqual(actualEvents, expectedEvents)
    allMergedKeys = set()
    for event in expectedEvents:
        allMergedKeys |= set(event.keys())
    def simplify(event):
        copy = event.copy()
        for key in event.keys():
            if (key not in allMergedKeys):
                copy.pop(key)
        return copy
    simplifiedActual = [simplify(event) for event in actualEvents]
    test.assertEqual(simplifiedActual, expectedEvents)