Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflowError on an utils function #28

Closed
zhanglw0521 opened this issue Apr 11, 2024 · 1 comment
Closed

StackOverflowError on an utils function #28

zhanglw0521 opened this issue Apr 11, 2024 · 1 comment

Comments

@zhanglw0521
Copy link
Collaborator

In utils.jl, we have the following

function specnlm2spec1p(spec_nlm)
    spec1p = union(spec_nlm...)
    lmax = [ spec1p[i].l for i = 1:length(spec1p) ] |> maximum
    nmax = [ spec1p[i].n for i = 1:length(spec1p) ] |> maximum
    return spec1p, lmax, nmax + 1
end

which extracts the corresponding Aspec from an input AAspec (I actually don't remember why we need lmax and nmax in the output but let's keep it for now).

However the union function in the first line seems to give a StackOverflowError. For instance, when we run

Zi = :C
Zs = [:H,:C,:O]

cats_ext = [(Zi,Z) for Z in Zs] |> unique

maxdeg = 6
ord = 3
radial = simple_radial_basis(legendre_basis(maxdeg))
Lmax = 0

Aspec, AAspec = degord2spec(radial; totaldegree = maxdeg, 
                                  order = ord, 
                                  Lmax = Lmax, catagories = cats_ext)

this issue arises.

It can be fixed by something like

function specnlm2spec1p(spec_nlm)
    spec1p = []
    for (i, spec_nlm_i) in enumerate(spec_nlm)
        push!(spec1p, spec_nlm_i...)
        unique!(spec1p)
    end
    lmax = [ spec1p[i].l for i = 1:length(spec1p) ] |> maximum
    nmax = [ spec1p[i].n for i = 1:length(spec1p) ] |> maximum
    return spec1p, lmax, nmax + 1
end

A PR regarding this issue will follow soon.

@zhanglw0521
Copy link
Collaborator Author

resolved by #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant