NeXpy 2.0.0b8__tar.gz → 2.0.0b9__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.
Files changed (113) hide show
  1. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/PKG-INFO +1 -1
  2. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/PKG-INFO +1 -1
  3. nexpy-2.0.0b9/src/nexpy/_version.py +34 -0
  4. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/consoleapp.py +1 -4
  5. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/dialogs.py +97 -141
  6. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/fitdialogs.py +70 -70
  7. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/mainwindow.py +2 -17
  8. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/plotview.py +3 -1
  9. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/treeview.py +0 -3
  10. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/widgets.py +9 -0
  11. nexpy-2.0.0b8/src/nexpy/_version.py +0 -21
  12. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/.gitattributes +0 -0
  13. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/.github/dependabot.yaml +0 -0
  14. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/.github/workflows/ci.yml +0 -0
  15. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/.gitignore +0 -0
  16. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/COPYING +0 -0
  17. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/README.md +0 -0
  18. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/README.rst +0 -0
  19. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/conda-recipe/bld.bat +0 -0
  20. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/conda-recipe/build.sh +0 -0
  21. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/conda-recipe/meta.yaml +0 -0
  22. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/Makefile +0 -0
  23. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/make.bat +0 -0
  24. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/_static/__ignore__.txt +0 -0
  25. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/conf.py +0 -0
  26. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/examples.rst +0 -0
  27. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/favicon.ico +0 -0
  28. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/axis-limits-bar.png +0 -0
  29. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/customize-panel.png +0 -0
  30. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/limits-panel.png +0 -0
  31. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/nexpy-fits.png +0 -0
  32. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/nexpy-gui.png +0 -0
  33. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/nexpy-logo.png +0 -0
  34. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/options-tab.png +0 -0
  35. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/projection-panel.png +0 -0
  36. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/projection-tab.png +0 -0
  37. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/scan-panel.png +0 -0
  38. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/signal-tab.png +0 -0
  39. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/simple-plot.png +0 -0
  40. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/skewed-axis.png +0 -0
  41. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/x-tab.png +0 -0
  42. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/y-tab.png +0 -0
  43. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/z-tab.png +0 -0
  44. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/images/z-toolbar.png +0 -0
  45. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/includeme.rst +0 -0
  46. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/index.rst +0 -0
  47. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/pythongui.rst +0 -0
  48. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/pythonshell.rst +0 -0
  49. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/readers.rst +0 -0
  50. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/doc/source/treeapi.rst +0 -0
  51. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/pyproject.toml +0 -0
  52. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/setup.cfg +0 -0
  53. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/SOURCES.txt +0 -0
  54. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/dependency_links.txt +0 -0
  55. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/entry_points.txt +0 -0
  56. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/pbr.json +0 -0
  57. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/requires.txt +0 -0
  58. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/NeXpy.egg-info/top_level.txt +0 -0
  59. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/__init__.py +0 -0
  60. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/README.rst +0 -0
  61. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/chopper.nxs +0 -0
  62. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/example.nxs +0 -0
  63. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/README.rst +0 -0
  64. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.py +0 -0
  65. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/__init__.pyc +0 -0
  66. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.py +0 -0
  67. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/convert_qe.pyc +0 -0
  68. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.py +0 -0
  69. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/chopper/get_ei.pyc +0 -0
  70. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/plugins/chopper_plugin/pyproject.toml +0 -0
  71. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/scripts/README.rst +0 -0
  72. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/scripts/chopper_plot.py +0 -0
  73. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/examples/scripts/example.py +0 -0
  74. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/__init__.py +0 -0
  75. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/datadialogs.py +0 -0
  76. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/importdialog.py +0 -0
  77. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/pyqt.py +0 -0
  78. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/NeXpy.png +0 -0
  79. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/NeXpy.svg +0 -0
  80. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/back.png +0 -0
  81. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/backward-icon.png +0 -0
  82. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/customize.png +0 -0
  83. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/equal.png +0 -0
  84. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/export-data.png +0 -0
  85. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/export-figure.png +0 -0
  86. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/filesave.png +0 -0
  87. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/forward-icon.png +0 -0
  88. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/forward.png +0 -0
  89. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/hand.png +0 -0
  90. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/home.png +0 -0
  91. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/link-icon.png +0 -0
  92. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/lock-icon.png +0 -0
  93. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/lock-red-icon.png +0 -0
  94. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/modify-style.png +0 -0
  95. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/move.png +0 -0
  96. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/pause-icon.png +0 -0
  97. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/refresh-icon.png +0 -0
  98. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/unlock-icon.png +0 -0
  99. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/unlock-red-icon.png +0 -0
  100. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/resources/zoom_to_rect.png +0 -0
  101. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/scripteditor.py +0 -0
  102. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/gui/utils.py +0 -0
  103. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/models/bose.py +0 -0
  104. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/models/critexp.py +0 -0
  105. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/models/op.py +0 -0
  106. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/models/pdfdecay.py +0 -0
  107. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/nexpygui.py +0 -0
  108. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/readers/readnpy.py +0 -0
  109. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/readers/readspec.py +0 -0
  110. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/readers/readstack.py +0 -0
  111. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/readers/readtiff.py +0 -0
  112. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/src/nexpy/readers/readtxt.py +0 -0
  113. {nexpy-2.0.0b8 → nexpy-2.0.0b9}/tests/test_imports.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeXpy
