amuse icon indicating copy to clipboard operation
amuse copied to clipboard

Grid channels can't be initialized with attributes

Open MJCWilhelm opened this issue 5 years ago • 4 comments

Is your feature request related to a problem? Please describe. A particle channel can be initialized with a list of attributes to copy on a call of .copy(), but a grid channel can't. This gives errors if channels to a combined set of grids and particles are initialized with pre-specified attributes.

Describe the solution you'd like Grid channels can be initialized with attribute and target names of variables to copy with .copy(), as is the case for particle channels.

copy_attribute does exist for grids, but for my application it's more convenient to have a pre-defined copy call instead of looping over all attributes every time.

MJCWilhelm avatar Feb 09 '21 11:02 MJCWilhelm

How about using .copy_attributes(["list", "of", "attribute", "names"]) as a workaround?

rieder avatar Feb 09 '21 11:02 rieder

Yep that's a workaround, but not as convenient, and it's weird that these two very similar functionalities have such a difference.

The code around this is not as daunting as I thought on first sight, so I can implement and push this myself. Sorry for making this issue, I was too quick in thinking it was more complicated than it is.

MJCWilhelm avatar Feb 09 '21 14:02 MJCWilhelm

Don't worry about creating a new issue if you later find you can fix it yourself. That's perfectly fine, you can just assign it to yourself in that case :).

rieder avatar Feb 09 '21 14:02 rieder

I made a pull request for the addition! I also added the reverse function for grids. See #730

MJCWilhelm avatar Feb 11 '21 11:02 MJCWilhelm