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

basis_from_basis not working with compound bases #13

Open
theolewy opened this issue Dec 14, 2022 · 0 comments
Open

basis_from_basis not working with compound bases #13

theolewy opened this issue Dec 14, 2022 · 0 comments

Comments

@theolewy
Copy link

When a compound basis x (formed from d domains) is inputted the outputted basis is not of size factor*(x.base_grid_size), but rather d * factor * (x.base_grid_size).

I think this is resolved when n_hi is moved into the for loop like this:

def basis_from_basis(basis, factor):
"""duplicates input basis with number of modes multiplied by input factor.

the new number of modes will be cast to an integer

inputs
------
basis : a dedalus basis
factor : a float that will multiply the grid size by basis

"""
basis_type = basis.__class__.__name__

if type(basis) == de.Compound:
    sub_bases = []
    for sub_basis in basis.subbases:
        sub_basis_type = sub_basis.__class__.__name__
        try:
            n_hi = int(sub_basis.base_grid_size * factor)
            nb = bases_register[sub_basis_type](basis.name, n_hi, interval=sub_basis.interval)
        except KeyError:
            raise KeyError("Don't know how to make a basis of type {}".format(basis_type))
        sub_bases.append(nb)
    new_basis = de.Compound(basis.name, tuple(sub_bases))
else:
    try:
        n_hi = int(basis.base_grid_size * factor)
        new_basis = bases_register[basis_type](basis.name, n_hi, interval=basis.interval)
    except KeyError:
        raise KeyError("Don't know how to make a basis of type {}".format(basis_type))

return new_basis

Sorry if I've got this wrong, but this seems to fix the problem for my code!!

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