Skip to content

Commit

Permalink
black formatting using latest black
Browse files Browse the repository at this point in the history
  • Loading branch information
Cathyhjj committed Apr 29, 2024
1 parent 3f62861 commit 5520e38
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 37 deletions.
4 changes: 3 additions & 1 deletion src/firefly/area_detector_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@


class AreaDetectorViewerDisplay(display.FireflyDisplay):
caqtdm_ui_file: str = "/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADAravis/aravisApp/op/ui/autoconvert/ADAravis.ui"
caqtdm_ui_file: str = (
"/APSshare/epics/synApps_6_2_1/support/areaDetector-R3-12-1/ADAravis/aravisApp/op/ui/autoconvert/ADAravis.ui"
)
image_is_new: bool = True

def customize_device(self):
Expand Down
8 changes: 6 additions & 2 deletions src/firefly/ion_chamber.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class IonChamberDisplay(display.FireflyDisplay):
"""A GUI window for changing settings in an ion chamber."""

caqtdm_scaler_ui_file: str = "/net/s25data/xorApps/ui/scaler32_full_offset.ui"
caqtdm_mcs_ui_file: str = "/APSshare/epics/synApps_6_2_1/support/mca-R7-9//mcaApp/op/ui/autoconvert/SIS38XX.ui"
caqtdm_preamp_ui_file: str = "/net/s25data/xorApps/epics/synApps_6_2_1/support/ip-GIT/ipApp/op/ui/autoconvert/SR570.ui"
caqtdm_mcs_ui_file: str = (
"/APSshare/epics/synApps_6_2_1/support/mca-R7-9//mcaApp/op/ui/autoconvert/SIS38XX.ui"
)
caqtdm_preamp_ui_file: str = (
"/net/s25data/xorApps/epics/synApps_6_2_1/support/ip-GIT/ipApp/op/ui/autoconvert/SR570.ui"
)

def customize_device(self):
self._device = registry.find(self.macros()["IC"])
Expand Down
20 changes: 11 additions & 9 deletions src/firefly/plans/xafs_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ def update_wavenumber_energy(self):

# Define conversion functions
conversion_funcs = {
self.step_line_edit: E_step_to_k_step
if is_k_checked
else lambda x, y: k_step_to_E_step_round(x, y),
self.start_line_edit: energy_to_wavenumber
if is_k_checked
else wavenumber_to_energy_round,
self.stop_line_edit: energy_to_wavenumber
if is_k_checked
else wavenumber_to_energy_round,
self.step_line_edit: (
E_step_to_k_step
if is_k_checked
else lambda x, y: k_step_to_E_step_round(x, y)
),
self.start_line_edit: (
energy_to_wavenumber if is_k_checked else wavenumber_to_energy_round
),
self.stop_line_edit: (
energy_to_wavenumber if is_k_checked else wavenumber_to_energy_round
),
}

# Iterate over line edits and apply corresponding conversion
Expand Down
23 changes: 19 additions & 4 deletions src/firefly/tests/test_run_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from firefly.run_client import DatabaseWorker

# pytest.skip("Need to migrate the module to gemviz fork", allow_module_level=True)
pytest.skip(
"There's some segmentation fault here that needs to be fixed",
allow_module_level=True,
)
# pytest.skip(
# "There's some segmentation fault here that needs to be fixed",
# allow_module_level=True,
# )


@pytest.fixture()
Expand All @@ -36,19 +36,22 @@ def display(affapp, catalog):
assert all(task.done() for task in pending), "Shutdown tasks not complete."


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
def test_run_viewer_action(ffapp, monkeypatch):
monkeypatch.setattr(ffapp, "create_window", MagicMock())
assert hasattr(ffapp, "show_run_browser_action")
ffapp.show_run_browser_action.trigger()
assert isinstance(ffapp.windows["run_browser"], MagicMock)


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_load_runs(display):
assert display.runs_model.rowCount() > 0
assert display.ui.runs_total_label.text() == str(display.runs_model.rowCount())


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_update_selected_runs(display):
# Change the proposal item
Expand All @@ -62,6 +65,7 @@ async def test_update_selected_runs(display):
assert len(display.db.selected_runs) > 0


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_metadata(display):
# Change the proposal item
Expand All @@ -73,6 +77,7 @@ async def test_metadata(display):
assert "xafs_scan" in text


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_1d_plot_signals(catalog, display):
# Check that the 1D plot was created
Expand All @@ -95,6 +100,7 @@ async def test_1d_plot_signals(catalog, display):
), f"energy_energy signal not in {combobox.objectName()}."


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_1d_plot_signal_memory(catalog, display):
"""Do we remember the signals that were previously selected."""
Expand All @@ -116,6 +122,7 @@ async def test_1d_plot_signal_memory(catalog, display):
assert cb.currentText() == "energy_id_energy_readback"


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_1d_hinted_signals(catalog, display, ffapp):
display.ui.plot_1d_hints_checkbox.setChecked(True)
Expand All @@ -138,6 +145,7 @@ async def test_1d_hinted_signals(catalog, display, ffapp):
), f"unhinted signal found in {combobox.objectName()}."


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_update_1d_plot(catalog, display, ffapp):
# Set up some fake data
Expand Down Expand Up @@ -171,6 +179,7 @@ async def test_update_1d_plot(catalog, display, ffapp):
np.testing.assert_almost_equal(ydata, expected_ydata)


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_2d_plot_signals(catalog, display):
# Check that the 1D plot was created
Expand All @@ -186,6 +195,7 @@ async def test_2d_plot_signals(catalog, display):
assert combobox.findText("It_net_counts") > -1


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_update_2d_plot(catalog, display):
display.plot_2d_item.setRect = MagicMock()
Expand Down Expand Up @@ -217,6 +227,7 @@ async def test_update_2d_plot(catalog, display):
display.plot_2d_item.setRect.assert_called_with(-100, -80, 200, 160)


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_update_multi_plot(catalog, display):
run = await catalog["7d1daf1d-60c7-4aa7-a668-d1cd97e5335f"]
Expand All @@ -237,6 +248,7 @@ async def test_update_multi_plot(catalog, display):
# np.testing.assert_almost_equal(ydata, expected_ydata)


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_filter_runs(catalog):
worker = DatabaseWorker(catalog=catalog)
Expand All @@ -245,6 +257,7 @@ async def test_filter_runs(catalog):
assert len(runs) == 1


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_distinct_fields(catalog, display):
worker = DatabaseWorker(catalog=catalog)
Expand All @@ -254,6 +267,7 @@ async def test_distinct_fields(catalog, display):
assert key in distinct_fields.keys()


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_db_task(display):
async def test_coro():
Expand All @@ -263,6 +277,7 @@ async def test_coro():
assert result == 15


