def METHOD_NAME(self, idx, ref_data, dE, dE_tol=1e-3, use_python_api="default"):
    if use_python_api == "default":
        for use_python_api in [False, True]:
            self.METHOD_NAME(idx, ref_data, dE, use_python_api=use_python_api)
        return
    self.form.ui.checkbox_use_python_api.setChecked(use_python_api)
    self.form.autosetSymmetrization()
    if idx == 0:
        widget_calc = self.form.ui.pushbutton_field1_calc
        widget_save = self.form.ui.pushbutton_field1_save
    elif idx == 2:
        widget_calc = self.form.ui.pushbutton_potential_calc
        widget_save = self.form.ui.pushbutton_potential_save
    # Run simulation
    QTest.mouseClick(widget_calc, Qt.LeftButton)
    while self.form.timer.isActive():
        self.form.checkForData()
    # Save current data
    self.form.savePlot = False
    forceFilename = os.path.join(PATH, "current")
    self.form.forceFilename = forceFilename
    QTest.mouseClick(widget_save, Qt.LeftButton)
    data = {}
    sconfig = {}
    # Load current data
    with zipfile.ZipFile(forceFilename, "r") as zip_file:
        with zip_file.open("data.mat") as f:
            f_io = io.BytesIO(f.read())
            data["current"] = loadmat(f_io)
        with zip_file.open("settings.sconf") as f:
            sconfig["current"] = json.load(f)
    os.remove(forceFilename)
    # Load reference data
    with open(os.path.join(PATH, ref_data, "data.mat"), "rb") as f:
        data["ref"] = loadmat(f)
    with open(os.path.join(PATH, ref_data, "settings.sconf")) as f:
        sconfig["ref"] = json.load(f)
    # Check if configs match # unecessary since we load the same config
    for k, v in sconfig["ref"].items():
        assert sconfig["current"][k] == v
    if len(data["current"]["eigenvalues"]) == 0:
        raise ValueError("No eigenvalues found in current data, some bug in calculating the eigenvalues.")
    # Check if central eigenvalues (+/- dE) match
    for i in range(len(data["ref"]["eigenvalues"])):
        Es = {k: np.array(mat["eigenvalues"])[i] for k, mat in data.items()}
        Es = {k: E[np.abs(E) < dE] for k, E in Es.items()}
        assert len(np.abs(Es["ref"]) == len(Es["current"]))
        diff_rel = np.abs(Es["ref"] - Es["current"])
        assert np.all(diff_rel <= dE_tol)