Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualizing mean_curvature on lebedev quadrature throws error #232

Open
jo-mueller opened this issue Jan 26, 2023 · 1 comment
Open

Visualizing mean_curvature on lebedev quadrature throws error #232

jo-mueller opened this issue Jan 26, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@jo-mueller
Copy link
Member

When using the pointcloud feature histogram visualization, napari throws an error (mean curvatures are calculated correctly, though). Traceback:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~\Anaconda3\envs\stress-test\lib\site-packages\psygnal\_signal.py:851, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, args=(False,))
    850 try:
--> 851     if caller(args):
        caller = <psygnal._signal._FunctionCaller object at 0x0000026407620670>
        args = (False,)
    852         # if the slotcaller returns `True`, the object weakref is
    853         # dead and needs to be disconnected
    854         rem.append(caller)

File ~\Anaconda3\envs\stress-test\lib\site-packages\psygnal\_signal.py:1184, in _FunctionCaller.__call__(self=<psygnal._signal._FunctionCaller object>, args=())
   1183     args = args[: self._max_args]
-> 1184 self._slot(*args)
        args = ()
        self._slot = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x0000026407622820>
        self = <psygnal._signal._FunctionCaller object at 0x0000026407620670>
   1185 return False

File ~\Anaconda3\envs\stress-test\lib\site-packages\magicgui\widgets\_function_gui.py:212, in FunctionGui.__init__.<locals>._disable_button_and_call()
    211 try:
--> 212     self.__call__()
        self = <FunctionGui _set_axis_keys(x_axis_key: str = 'mean_curvature', n_bins: int = 50) -> None>
    213 finally:

File ~\Anaconda3\envs\stress-test\lib\site-packages\magicgui\widgets\_function_gui.py:324, in FunctionGui.__call__(self=<FunctionGui _set_axis_keys(x_axis_key: str = 'mean_curvature', n_bins: int = 50) -> None>, update_widget=False, *args=(), **kwargs={})
    323 with _function_name_pointing_to_widget(self):
--> 324     value = self._function(*bound.args, **bound.kwargs)
        self = <FunctionGui _set_axis_keys(x_axis_key: str = 'mean_curvature', n_bins: int = 50) -> None>
        bound = <BoundArguments (x_axis_key='mean_curvature', n_bins=50)>
        self._function = <bound method FeaturesHistogramWidget._set_axis_keys of <napari_stress._plotting.features_histogram.FeaturesHistogramWidget object at 0x000002640A706310>>
    326 self._call_count += 1

File ~\Documents\BiAPoL\Projects\napari-stress\src\napari_stress\_plotting\features_histogram.py:136, in FeaturesHistogramWidget._set_axis_keys(self=<napari_stress._plotting.features_histogram.FeaturesHistogramWidget object>, x_axis_key='mean_curvature', n_bins=50)
    135 self.viewer.layers[self.layers[0].name].refresh_colors(True)
--> 136 self.viewer.layers[self.layers[0].name].face_color = x_axis_key
        x_axis_key = 'mean_curvature'
        self = <napari_stress._plotting.features_histogram.FeaturesHistogramWidget object at 0x000002640A706310>
        self.viewer.layers = [<Points layer 'Points' at 0x264732d2490>, <Points layer 'Points [1]' at 0x2640a12a940>, <Points layer 'Result of lebedev quadrature' at 0x26405bcb610>]
        self.viewer = Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(29.855270350049004, 33.773493688181304, 36.34103003072159), zoom=21.00243539125296, angles=(-73.36374518734551, 55.48234020909476, 36.220213777827645), perspective=0.0, interactive=True), cursor=Cursor(position=(0.0, 49.96681443994228, 40.4738200104223, 48.231427909671005), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=4, ndisplay=3, last_used=0, range=((0.0, 1.0, 1.0), (15.204772207073828, 45.505768493024185, 1.0), (17.82891422576963, 50.71807315059298, 1.0), (21.41344054680773, 52.268619514635446, 1.0)), current_step=(0, 15, 16, 15), order=(0, 1, 2, 3), axis_labels=('0', '1', '2', '3')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Points layer 'Points' at 0x264732d2490>, <Points layer 'Points [1]' at 0x2640a12a940>, <Points layer 'Result of lebedev quadrature' at 0x26405bcb610>], scale_bar=ScaleBar(visible=False, colored=False, color=<class 'numpy.ndarray'> (4,) float32, ticks=True, position=<Position.BOTTOM_RIGHT: 'bottom_right'>, font_size=10.0, box=False, box_color=<class 'numpy.ndarray'> (4,) float32, unit=None), text_overlay=TextOverlay(visible=False, color=<class 'numpy.ndarray'> (4,) float32, font_size=10.0, position=<TextOverlayPosition.TOP_LEFT: 'top_left'>, text=''), overlays=Overlays(interaction_box=InteractionBox(points=None, show=False, show_handle=False, show_vertices=False, selection_box_drag=None, selection_box_final=None, transform_start=<napari.utils.transforms.transforms.Affine object at 0x000002645DD2B580>, transform_drag=<napari.utils.transforms.transforms.Affine object at 0x000002645DD2B5E0>, transform_final=<napari.utils.transforms.transforms.Affine object at 0x000002645DD2B640>, transform=<napari.utils.transforms.transforms.Affine object at 0x000002645DD2B6A0>, allow_new_selection=True, selected_vertex=None)), help='use <2> for add points, use <3> for select points', status={'layer_base': 'Result of lebedev quadrature', 'source_type': 'widget', 'plugin': 'perform_lebedev_quadrature', 'coordinates': ' [0 50 40 48]'}, tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_move at 0x000002646B441DC0>], mouse_drag_callbacks=[<function InteractionBoxMouseBindings.initialize_mouse_events.<locals>.mouse_drag at 0x000002646B418040>], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x000002645D0864C0>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'Shift': <function InteractionBoxMouseBindings.initialize_key_events.<locals>.hold_to_lock_aspect_ratio at 0x000002646B404310>, 'Control-Shift-R': <function InteractionBoxMouseBindings._reset_active_layer_affine at 0x000002646B46D3A0>, 'Control-Shift-A': <function InteractionBoxMouseBindings._transform_active_layer at 0x000002646B46D280>})
        self.layers[0] = <Points layer 'Result of lebedev quadrature' at 0x26405bcb610>
        self.layers = [<Points layer 'Result of lebedev quadrature' at 0x26405bcb610>]

File ~\Anaconda3\envs\stress-test\lib\site-packages\napari\layers\points\points.py:985, in Points.face_color(self=<Points layer 'Result of lebedev quadrature'>, face_color='mean_curvature')
    983 @face_color.setter
    984 def face_color(self, face_color):
--> 985     self._face._set_color(
        self._face = ColorManager(current_color=<class 'numpy.ndarray'> (4,) float64, color_mode=<ColorMode.DIRECT: 'direct'>, color_properties=None, continuous_colormap=Colormap(colors=<class 'numpy.ndarray'> (256, 4) float32, name='viridis', interpolation=<ColormapInterpolationMode.LINEAR: 'linear'>, controls=<class 'numpy.ndarray'> (256,) float32), contrast_limits=None, categorical_colormap=CategoricalColormap(colormap={}, fallback_color=ColorCycle(values=<class 'numpy.ndarray'> (1, 4) float32, cycle=<itertools.cycle object at 0x0000026409DC7040>)), colors=<class 'numpy.ndarray'> (434, 4) float64)
        self = <Points layer 'Result of lebedev quadrature' at 0x26405bcb610>
        face_color = 'mean_curvature'
    986         color=face_color,
    987         n_colors=len(self.data),
    988         properties=self.properties,
    989         current_properties=self.current_properties,
    990     )
    991     self.events.face_color()

File ~\Anaconda3\envs\stress-test\lib\site-packages\napari\layers\utils\color_manager.py:233, in ColorManager._set_color(self=ColorManager(current_color=<class 'numpy.ndarray... colors=<class 'numpy.ndarray'> (434, 4) float64), color='mean_curvature', n_colors=434, properties={'mean_curvature': <class 'numpy.ndarray'> (434,) float64}, current_properties={})
    225 if is_color_mapped(color, properties):
    226     # note that we set ColorProperties.current_value by indexing rather than
    227     # np.squeeze since the current_property values have shape (1,) and
    228     # np.squeeze would return an array with shape ().
    229     # see https://github.com/napari/napari/pull/3110#discussion_r680680779
    230     self.color_properties = ColorProperties(
    231         name=color,
    232         values=properties[color],
--> 233         current_value=current_properties[color][0],
        self.color_properties = None
        self = ColorManager(current_color=<class 'numpy.ndarray'> (4,) float64, color_mode=<ColorMode.DIRECT: 'direct'>, color_properties=None, continuous_colormap=Colormap(colors=<class 'numpy.ndarray'> (256, 4) float32, name='viridis', interpolation=<ColormapInterpolationMode.LINEAR: 'linear'>, controls=<class 'numpy.ndarray'> (256,) float32), contrast_limits=None, categorical_colormap=CategoricalColormap(colormap={}, fallback_color=ColorCycle(values=<class 'numpy.ndarray'> (1, 4) float32, cycle=<itertools.cycle object at 0x0000026409DC7040>)), colors=<class 'numpy.ndarray'> (434, 4) float64)
        color = 'mean_curvature'
        properties = {'mean_curvature': <class 'numpy.ndarray'> (434,) float64}
        properties[color] = <class 'numpy.ndarray'> (434,) float64
        current_properties = {}
    234     )
    235     if guess_continuous(properties[color]):

KeyError: 'mean_curvature'

The above exception was the direct cause of the following exception:

EmitLoopError                             Traceback (most recent call last)
File ~\Anaconda3\envs\stress-test\lib\site-packages\magicgui\widgets\_bases\value_widget.py:57, in ValueWidget._on_value_change(self=PushButton(value=False, annotation=None, name='call_button'), value=False)
     55 if value is self.null_value and not self._nullable:
     56     return
---> 57 self.changed.emit(value)
        value = False
        self.changed = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        self = PushButton(value=False, annotation=None, name='call_button')

File ~\Anaconda3\envs\stress-test\lib\site-packages\psygnal\_signal.py:805, in SignalInstance.emit(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, check_nargs=False, check_types=False, asynchronous=False, *args=(False,))
    802     sd.start()
    803     return sd
--> 805 self._run_emit_loop(args)
        self = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        args = (False,)
    806 return None

File ~\Anaconda3\envs\stress-test\lib\site-packages\psygnal\_signal.py:856, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, args=(False,))
    854                 rem.append(caller)
    855         except Exception as e:
--> 856             raise EmitLoopError(slot=caller.slot(), args=args, exc=e) from e
        caller = <psygnal._signal._FunctionCaller object at 0x0000026407620670>
        args = (False,)
    858 for slot in rem:
    859     self.disconnect(slot)

EmitLoopError: calling <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x0000026407622820> with args=(False,) caused KeyError in emit loop.
@jo-mueller jo-mueller added the bug Something isn't working label Jan 26, 2023
@jo-mueller
Copy link
Member Author

Possible duplicate of #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant