def test_change_of_basis():
    # We try to construct a two-dimensional double-well system from a
    # two-dimensional harmonic oscillator system by using the change-of-basis
    # function with C found from diagonalizing the double-well one-body
    # Hamiltonian.
    n = 2
    l = 12
    omega = 1
    mass = 1
    barrier_strength = 3
    radius = 10
    num_grid_points = 401
    axis = 0

    tdho = GeneralOrbitalSystem(
        n,
        TwoDimensionalHarmonicOscillator(
            l, radius, num_grid_points, omega=omega
        ),
    )

    h_dw = get_double_well_one_body_elements(
        l, omega, mass, barrier_strength, dtype=np.complex128, axis=axis
    )

    epsilon, C_dw = np.linalg.eigh(h_dw)
    C = BasisSet.add_spin_one_body(C_dw, np=np)

    tdho.change_basis(C)

    tddw = GeneralOrbitalSystem(
        n,
        TwoDimensionalDoubleWell(
            l,
            radius,
            num_grid_points,
            omega=omega,
            mass=mass,
            barrier_strength=barrier_strength,
            axis=axis,
        ),
    )
    tddw.change_basis(C)

    np.testing.assert_allclose(tdho.u, tddw.u, atol=1e-7)
    np.testing.assert_allclose(tdho.spf, tddw.spf, atol=1e-7)
def construct_custom_system(
    n,
    l,
    s,
    h,
    u,
    dim=3,
    particle_charge=-1,
    np=None,
    includes_spin=False,
    anti_symmetrized_u=False,
    system_type="general",
    **kwargs,
):

    if np is None:
        import numpy as np

    bs = setup_basis_set(
        n,
        l,
        s,
        h,
        u,
        dim,
        particle_charge,
        np,
        includes_spin,
        anti_symmetrized_u,
        **kwargs,
    )

    if system_type.lower() == "general":
        system = GeneralOrbitalSystem(n, bs)
    elif system_type.lower() == "spatial":
        system = SpatialOrbitalSystem(n, bs)
    else:
        raise NotImplementedError(
            f"System type: {system_type} is not supported!")

    if "C" in kwargs.keys():
        system.change_basis(kwargs["C"])

    return system