def pf_to_n(L, pf, R):
    """Returns the number of non-intersecting spheres required to achieve
    as close to a given packing fraction as possible, along with the actual
    achieved packing fraction. for a number of non-intersecting spheres.

    Parameters
    ----------
    L: float array, shape (d,)
        System lengths.
    pf: float
        Fraction of space to be occupied by the spheres.
    R: float
        Sphere radius.

    Returns
    -------
    n: integer
        Number of spheres required to achieve a packing fraction `pf_actual`
    pf_actual:
        Fraction of space occupied by `n` spheres.
        This is the closest possible fraction achievable to `pf`.
    """
    dim = L.shape[0]
    n = int(round(pf * np.product(L) / sphere_volume(R, dim)))
    pf_actual = n_to_pf(L, n, R)
    return n, pf_actual
Returns the number of non-intersecting spheres required to achieve
    as close to a given packing fraction as possible, along with the actual
    achieved packing fraction. for a number of non-intersecting spheres.

    Parameters
    ----------
    L: float array, shape (d,)
        System lengths.
    pf: float
        Fraction of space to be occupied by the spheres.
    R: float
        Sphere radius.

    Returns
    -------
    n: integer
        Number of spheres required to achieve a packing fraction `pf_actual`
    pf_actual:
        Fraction of space occupied by `n` spheres.
        This is the closest possible fraction achievable to `pf`.