3
- Version: 2.0.0b8
3
+ Version: 2.0.0b9
4
4
  Summary: Python GUI to analyze NeXus data
5
5
  Author-email: Raymond Osborn <rayosborn@mac.com>
6
6
  License: Licensing Terms for NeXpy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeXpy
3
- Version: 2.0.0b8
3
+ Version: 2.0.0b9
4
4
  Summary: Python GUI to analyze NeXus data
5
5
  Author-email: Raymond Osborn <rayosborn@mac.com>
6
6
  License: Licensing Terms for NeXpy
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '2.0.0b9'
32
+ __version_tuple__ = version_tuple = (2, 0, 0, 'b9')
33
+
34
+ __commit_id__ = commit_id = 'g71f89ff3a'
@@ -195,10 +195,7 @@ class NXConsoleApp(JupyterQtConsoleApp):
195
195
  self.app.setApplicationName('nexpy')
196
196
  sys.excepthook = report_exception
197
197
  try:
198
- if 'svg' in QtGui.QImageReader.supportedImageFormats():
199
- self.app.icon = resource_icon('NeXpy.svg')
200
- else:
201
- self.app.icon = resource_icon('NeXpy.png')
198
+ self.app.icon = resource_icon('NeXpy.png')
202
199
  QtWidgets.QApplication.setWindowIcon(self.app.icon)
203
200
  self.icon_pixmap = QtGui.QPixmap(
204
201
  self.app.icon.pixmap(QtCore.QSize(64, 64)))
@@ -3920,7 +3920,6 @@ class ViewTab(NXTab):
3920
3920
 
3921
3921
  layout = QtWidgets.QVBoxLayout()
3922
3922
  self.properties = GridParameters()
3923
-
3924
3923
  self.properties.add('class', node.__class__.__name__, 'Class',
3925
3924
  readonly=True)
3926
3925
  self.properties.add('name', node.nxname, 'Name', readonly=True)
@@ -4001,21 +4000,84 @@ class ViewTab(NXTab):
4001
4000
  title='Attributes',
4002
4001
  width=200))
4003
4002
 
