Skip to content

Weird behavior DiffractionSimulation.intensities #174

@din14970

Description

@din14970

Describe the bug
Due to the way intensities is implemented as a property with a setter, some weird behavior can occur due to the direct beam mask.

Similar issues can be created with the coordinates attribute.

To Reproduce

from diffsims.sims.diffraction_simulation import DiffractionSimulation

coords = np.array([[0, 0], [1, 1], [2, 3]])
intensities = np.array([1, 1, 3])
sim = DiffractionSimulation(coordinates = coords, intensities = intensities, with_direct_beam=False)
sim.intensities = sim.intensities

# now throws an error because intensities is of the wrong shape
sim.intensities

Expected behavior
The setter needs to be more restrictive so that not just any array can be used, which creates inconsistencies.
I propose to check the size of the passed arrays and modify behavior depending on whether with_direct_beam is on or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions