Skip to content

Remove the pylab star import and check shared triggers of secondary pseudoclocks - #130

Merged
chrisjbillington merged 2 commits into
masterfrom
pylab-import-and-shared-triggers
Oct 23, 2026
Merged

chrisjbillington merged 2 commits into
masterfrom
pylab-import-and-shared-triggers

Conversation

@chrisjbillington

@chrisjbillington chrisjbillington commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Written by Claude. This pull request and its commits were produced by Claude, the AI model, in a Claude Code session that @chrisjbillington is running for labscript suite maintenance. It is opened from his account; the commits are authored as Claude.

Two changes for the next release, one commit each. Closes #104.

from labscript import * no longer imports all of pylab. labscript.labscript and labscript.functions did from pylab import *, so experiment scripts got every numpy and matplotlib name, and every compilation imported matplotlib. Now they get only labscript's own names. This is a breaking change: a script that uses names such as linspace, array or pi without importing them now needs to import numpy itself. The docs now build with NumPy 2, so the numpy<2 pin on the docs extra is removed.

Secondary pseudoclocks now get the shared-trigger check. Devices on the same trigger line must have identical triggers, but this was never checked for secondary pseudoclocks, because PseudoclockDevice.do_checks() overrides the check without calling it. Now it calls it. For example, two pseudoclocks on the same trigger line with different initial trigger times now fail to compile, with an error that names both.

Testing: A shot that uses every ramp function compiles to identical output with and without this change. None of the other labscript-suite packages use pylab names from from labscript import *. The docs build with NumPy 2.5.4. Two PineBlasters on one trigger line compile as before, and fail with the new error when one of them is given a different initial trigger time. An end-to-end test that installs the suite, compiles the example experiment, loads the shot in lyse and runviewer, and starts BLACS, runmanager, runviewer and lyse passed on Ubuntu and Windows for Python 3.11 to 3.14 with PySide6, PyQt6 and PyQt5 (run 39119010476).

🤖 Generated with Claude Code

…unctions (#104)

`from labscript import *` re-exported every name of `from pylab import *`, so
experiment scripts received numpy and matplotlib names from labscript, and every
compilation imported matplotlib. The star import is removed from both modules,
which now use `np.` for the numpy functions they call. Scripts that relied on
those names must import numpy themselves.

The docs extra no longer pins numpy<2, which was needed because the star import
shadowed the `labscript.core` submodule with `numpy.core`. The intermediate
device example in the developer docs imports numpy explicitly.

Verified by compiling a shot with every analog ramp function (ramp, sine,
sine_ramp, sine4_ramp, sine4_reverse_ramp, exp_ramp, exp_ramp_t,
piecewise_accel_ramp, square_wave) on master and on this branch: the output
tables, the pulse program and the connection table are identical, and
`linspace` is no longer in the labscript namespace. The documentation builds
with Sphinx 8.2.3 and NumPy 2.5.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1BcGgwHXD3Lcx1FgWYwee
TriggerableDevice.do_checks() checks that all devices on one trigger line
have identical triggers. PseudoclockDevice overrides do_checks() with a
different signature and did not call it, so the check never ran for
secondary pseudoclocks. PseudoclockDevice.do_checks() now calls it before
checking the outputs.

A secondary pseudoclock that shares its trigger line with another device
whose triggers differ, for example a second pseudoclock with a different
initial trigger time, now fails to compile with a LabscriptError naming
both devices.

Verified with two PineBlasters triggered by one digital output of a
DummyIntermediateDevice: with identical triggers the shot compiles on master
and on this branch; with set_initial_trigger_time() on one of them it
compiles on master and fails on this branch with the shared-trigger error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1BcGgwHXD3Lcx1FgWYwee
@chrisjbillington
chrisjbillington merged commit c8441c1 into master Oct 23, 2026
1 check passed
@chrisjbillington
chrisjbillington deleted the pylab-import-and-shared-triggers branch October 26, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove pylab star import in labscript.labscript

2 participants