4004
- hlayout = QtWidgets.QHBoxLayout()
4005
- hlayout.addStretch()
4006
- hlayout.addLayout(layout)
4007
- if (isinstance(node, NXfield) and node.shape is not None and
4008
- node.shape != () and node.shape != (1,)):
4009
- try:
4010
- table = self.table()
4011
- hlayout.addLayout(table)
4012
- except OSError:
4013
- pass
4014
- hlayout.addStretch()
4015
- self.setLayout(hlayout)
4003
+ self.scroll_area = None
4004
+
4005
+ if isinstance(node, NXgroup):
4006
+ self.group = node
4007
+ field_list = [f for f in self.group.NXfield
4008
+ if f.ndim == 0 or (f.ndim == 1 and f.shape[0] == 1)]
4009
+ if len(field_list) > 0:
4010
+ layout.addWidget(NXLabel('Scalar Fields', bold=True,
4011
+ align='center'))
4012
+ self.grid = QtWidgets.QGridLayout()
4013
+ row = 0
4014
+ grid_height = 0
4015
+ for field in field_list:
4016
+ self.grid.addWidget(NXLabel(field.nxname), row, 0,
4017
+ QtCore.Qt.AlignTop)
4018
+ if field.is_string():
4019
+ field_box = NXTextEdit(field.nxvalue, autosize=True)
4020
+ grid_height += field_box.document().size().height()
4021
+ self.grid.addWidget(field_box, row, 1,
4022
+ QtCore.Qt.AlignTop)
4023
+ else:
4024
+ field_box = NXTextEdit(field.nxvalue, align='right',
4025
+ autosize=True)
4026
+ grid_height += field_box.document().size().height()
4027
+ self.grid.addWidget(field_box, row, 1)
4028
+ self.grid.addWidget(NXLabel(field.nxunits), row, 2)
4029
+ row += 1
4030
+ self.grid.setContentsMargins(10, 0, 40, 10)
4031
+ self.grid.setSpacing(5)
4032
+ self.grid.setColumnStretch(1, 1)
4033
+ group_widget = NXWidget()
4034
+ group_widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
4035
+ QtWidgets.QSizePolicy.Expanding)
4036
+ grid_container = NXWidget()
4037
+ grid_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
4038
+ QtWidgets.QSizePolicy.Expanding)
4039
+ grid_container.setLayout(self.grid)
4040
+ if grid_height > 400:
4041
+ grid_container = NXWidget()
4042
+ grid_container.setLayout(self.grid)
4043
+ self.scroll_area = NXScrollArea(grid_container, height=600)
4044
+ self.scroll_area.setMinimumHeight(400)
4045
+ grid_layout = QtWidgets.QVBoxLayout()
4046
+ grid_layout.addWidget(self.scroll_area)
4047
+ group_widget.setLayout(grid_layout)
4048
+ else:
4049
+ group_widget.setLayout(self.grid)
4050
+ layout.addWidget(group_widget)
4051
+ self.save_button = NXPushButton('Save', self.save_scalar_fields)
4052
+ layout.addWidget(self.save_button,
4053
+ alignment=QtCore.Qt.AlignCenter)
4054
+ self.setLayout(layout)
4055
+ else:
4056
+ self.group = None
4057
+ hlayout = QtWidgets.QHBoxLayout()
4058
+ hlayout.addStretch()
4059
+ hlayout.addLayout(layout)
4060
+ if (isinstance(node, NXfield) and node.shape is not None and
4061
+ node.shape != () and node.shape != (1,)):
4062
+ try:
4063
+ table = self.table()
4064
+ hlayout.addLayout(table)
4065
+ except OSError:
4066
+ pass
4067
+ hlayout.addStretch()
4068
+ self.setLayout(hlayout)
4016
4069
 
4017
4070
  self.setWindowTitle(node.nxroot.nxname+node.nxpath)
4018
4071
 
4072
+ def resize(self):
4073
+ """Update the size of the scroll area and its contents."""
4074
+ super().resize()
4075
+ if self.scroll_area is not None:
4076
+ self.scroll_area.widget().updateGeometry()
4077
+ self.scroll_area.updateGeometry()
4078
+ self.scroll_area.widget().adjustSize()
4079
+ self.scroll_area.adjustSize()
4080
+
4019
4081
  def table(self):
4020
4082
  """
4021
4083
  Create a table view for displaying the data in a NeXus field.
@@ -4099,6 +4161,28 @@ class ViewTab(NXTab):
4099
4161
  hheight = self.table_view.horizontalHeader().height()
4100
4162
  self.table_view.setFixedHeight(vheight + hheight)
4101
4163
 
4164
+ def save_scalar_fields(self):
4165
+ if not self.group.is_modifiable():
4166
+ self.display_message('Group is read-only')
4167
+ return
4168
+ row = 1
4169
+ for row in range(1, self.grid.rowCount()):
4170
+ field_name = self.grid.itemAtPosition(row, 0).widget().text()
4171
+ field = self.group[field_name]
4172
+ if field.is_string():
4173
+ value = self.grid.itemAtPosition(row, 1).widget().toPlainText()
4174
+ if field.nxvalue != value.rstrip():
4175
+ field.nxdata = value.rstrip()
4176
+ else:
4177
+ value = self.grid.itemAtPosition(row, 1).widget().toPlainText()
4178
+ try:
4179
+ value = field.dtype.type(value)
4180
+ except ValueError:
4181
+ self.display_message(f'Invalid value for {field.nxname}')
4182
+ return
4183
+ if not np.isclose(field.nxvalue, value):
4184
+ field.nxdata = value
4185
+
4102
4186
 
4103
4187
  class ViewTableModel(QtCore.QAbstractTableModel):
4104
4188
 
@@ -4494,134 +4578,6 @@ class ValidateTab(NXTab):
4494
4578
  self.activateWindow()
4495
4579
 
4496
4580
 
4497
- class EditDialog(NXPanel):
4498
-
4499
- def __init__(self, parent=None):
4500
- """Initialize the Edit Panel.
4501
-
4502
- Parameters
4503
- ----------
4504
- parent : QWidget, optional
4505
- The parent of the dialog. The default is None.
4506
- """
4507
- super().__init__('Edit', title='Edit Panel', apply=True, reset=False,
4508
- parent=parent)
4509
- self.tab_class = EditTab
4510
-
4511
- def activate(self, node):
4512
- """
4513
- Activate a tab to edit the contents of a NeXus group.
4514
-
4515
- Parameters
4516
- ----------
4517
- node : NXobject
4518
- The node to be edited
4519
- """
4520
- label = node.nxroot.nxname + node.nxpath
4521
- if label not in self.tabs:
4522
- tab = EditTab(label, node, parent=self)
4523
- self.add(label, tab, idx=self.idx(label))
4524
- else:
4525
- self.tab = label
4526
- self.setVisible(True)
4527
- self.raise_()
4528
- self.activateWindow()
4529
-
4530
-
4531
- class EditTab(NXTab):
4532
-
4533
- def __init__(self, label, node, parent=None):
4534
-
4535
- """
4536
- Initialize the tab to edit the contents of a NeXus group. Only
4537
- scalar fields are editable in this dialog.
4538
-
4539
- Parameters
4540
- ----------
4541
- label : str
4542
- The title of the tab
4543
- node : NXobject
4544
- The NeXus node to be edited
4545
- parent : QWidget, optional
4546
- The parent of the tab
4547
- """
4548
- super().__init__(label, parent=parent)
4549
-
4550
- self.group = node
4551
- if not isinstance(self.group, NXgroup):
4552
- raise NeXusError('The node must be a NeXus group')
4553
-
4554
- field_list = [f for f in self.group.NXfield if f.ndim == 0]
4555
- if len(field_list) == 0:
4556
- raise NeXusError(f"No scalar fields found in {self.group.nxpath}")
4557
-
4558
- self.grid = QtWidgets.QGridLayout()
4559
- self.grid.setSpacing(10)
4560
- headers = ['Field', 'Value', '']
4561
- width = [100, 100, 20]
4562
- column = 0
4563
- for header in headers:
4564
- label = NXLabel(header, bold=True, align='center')
4565
- self.grid.addWidget(label, 0, column)
4566
- self.grid.setColumnMinimumWidth(column, width[column])
4567
- column += 1
4568
-
4569
- row = 1
4570
- for field in field_list:
4571
- self.grid.addWidget(NXLabel(field.nxname), row, 0,
4572
- QtCore.Qt.AlignTop)
4573
- if field.is_string():
4574
- self.grid.addWidget(NXTextEdit(field.nxvalue, autosize=True),
4575
- row, 1, QtCore.Qt.AlignTop)
4576
- else:
4577
- self.grid.addWidget(NXTextEdit(field.nxvalue, align='right',
4578
- autosize=True),
4579
- row, 1)
4580
- self.grid.addWidget(NXLabel(field.nxunits), row, 2)
4581
- row += 1
4582
- self.grid.setContentsMargins(10, 10, 40, 10)
4583
- self.grid.setSpacing(5)
4584
- if len(field_list) > 10:
4585
- self.scroll_area = NXScrollArea(self.grid, height=800)
4586
- self.scroll_area.setMinimumHeight(200)
4587
- self.set_layout(self.scroll_area)
4588
- else:
4589
- self.set_layout(self.grid)
4590
- self.scroll_area = None
4591
- self.set_title(f'Edit {self.group.nxpath}')
4592
-
4593
- def resize(self):
4594
- """Update the size of the scroll area and its contents."""
4595
- super().resize()
4596
- if self.scroll_area is not None:
4597
- self.scroll_area.widget().updateGeometry()
4598
- self.scroll_area.updateGeometry()
4599
- self.scroll_area.widget().adjustSize()
4600
- self.scroll_area.adjustSize()
4601
-
4602
- def apply(self):
4603
- if not self.group.is_modifiable():
4604
- self.display_message('Group is read-only')
4605
- return
4606
- row = 1
4607
- for row in range(1, self.grid.rowCount()):
4608
- field_name = self.grid.itemAtPosition(row, 0).widget().text()
4609
- field = self.group[field_name]
4610
- if field.is_string():
4611
- value = self.grid.itemAtPosition(row, 1).widget().toPlainText()
4612
- if field.nxvalue != value.rstrip():
4613
- field.nxdata = value.rstrip()
4614
- else:
4615
- value = self.grid.itemAtPosition(row, 1).widget().toPlainText()
4616
- try:
4617
- value = field.dtype.type(value)
4618
- except ValueError:
4619
- self.display_message(f'Invalid value for {field.nxname}')
4620
- return
4621
- if not np.isclose(field.nxvalue, value):
4622
- field.nxdata = value
4623
-
4624
-
4625
4581
  class GroupDialog(NXDialog):
4626
4582
 
4627
4583
  def __init__(self, node, parent=None):
@@ -298,13 +298,13 @@ class FitTab(NXTab):
298
298
  self.remove_combo = NXComboBox()
299
299
  self.restore_button = NXPushButton("Restore Parameters",
300
300
  self.restore_parameters)
301
- self.save_parameters_button = NXPushButton("Save Parameters",
302
- self.save_parameters)
301
+ self.copy_parameters_button = NXPushButton("Copy Parameters",
302
+ self.copy_parameters)
303
303
  self.remove_layout = self.make_layout(self.remove_button,
304
304
  self.remove_combo,
305
305
  'stretch',
306
306
  self.restore_button,
307
- self.save_parameters_button,
307
+ self.copy_parameters_button,
308
308
  align='justified')
309
309
 
310
310
  if self.plotview is None:
@@ -332,11 +332,13 @@ class FitTab(NXTab):
332
332
  else:
333
333
  self.fit_checkbox = NXCheckBox('Use Poisson Errors',
334
334
  self.define_errors)
335
+ self.copy_fit_button = NXPushButton("Copy Fit", self.copy_fit)
335
336
  self.save_fit_button = NXPushButton("Save Fit", self.save_fit)
336
337
  self.adjust_layout = self.make_layout(self.fit_button,
337
338
  self.fit_combo,
338
339
  self.fit_checkbox,
339
340
  'stretch',
341
+ self.copy_fit_button,
340
342
  self.save_fit_button,
341
343
  align='justified')
342
344
 
@@ -506,12 +508,13 @@ class FitTab(NXTab):
506
508
  self.remove_button.setVisible(False)
507
509
  self.remove_combo.setVisible(False)
508
510
  self.restore_button.setVisible(False)
509
- self.save_parameters_button.setVisible(False)
511
+ self.copy_parameters_button.setVisible(False)
510
512
  self.fit_button.setVisible(False)
511
513
  self.fit_combo.setVisible(False)
512
514
  self.fit_checkbox.setVisible(False)
513
515
  self.fit_status.setVisible(False)
514
516
  self.report_button.setVisible(False)
517
+ self.copy_fit_button.setVisible(False)
515
518
  self.save_fit_button.setVisible(False)
516
519
  self.plot_model_button.setVisible(False)
517
520
  self.plot_combo.setVisible(False)
@@ -522,7 +525,7 @@ class FitTab(NXTab):
522
525
  self.compose_button.setVisible(True)
523
526
  self.remove_button.setVisible(True)
524
527
  self.remove_combo.setVisible(True)
525
- self.save_parameters_button.setVisible(True)
528
+ self.copy_parameters_button.setVisible(True)
526
529
  self.fit_button.setVisible(True)
527
530
  self.fit_combo.setVisible(True)
528
531
  self.fit_checkbox.setVisible(True)
@@ -533,8 +536,10 @@ class FitTab(NXTab):
533
536
  self.restore_button.setVisible(True)
534
537
  self.fit_status.setVisible(True)
535
538
  self.report_button.setVisible(True)
539
+ self.copy_fit_button.setVisible(True)
536
540
  self.save_fit_button.setVisible(True)
537
541
  else:
542
+ self.copy_fit_button.setVisible(False)
538
543
  self.save_fit_button.setVisible(False)
539
544
 
540
545
  @property
@@ -870,15 +875,19 @@ class FitTab(NXTab):
870
875
  self.model += model['model']
871
876
  self.composite_model += '+' + model['name']
872
877
  self.add_model_parameters(model_index)
873
- try:
874
- if 'model' in group:
875
- composite_model = group['model'].nxvalue
876
- self.model = self.eval_model(composite_model)
877
- self.composite_model = composite_model
878
- except NeXusError:
879
- pass
878
+ if 'composite_model' in group.attrs:
879
+ composite_model = group.attrs['composite_model']
880
+ elif 'model' in group and isinstance(group['model'], NXfield):
881
+ composite_model = group['model'].nxvalue
882
+ else:
883
+ composite_model = None
884
+ if composite_model is not None:
885
+ self.model = self.eval_model(composite_model)
886
+ self.composite_model = composite_model
887
+ else:
888
+ self.model = self.eval_model(self.composite_model)
880
889
  self.write_parameters()
881
- self.save_parameters_button.setVisible(True)
890
+ self.copy_parameters_button.setVisible(True)
882
891
  self.save_fit_button.setVisible(False)
883
892
 
884
893
  def convert_parameter_name(self, parameter, saved_parameters):
@@ -1348,7 +1357,7 @@ class FitTab(NXTab):
1348
1357
  p.value = make_float(p.box['value'].text())
1349
1358
  p.min = make_float(p.box['min'].text())
1350
1359
  p.max = make_float(p.box['max'].text())
1351
- p.vary = not p.box['fixed'].checkState()
1360
+ p.vary = not p.box['fixed'].isChecked()
1352
1361
  for m in self.models:
1353
1362
  for parameter in m['parameters']:
1354
1363
  p = m['parameters'][parameter]
@@ -1653,18 +1662,7 @@ class FitTab(NXTab):
1653
1662
  self.fit_status.setText('Fit failed')
1654
1663
 
1655
1664
  def report_fit(self):
1656
- """
1657
- Display the results of a fit in a message box.
1658
-
1659
- This function is used to display the results of a fit in a message box.
1660
- The message box contains a text box that displays the fit results.
1661
- The fit results are formatted as a multi-line string, with each line
1662
- containing a different piece of information about the fit. The
1663
- information includes the fit message, the chi^2 and reduced chi^2, the
1664
- number of function evaluations, the number of variables, the number
1665
- of data points, and the number of degrees of freedom. The fit report
1666
- is also included.
1667
- """
1665
+ """Display the results of a fit in a message box."""
1668
1666
  if self.fit.result.errorbars:
1669
1667
  errors = 'Uncertainties estimated'
1670
1668
  else:
@@ -1687,30 +1685,14 @@ class FitTab(NXTab):
1687
1685
  layout.addItem(spacer, layout.rowCount(), 0, 1, layout.columnCount())
1688
1686
  message_box.exec()
1689
1687
 
1690
- def save_fit(self):
1691
- """
1692
- Save the fit results in a NXprocess group.
1693
-
1694
- If the fit results have not been calculated, a message is posted
1695
- to the status bar and the function returns without doing
1696
- anything else.
1697
-
1698
- The NXprocess group is built from the data, model, and
1699
- parameters. The model and data are stored in the group as
1700
- datasets, and the parameters are stored as attributes of the
1701
- datasets. The program name and version are stored as attributes
1702
- of the group. The fit statistics are stored as attributes of a
1703
- 'statistics' dataset in the group. The fit report is stored as a
1704
- note in the group.
1705
-
1706
- The group is then written to disk using the write_group method.
1707
- """
1688
+ def store_fit(self):
1689
+ """Store the results of a fit in a NXprocess group."""
1708
1690
  if self.fit is None:
1709
1691
  self.fit_status.setText('Fit not available for saving')
1710
1692
  return
1711
1693
  self.read_parameters()
1712
1694
  group = NXprocess()
1713
- group['model'] = self.composite_model
1695
+ group.attrs['composite_model'] = self.composite_model
1714
1696
  group['data'] = self.data
1715
1697
  for m in self.models:
1716
1698
  group[m['name']] = self.get_model(m['model'])
@@ -1742,41 +1724,34 @@ class FitTab(NXTab):
1742
1724
  f'No. of Data Points = {self.fit.result.ndata}\n'
1743
1725
  f'No. of Degrees of Freedom = {self.fit.result.nfree}\n'
1744
1726
  f'{self.fit.fit_report()}')
1745
- self.write_group(group)
1727
+ return group
1746
1728
 
1747
- def save_parameters(self):
1729
+ def copy_fit(self):
1748
1730
  """