@pytest.mark.skip(reason="There's some segmentation fault here that needs to be fixed")
@pytest.mark.asyncio
async def test_db_task_interruption(display, event_loop):
async def test_coro(sleep_time):
Expand Down
4 changes: 3 additions & 1 deletion src/firefly/tests/test_xafs_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ def test_xafs_scan_plan_queued_energies_k_mixed(ffapp, qtbot):
707.04,
] # k values obtained from Athena software to double confirm ours
)
exposures = np.array([1, 1, 1, 1, 1, 1, 1, 1, 5.665, 14.141]) # k exposures kmin 3.62263
exposures = np.array(
[1, 1, 1, 1, 1, 1, 1, 1, 5.665, 14.141]
) # k exposures kmin 3.62263
# set up meta data
display.ui.lineEdit_sample.setText("sam")
display.ui.lineEdit_purpose.setText("test")
Expand Down
4 changes: 3 additions & 1 deletion src/firefly/voltmeters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
class VoltmetersDisplay(display.FireflyDisplay):
_ion_chamber_displays = []
caqtdm_scaler_ui_file: str = "/net/s25data/xorApps/ui/scaler32_full_offset.ui"
caqtdm_mcs_ui_file: str = "/APSshare/epics/synApps_6_2_1/support/mca-R7-9//mcaApp/op/ui/autoconvert/SIS38XX.ui"
caqtdm_mcs_ui_file: str = (
"/APSshare/epics/synApps_6_2_1/support/mca-R7-9//mcaApp/op/ui/autoconvert/SIS38XX.ui"
)

def __init__(
self,
Expand Down
3 changes: 1 addition & 2 deletions src/haven/energy_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def full_range(start, end, step):

@dataclass
class ERange(EnergyRange):

"""A range of energies used for scanning.
All values are assumed to be in electron-volts. If *E0* is a
Expand Down Expand Up @@ -141,7 +140,7 @@ def wavenumbers(self):

def exposures(self):
ks = self.wavenumbers()
return self.exposure * (ks / np.min(ks)) ** self.k_weight
return self.exposure * ((ks / np.min(ks)) ** self.k_weight)


def merge_ranges(*ranges, default_exposure=DEFAULT_EXPOSURE, sort=False):
Expand Down
3 changes: 1 addition & 2 deletions src/haven/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class SignalNotFound(KeyError):
...


class EmptySignalName(ValueError):
...
class EmptySignalName(ValueError): ...


class InvalidTransformation(TypeError):
Expand Down
15 changes: 5 additions & 10 deletions src/haven/instrument/area_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ class AsyncCamMixin(OphydObject):
acquire = ADCpt(SignalWithRBV, "Acquire")


class SimDetectorCam_V34(CamMixin_V34, SimDetectorCam):
...
class SimDetectorCam_V34(CamMixin_V34, SimDetectorCam): ...


class EigerCam(AsyncCamMixin, EigerDetectorCam):
...
class EigerCam(AsyncCamMixin, EigerDetectorCam): ...


class LambdaCam(AsyncCamMixin, Lambda750kCam):
...
class LambdaCam(AsyncCamMixin, Lambda750kCam): ...


class WriteModes(IntEnum):
Expand Down Expand Up @@ -137,12 +134,10 @@ class StatsMixin:
]


class StatsPlugin_V31(StatsMixin, OphydStatsPlugin_V31):
...
class StatsPlugin_V31(StatsMixin, OphydStatsPlugin_V31): ...


class StatsPlugin_V34(StatsMixin, OphydStatsPlugin_V34):
...
class StatsPlugin_V34(StatsMixin, OphydStatsPlugin_V34): ...


class SimDetector(SingleTrigger_V34, DetectorBase):
Expand Down
6 changes: 2 additions & 4 deletions src/haven/instrument/scaler_triggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ def _trigger_scaler(self, *args, **kwargs):
return new_status


class ScalerSignal(ScalerTriggered, EpicsSignal):
...
class ScalerSignal(ScalerTriggered, EpicsSignal): ...


class ScalerSignalRO(ScalerTriggered, EpicsSignalRO):
...
class ScalerSignalRO(ScalerTriggered, EpicsSignalRO): ...


# -----------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/haven/plans/energy_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def energy_scan(
energy_signals = [registry.find(ep) for ep in energy_signals]
# Figure out which time positioners to use
if time_signals is None:
time_signals = [det.default_time_signal for det in detectors if hasattr(det, 'default_time_signal')]
time_signals = [
det.default_time_signal
for det in detectors
if hasattr(det, "default_time_signal")
]
else:
time_signals = [registry.find(tp) for tp in time_signals]
# Convert an individual exposure time to an array of exposure times
Expand Down

0 comments on commit 5520e38

Please sign in to comment.