xarray-graph 0.2.3__tar.gz → 0.2.4__tar.gz
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.
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/PKG-INFO +1 -1
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/pyproject.toml +1 -1
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/src/xarray_graph/XarrayGraph.py +42 -58
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/LICENSE +0 -0
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/README.md +0 -0
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/src/xarray_graph/__init__.py +0 -0
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/src/xarray_graph/__main__.py +0 -0
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/src/xarray_graph/tmp/RegionsManager.py +0 -0
- {xarray_graph-0.2.3 → xarray_graph-0.2.4}/tests/__init__.py +0 -0
|
@@ -153,7 +153,7 @@ class XarrayGraph(QMainWindow):
|
|
|
153
153
|
self._notes_edit.setPlainText(self.attrs.get('notes', ''))
|
|
154
154
|
|
|
155
155
|
# populate array math selections
|
|
156
|
-
|
|
156
|
+
self._update_array_math_comboboxes()
|
|
157
157
|
|
|
158
158
|
@property
|
|
159
159
|
def dims(self) -> list[str]:
|
|
@@ -1191,7 +1191,7 @@ class XarrayGraph(QMainWindow):
|
|
|
1191
1191
|
self._math_operator_combobox.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
|
|
1192
1192
|
|
|
1193
1193
|
self._math_eval_button = QPushButton('Evaluate')
|
|
1194
|
-
|
|
1194
|
+
self._math_eval_button.pressed.connect(self.eval_array_math)
|
|
1195
1195
|
|
|
1196
1196
|
math_group = QGroupBox('Array math')
|
|
1197
1197
|
grid = QGridLayout(math_group)
|
|
@@ -1512,13 +1512,6 @@ class XarrayGraph(QMainWindow):
|
|
|
1512
1512
|
|
|
1513
1513
|
self._control_panel.addWidget(scroll_area)
|
|
1514
1514
|
|
|
1515
|
-
# def _show_region_context_menu(self, pos: QPoint) -> None:
|
|
1516
|
-
# if not hasattr(self, '_region_button_menu'):
|
|
1517
|
-
# self._region_button_menu = QMenu()
|
|
1518
|
-
# menu = QMenu()
|
|
1519
|
-
# menu.addAction('Draw X-axis regions until unchecked', self.clear_regions)
|
|
1520
|
-
# menu.exec(self.sender().mapToGlobal(pos))
|
|
1521
|
-
|
|
1522
1515
|
def _set_region_drawing_mode(self, draw: bool | None = None) -> None:
|
|
1523
1516
|
if draw is None:
|
|
1524
1517
|
draw = self._region_button.isChecked()
|
|
@@ -1667,57 +1660,48 @@ class XarrayGraph(QMainWindow):
|
|
|
1667
1660
|
if isinstance(item, XAxisRegion):
|
|
1668
1661
|
item.setFontSize(self._textitem_fontsize_spinbox.value())
|
|
1669
1662
|
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
# self._math_lhs_combobox.addItems(var_items)
|
|
1680
|
-
# self._math_rhs_combobox.addItems(var_items)
|
|
1663
|
+
def _update_array_math_comboboxes(self) -> None:
|
|
1664
|
+
var_paths = [item.path for item in self._data_treeview.model().root().depth_first() if item.is_var()]
|
|
1665
|
+
for i in range(len(var_paths)):
|
|
1666
|
+
if len(var_paths[i]) > 100:
|
|
1667
|
+
var_paths[i] = '...' + var_paths[i][-97:]
|
|
1668
|
+
self._math_lhs_combobox.clear()
|
|
1669
|
+
self._math_rhs_combobox.clear()
|
|
1670
|
+
self._math_lhs_combobox.addItems(var_paths)
|
|
1671
|
+
self._math_rhs_combobox.addItems(var_paths)
|
|
1681
1672
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
# # append result as child of lhs_item
|
|
1704
|
-
# # TODO: handle result name collisions
|
|
1705
|
-
# result_name = self._math_result_name_edit.text().strip()
|
|
1706
|
-
# ds = xr.Dataset(data_vars={result.name: result})
|
|
1707
|
-
# result_node = XarrayTreeNode(name=result_name, dataset=ds, parent=lhs_item.node)
|
|
1673
|
+
def eval_array_math(self) -> None:
|
|
1674
|
+
var_items = [item for item in self._data_treeview.model().root().depth_first() if item.is_var()]
|
|
1675
|
+
lhs_item = var_items[self._math_lhs_combobox.currentIndex()]
|
|
1676
|
+
rhs_item = var_items[self._math_rhs_combobox.currentIndex()]
|
|
1677
|
+
lhs: xr.DataArray = lhs_item.node[lhs_item.key]
|
|
1678
|
+
rhs: xr.DataArray = rhs_item.node[rhs_item.key]
|
|
1679
|
+
op = self._math_operator_combobox.currentText()
|
|
1680
|
+
if op == '+':
|
|
1681
|
+
result = lhs + rhs
|
|
1682
|
+
elif op == '-':
|
|
1683
|
+
result = lhs - rhs
|
|
1684
|
+
elif op == '*':
|
|
1685
|
+
result = lhs * rhs
|
|
1686
|
+
elif op == '/':
|
|
1687
|
+
result = lhs / rhs
|
|
1688
|
+
# append result as child of lhs_item
|
|
1689
|
+
result_name = self._math_result_name_edit.text().strip()
|
|
1690
|
+
if result_name == '':
|
|
1691
|
+
result_name = self._math_result_name_edit.placeholderText()
|
|
1692
|
+
result_ds = xr.Dataset(data_vars={result.name: result})
|
|
1693
|
+
result_node = DataTree(name=result_name, data=result_ds, parent=lhs_item.node)
|
|
1708
1694
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
# self._data_treeview.setExpanded(model.parent(index), True)
|
|
1720
|
-
# item = item.next_depth_first()
|
|
1695
|
+
# update data tree
|
|
1696
|
+
self.data = self.data
|
|
1697
|
+
|
|
1698
|
+
# make sure newly added fit nodes are selected and expanded
|
|
1699
|
+
model: XarrayTreeModel = self._data_treeview.model()
|
|
1700
|
+
for item in model.root().depth_first():
|
|
1701
|
+
if item.node is result_node and item.is_var():
|
|
1702
|
+
index: QModelIndex = model.createIndex(item.sibling_index, 0, item)
|
|
1703
|
+
self._data_treeview.selectionModel().select(index, QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows)
|
|
1704
|
+
self._data_treeview.setExpanded(model.parent(index), True)
|
|
1721
1705
|
|
|
1722
1706
|
# # @Slot()
|
|
1723
1707
|
# # def on_axes_item_changed(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|