1749
- Save the fit model in a NXprocess group.
1731
+ Copy the results of a fit to the clipboard.
1750
1732
 
1751
- The group contains the model name, the data, and a 'parameters'
1752
- dataset containing the values of all the model parameters. The
1753
- group is then written to disk using the write_group method.
1733
+ The results of the fit are copied to the clipboard as a
1734
+ NXprocess group containing the model, data, and parameters. The
1735
+ group can then be pasted into another NeXus group in the tree.
1754
1736
  """
1755
- self.read_parameters()
1756
- group = NXprocess()
1757
- group['model'] = self.composite_model
1758
- group['data'] = self.data
1759
- for m in self.models:
1760
- group[m['name']] = self.get_model(m['model'])
1761
- parameters = NXparameters(attrs={'model': m['class']})
1762
- for n, p in m['parameters'].items():
1763
- n = n.replace(m['model'].prefix, '')
1764
- parameters[n] = NXfield(p.value, error=p.stderr,
1765
- initial_value=p.init_value,
1766
- min=str(p.min), max=str(p.max),
1767
- vary=p.vary, expr=p.expr)
1768
- group[m['name']].insert(parameters)
1769
- group['title'] = 'Fit Model'
1770
- group['model'] = self.get_model()
1737
+ group = self.store_fit()
1738
+ self.mainwindow.copied_node = self.mainwindow.copy_node(group)
1739
+
1740
+ def save_fit(self):
1741
+ """Save the results of a fit to the scratch file.
1742
+
1743
+ The results of the fit are written to the NeXpy scratch file as
1744
+ a NXprocess group containing the model, data, and parameters.
1745
+ """
1746
+ group = self.store_fit()
1771
1747
  self.write_group(group)
1772
1748
 
1773
1749
  def write_group(self, group):
1774
1750
  """
