diff --git a/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py b/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py index 7ff10d9ab..d6b192c7f 100644 --- a/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py +++ b/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py @@ -56,10 +56,8 @@ def array_to_3d_imagedata(data: np.ndarray, spacing: Tuple[float]): else: image.AllocateScalars(vtk.VTK_DOUBLE, 1) - for i in range(nx): - for j in range(ny): - for k in range(nz): - image.SetScalarComponentFromDouble(i, j, k, 0, data[i, j, k]) + for (i, j, k), val in np.ndenumerate(data): + image.SetScalarComponentFromDouble(i, j, k, 0, val) return image @@ -262,13 +260,11 @@ def _draw_isosurface(self, index: int, params=None): grid_step = radius / fine_sampling span = upper_limit - lower_limit - grid_steps = [int(x) for x in span / grid_step] - gdim = (grid_steps[0], grid_steps[1], grid_steps[2]) + grid_steps = list((span // grid_step).astype(int)) + gdim = tuple(grid_steps[0:3]) grid = np.zeros(gdim, dtype=np.int32) - indices = np.floor((coords - lower_limit.reshape((1, 3))) / grid_step).astype( - int - ) + indices = ((coords - lower_limit.reshape((1, 3))) // grid_step).astype(int) unique_indices, counts = np.unique(indices, return_counts=True, axis=0) grid[tuple(unique_indices.T)] += counts self._atomic_trace_histogram = smear_grid(grid, fine_sampling) diff --git a/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/TraceWidget.py b/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/TraceWidget.py index 588820541..7a9d946d5 100644 --- a/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/TraceWidget.py +++ b/MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/TraceWidget.py @@ -61,13 +61,13 @@ def validate(self, input_string: str, position: int): else: state = QValidator.State.Invalid else: - if len(rgb) > 3: + if any([x > 255 for x in rgb]): + state = QValidator.State.Invalid + elif len(rgb) > 3: state = QValidator.State.Invalid elif len(rgb) == 3: if all([(x >= 0) and (x < 256) for x in rgb]): state = QValidator.State.Acceptable - elif any([x > 255 for x in rgb]): - state = QValidator.State.Invalid else: state = QValidator.State.Intermediate return state, input_string, position