Skip to content

basis_from_basis not working with compound bases #13

Description

@theolewy

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!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions