Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sasview-counterpart-t…
Browse files Browse the repository at this point in the history
…o-sasdata-manipulations-rewrite
  • Loading branch information
ehewins committed Sep 17, 2023
2 parents 0a74773 + 90e45b7 commit bddcc9d
Show file tree
Hide file tree
Showing 73 changed files with 4,946 additions and 53 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9

- uses: actions/checkout@v3
- id: set-matrix
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Install utilities to build installer
if: ${{ matrix.installer }}
run: |
python -m pip install pyinstaller==5.7.0
python -m pip install pyinstaller
- name: Build sasview with pyinstaller
if: ${{ matrix.installer }}
Expand Down Expand Up @@ -283,7 +283,7 @@ jobs:
strategy:
matrix:
os: [ windows-latest, ubuntu-20.04 ]
python-version: [ 3.8 ]
python-version: [ 3.11 ]
fail-fast: false

name: Test installer
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@

# List of python versions to use for release builds
python_release_list = [
'3.8',
'3.11',
]

# List of python versions to use for tests
python_test_list = python_release_list + [
'3.8',
'3.9',
'3.10'
]
Expand Down
11 changes: 5 additions & 6 deletions build_tools/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
numpy<1.24
scipy==1.10.0
numpy
scipy
docutils
pytest
pytest_qt
pytest-mock
unittest-xml-reporting
tinycc
h5py
h5py
sphinx
pyparsing
html5lib
reportlab==3.6.6
pybind11
appdirs
six
Expand All @@ -22,7 +21,7 @@ xhtml2pdf
pylint
periodictable
uncertainties
matplotlib~=3.5.2
matplotlib
lxml
pytools
cffi
Expand All @@ -33,7 +32,7 @@ bumps
html2text
jsonschema
pywin32; platform_system == "Windows"
PySide6==6.2.4
PySide6==6.4.3
twisted
zope
superqt
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from setuptools import setup, Command, find_packages


# Manage version number
version_file = os.path.join("src", "sas", "system", "version.py")
with open(version_file) as fid:
Expand Down Expand Up @@ -80,6 +81,9 @@ def run(self):
'install', 'build', 'build_py', 'bdist', 'bdist_egg', 'bdist_rpm',
'bdist_wheel', 'develop', 'test'
]

print(sys.argv)

# determine if this run requires building of Qt GUI ui->py
build_qt = any(c in sys.argv for c in build_commands)
force_rebuild = "-f" if 'rebuild_ui' in sys.argv or 'clean' in sys.argv else ""
Expand All @@ -93,7 +97,7 @@ def run(self):
# Required packages
required = [
'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing>=2.0.0',
'lxml', 'h5py',
'lxml',
]

if os.name == 'nt':
Expand Down
9 changes: 1 addition & 8 deletions src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,7 @@ def _findId(self, name):
def _extractData(self, key_id):
""" Extract data from file with id contained in list of filenames """
data_complete = self.filenames[key_id]
dimension = data_complete.data.__class__.__name__

if dimension in ('Data1D', 'Data2D'):
return copy.deepcopy(data_complete.data)

else:
logging.error('Error with data format')
return
return copy.deepcopy(data_complete)

# ########
# PLOTS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
from typing import List, Tuple

from PySide6.QtWidgets import QWidget, QVBoxLayout, QFormLayout, QComboBox, QDoubleSpinBox

from sas.qtgui.Perspectives.ParticleEditor.datamodel.calculation import AngularDistribution
from sas.qtgui.Perspectives.ParticleEditor.sampling.geodesic import GeodesicDivisions
from sas.qtgui.Perspectives.ParticleEditor.sampling.angles import angular_sampling_methods
from sas.qtgui.Perspectives.ParticleEditor.GeodesicSampleSelector import GeodesicSamplingSpinBox

class ParametersForm(QWidget):
""" Form that displays the parameters associated with the class (also responsible for generating the sampler)"""
def __init__(self, sampling_class: type, parent=None):
super().__init__(parent=parent)

self.sampling_class = sampling_class

self.layout = QFormLayout()
self.parameter_callbacks = []

for parameter_name, text, cls in sampling_class.parameters():
if cls == GeodesicDivisions:
widget = GeodesicSamplingSpinBox()

def callback():
return widget.getNDivisions()

elif cls == float:
widget = QDoubleSpinBox()

def callback():
return widget.value()


else:
raise TypeError(f"Cannot create appropriate widget for parameter of type '{cls}'")

self.layout.addRow(text, widget)
self.parameter_callbacks.append((parameter_name, callback))

self.setLayout(self.layout)

def generate_sampler(self) -> AngularDistribution:
""" Generate a sampler based on the selected parameters """

parameter_dict = {name: callback() for name, callback in self.parameter_callbacks}

return self.sampling_class(**parameter_dict)



class AngularSamplingMethodSelector(QWidget):
""" Selects the method for doing angular sampling, and provides access to the parameters """

def __init__(self, parent=None):
super().__init__(parent)

layout = QVBoxLayout()

self.combo = QComboBox()
self.combo.addItems([cls.name() for cls in angular_sampling_methods])

subwidget = QWidget()
self.subwidget_layout = QVBoxLayout()
subwidget.setLayout(self.subwidget_layout)

layout.addWidget(self.combo)
layout.addWidget(subwidget)

self.setLayout(layout)

self.entry_widgets = [ParametersForm(cls) for cls in angular_sampling_methods]

for widget in self.entry_widgets:
self.subwidget_layout.addWidget(widget)
widget.hide()

self.entry_widgets[0].show()

self.combo.currentIndexChanged.connect(self.on_update)

def on_update(self):
for i in range(self.subwidget_layout.count()):
self.subwidget_layout.itemAt(i).widget().hide()

self.subwidget_layout.itemAt(self.combo.currentIndex()).widget().show()

def generate_sampler(self) -> AngularDistribution:
""" Create the angular distribution sampler spectified by the current settings"""
return self.subwidget_layout.itemAt(self.combo.currentIndex()).widget().generate_sampler()

def main():
""" Show a demo """

from PySide6 import QtWidgets


app = QtWidgets.QApplication([])


widget = QWidget()
layout = QVBoxLayout()

sampling = AngularSamplingMethodSelector()

def callback():
print(sampling.generate_sampler())

button = QtWidgets.QPushButton("Check")
button.clicked.connect(callback)

layout.addWidget(sampling)
layout.addWidget(button)

widget.setLayout(layout)

widget.show()
app.exec_()


if __name__ == "__main__":
main()
27 changes: 27 additions & 0 deletions src/sas/qtgui/Perspectives/ParticleEditor/CodeToolBar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from PySide6 import QtWidgets, QtGui

from sas.qtgui.Perspectives.ParticleEditor.UI.CodeToolBarUI import Ui_CodeToolBar

import sas.qtgui.Perspectives.ParticleEditor.UI.icons_rc
class CodeToolBar(QtWidgets.QWidget, Ui_CodeToolBar):
def __init__(self, parent=None):
super().__init__()

self.setupUi(self)


load_icon = QtGui.QIcon()
load_icon.addPixmap(QtGui.QPixmap(":/particle_editor/upload-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.loadButton.setIcon(load_icon)

save_icon = QtGui.QIcon()
save_icon.addPixmap(QtGui.QPixmap(":/particle_editor/download-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.saveButton.setIcon(save_icon)

build_icon = QtGui.QIcon()
build_icon.addPixmap(QtGui.QPixmap(":/particle_editor/hammer-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.buildButton.setIcon(build_icon)

scatter_icon = QtGui.QIcon()
scatter_icon.addPixmap(QtGui.QPixmap(":/particle_editor/scatter-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.scatterButton.setIcon(scatter_icon)
Loading

0 comments on commit bddcc9d

Please sign in to comment.