def minDictionaries(d1,d2):
        """
        Return the minimum of two dictionaries. Assumes they share the same keys.
        """
        assert set(d1.keys()) == set(d2.keys())
        return dict( (key, min(d1[key],d2[key]))   for key in d1)