<commit_before>import numpy as np
from itertools import product
from functools import reduce

def mp2(ints, orbs, orbe, nocc, nvirt, verbose=False):
    moints = ints.transform_mp2(orbs, nocc)
    Emp2 = 0
    for a,b in product(range(nocc), repeat=2):
        Eab = 0
        for r,s in product(range(nvirt), repeat=2):
            arbs, asbr = moints[a,r,b,s], moints[a,s,b,r]
            Eab += arbs*(2*arbs-asbr)/(orbe[a]+orbe[b]-orbe[nocc+r]-orbe[nocc+s])
        if verbose: print("MP2 pair energy for %d,%d: %f" % (a, b, Eab))
        Emp2 += Eab
    if verbose: print("MP2 energy: %f" % Eab)
    return Emp2

if __name__ == '__main__': test_mp2()<commit_msg>refactoring<commit_after>import numpy as np
from itertools import product
from functools import reduce

def mp2(hamiltonian, orbs, orbe, nocc, nvirt, verbose=False):
    ints = hamiltonian.i2
    moints = ints.transform_mp2(orbs, nocc)
    Emp2 = 0
    for a,b in product(range(nocc), repeat=2):
        Eab = 0
        for r,s in product(range(nvirt), repeat=2):
            arbs, asbr = moints[a,r,b,s], moints[a,s,b,r]
            Eab += arbs*(2*arbs-asbr)/(orbe[a]+orbe[b]-orbe[nocc+r]-orbe[nocc+s])
        if verbose: print("MP2 pair energy for %d,%d: %f" % (a, b, Eab))
        Emp2 += Eab
    if verbose: print("MP2 energy: %f" % Eab)
    return Emp2

if __name__ == '__main__': test_mp2()
{'fraction_non_alphanumeric': 0.15260454878943508, 'fraction_numerical': 0.019809244314013204, 'mean_word_length': 3.1969230769230768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5353315', 'n_tokens_mistral': 570, 'n_tokens_neox': 550, 'n_words': 135}