1775
- Write a group to the scratch file.
1751
+ Write a group to the NeXpy scratch file.
1776
1752
 
1777
1753
  The group is written to the first free number in the scratch file,
1778
- starting from 'f1'. The group name is then displayed in the status
1779
- bar.
1754
+ starting from 'f1'.
1780
1755
  """
1781
1756
  if 'w0' not in self.tree:
1782
1757
  self.tree['w0'] = nxload(self.mainwindow.scratch_file, 'rw')
@@ -1793,6 +1768,31 @@ class FitTab(NXTab):
1793
1768
  self.tree['w0'][name] = group
1794
1769
  self.fit_status.setText(f'Parameters saved to w0/{name}')
1795
1770
 
1771
+ def copy_parameters(self):
1772
+ """Copy the current parameters to the clipboard.
1773
+
1774
+ The parameters are copied to the clipboard as a NXprocess group
1775
+ containing the model, data, and parameters. The group can then
1776
+ be pasted into another NeXus group in the tree.
1777
+ """
1778
+ self.read_parameters()
1779
+ group = NXprocess()
1780
+ group.attrs['composite_model'] = self.composite_model
1781
+ group['data'] = self.data
1782
+ for m in self.models:
1783
+ group[m['name']] = self.get_model(m['model'])
1784
+ parameters = NXparameters(attrs={'model': m['class']})
1785
+ for n, p in m['parameters'].items():
1786
+ n = n.replace(m['model'].prefix, '')
1787
+ parameters[n] = NXfield(p.value, error=p.stderr,
1788
+ initial_value=p.init_value,
1789
+ min=str(p.min), max=str(p.max),
1790
+ vary=p.vary, expr=p.expr)
1791
+ group[m['name']].insert(parameters)
1792
+ group['title'] = 'Fit Model'
1793
+ group['model'] = self.get_model()
1794
+ self.mainwindow.copied_node = self.mainwindow.copy_node(group)
1795
+
1796
1796
  def restore_parameters(self):
1797
1797
  """
