scatter3d-anywidget 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scatter3d/scatter3d.py CHANGED
@@ -80,6 +80,7 @@ class Category:
80
80
  label_list=None,
81
81
  color_palette: dict[Any, tuple[float, float, float]] | None = None,
82
82
  missing_color: tuple[float, float, float] = MISSING_COLOR,
83
+ editable: bool = True,
83
84
  ):
84
85
  self._cb_id_gen = count(1)
85
86
  self._callbacks: dict[int, weakref.ReferenceType] = {}
@@ -102,6 +103,8 @@ class Category:
102
103
  _is_valid_color(missing_color)
103
104
  self._missing_color = missing_color
104
105
 
106
+ self._editable = bool(editable)
107
+
105
108
  def subscribe(self, cb: CategoryCallback) -> int:
106
109
  cb_id = next(self._cb_id_gen)
107
110
  try:
@@ -125,6 +128,10 @@ class Category:
125
128
  for cb_id in dead:
126
129
  self._callbacks.pop(cb_id, None)
127
130
 
131
+ @property
132
+ def editable(self) -> bool:
133
+ return self._editable
134
+
128
135
  @staticmethod
129
136
  def _get_unique_labels_in_values(values):
130
137
  return values.drop_nulls().unique().to_list()
@@ -495,6 +502,11 @@ class Scatter3dWidget(anywidget.AnyWidget):
495
502
  help="Desired widget height in CSS pixels. Frontend will clamp to notebook constraints.",
496
503
  ).tag(sync=True)
497
504
 
505
+ category_editable_t = traitlets.Bool(
506
+ default_value=True,
507
+ help="Whether the active category is editable (enables lasso UI).",
508
+ ).tag(sync=True)
509
+
498
510
  def __init__(
499
511
  self,
500
512
  xyz: numpy.ndarray,
@@ -730,6 +742,10 @@ class Scatter3dWidget(anywidget.AnyWidget):
730
742
  )
731
743
  return v
732
744
 
745
+ @property
746
+ def active_category(self):
747
+ return self.active_category_t
748
+
733
749
  @traitlets.observe("tooltip_request_t")
734
750
  def _on_tooltip_request(self, change) -> None:
735
751
  req = change["new"] or {}
@@ -845,6 +861,13 @@ class Scatter3dWidget(anywidget.AnyWidget):
845
861
  labels = [str(lbl) for lbl in cat.label_list]
846
862
  self.labels_t = labels
847
863
 
864
+ self.category_editable_t = cat.editable
865
+
866
+ if not self.category_editable_t and self.interaction_mode_t == "lasso":
867
+ self.interaction_mode_t = "rotate"
868
+ if self.interactive_ready_t:
869
+ self.send_state("interaction_mode_t")
870
+
848
871
  # coded values: uint16 bytes, length N
849
872
  coded = cat.coded_values
850
873
  if coded.shape[0] != self.num_points: