Skip to content

Clearer error message when PlatonicSpheresCollection is initialized with bad positions. #5

@briandleahy

Description

@briandleahy

Currently, it's possible to create a state with particles well outside the padded region, without any error being thrown. However as soon as an update on the particles is attempted, an UpdateError gets raised because the particles are outside the box. This is confusing to the user.

I think a MWE would be (not by a computer with PERI)

from peri.comp import objs
from peri import states, util, models

pos = np.array([10,10,1000]).reshape(-1,3)
obj = objs.PlatonicSpheresCollection(pos, 5.0)
st = states.ImageState(util.NullImage(shape=(30,30,30)), [obj], models.ParticlesOnlyModel())

# no problem

st.update('sph-0-x', st.get_values('sph-0-x') - 1e-3)  # problem

I think the best solution is to check for bad particles the first time that PlatonicSpheresCollection has set_shape called, and raise an error then if there are bad positions / positions outside the padded image shape. Thoughts?

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