1798
1798
  Restore the initial parameters of the fit model.
@@ -28,8 +28,8 @@ from qtconsole.rich_jupyter_widget import RichJupyterWidget
28
28
 
29
29
  from .. import __version__
30
30
  from .dialogs import (AttributeDialog, CustomizeDialog, DirectoryDialog,
31
- EditDialog, ExportDialog, FieldDialog, GroupDialog,
32
- LimitDialog, LockDialog, LogDialog, ManageBackupsDialog,
31
+ ExportDialog, FieldDialog, GroupDialog, LimitDialog,
32
+ LockDialog, LogDialog, ManageBackupsDialog,
33
33
  ManagePluginsDialog, NewDialog, PasteDialog, PlotDialog,
34
34
  PlotScalarDialog, ProjectionDialog, RenameDialog,
35
35
  ScanDialog, SettingsDialog, SignalDialog, UnlockDialog,
@@ -543,11 +543,6 @@ class MainWindow(QtWidgets.QMainWindow):
543
543
 
544
544
  self.data_menu.addSeparator()
545
545
 
546
- self.edit_action = QtWidgets.QAction(
547
- "Edit Data", self, shortcut=QtGui.QKeySequence("Ctrl+E"),
548
- triggered=self.edit_data)
549
- self.add_menu_action(self.data_menu, self.edit_action)
550
-
551
546
  self.rename_action = QtWidgets.QAction("Rename Data", self,
552
547
  triggered=self.rename_data)
553
548
  self.add_menu_action(self.data_menu, self.rename_action)
@@ -1686,16 +1681,6 @@ class MainWindow(QtWidgets.QMainWindow):
1686
1681
  except NeXusError as error:
1687
1682
  report_error("Viewing Data", error)
1688
1683
 
1689
- def edit_data(self):
1690
- """Open an editor for the selected group."""
1691
- try:
1692
- node = self.treeview.get_node()
1693
- if not self.panel_is_running('Edit'):
1694
- self.panels['Edit'] = EditDialog()
1695
- self.panels['Edit'].activate(node)
1696
- except NeXusError as error:
1697
- report_error("Editing Data", error)
1698
-
1699
1684
  def validate_data(self):
1700
1685
  """
1701
1686
  Validate the selected data.
@@ -1917,8 +1917,10 @@ class NXPlotView(QtWidgets.QDialog):
1917
1917
  raise NeXusError('Can only rotate 2D data.')
1918
1918
  try:
1919
1919
  angle = float(angle)
1920
+ if not (angle > -360.0 and angle < 360.0):
1921
+ raise ValueError
1920
1922
  except (ValueError, TypeError):
1921
- raise NeXusError('Rotation angle must be a number.')
1923
+ raise NeXusError('Rotation angle is invalid.')
1922
1924
  return rotate_data(self.plotdata, angle, aspect=self.get_aspect())
1923
1925
 
1924
1926
  @property
@@ -519,7 +519,6 @@ class NXTreeView(QtWidgets.QTreeView):
519
519
  self.mainwindow.group_action.setEnabled(False)
520
520
  self.mainwindow.field_action.setEnabled(False)
521
521
  self.mainwindow.attribute_action.setEnabled(False)
522
- self.mainwindow.edit_action.setEnabled(False)
523
522
  self.mainwindow.rename_action.setEnabled(False)
524
523
  self.mainwindow.delete_action.setEnabled(False)
525
524
  self.mainwindow.copydata_action.setEnabled(False)
@@ -570,7 +569,6 @@ class NXTreeView(QtWidgets.QTreeView):
570
569
  self.mainwindow.copydata_action.setEnabled(True)
571
570
  if isinstance(node, NXgroup):
572
571
  self.mainwindow.validate_action.setEnabled(True)
573
- self.mainwindow.edit_action.setEnabled(True)
574
572
  if isinstance(node, NXlink):
575
573
  self.mainwindow.link_action.setEnabled(True)
576
574
  if isinstance(node, NXdata):
@@ -679,7 +677,6 @@ class NXTreeView(QtWidgets.QTreeView):
679
677
  self.addMenu(self.mainwindow.field_action)
680
678
  self.addMenu(self.mainwindow.attribute_action)
681
679
  self.menu.addSeparator()
682
- self.addMenu(self.mainwindow.edit_action)
683
680
  self.addMenu(self.mainwindow.rename_action)
684
681
  self.addMenu(self.mainwindow.delete_action)
685
682
  self.menu.addSeparator()
@@ -2085,6 +2085,10 @@ class GridParameter:
2085
2085
  Whether the field contains a color value, default False.
2086
2086
  spinbox : bool, optional
2087
2087
  Whether the field should be a spin box, default False.
2088
+ readonly : bool, optional
2089
+ Whether the field is read-only, default False.
2090
+ width : int, optional
2091
+ Width of the box, default None
2088
2092
  """
2089
2093
  self.name = name
2090
2094
  self._value = value
@@ -3165,6 +3169,11 @@ class NXPushButton(QtWidgets.QPushButton):
3165
3169
  else:
3166
3170
  self.parent().keyPressEvent(event)
3167
3171
 
3172
+ def mouseReleaseEvent(self, event: QtGui.QMouseEvent):
3173
+ """Clear focus after a mouse release event."""
3174
+ super().mouseReleaseEvent(event)
3175
+ self.clearFocus()
3176
+
3168
3177
 
3169
3178
  class NXColorButton(QtWidgets.QPushButton):
3170
3179
 
@@ -1,21 +0,0 @@
1
- # file generated by setuptools-scm
2
- # don't change, don't track in version control
3
-
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
-
6
- TYPE_CHECKING = False
7
- if TYPE_CHECKING:
8
- from typing import Tuple
9
- from typing import Union
10
-
11
- VERSION_TUPLE = Tuple[Union[int, str], ...]
12
- else:
13
- VERSION_TUPLE = object
14
-
15
- version: str
16
- __version__: str
17
- __version_tuple__: VERSION_TUPLE
18
- version_tuple: VERSION_TUPLE
19
-
20
- __version__ = version = '2.0.0b8'
21
- __version_tuple__ = version_tuple = (2, 0, 0, 'b8')
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes