Recent Releases of puzzlepiece
puzzlepiece - v0.12.1
New features:
* You can now omit self in param setter/getter and action definitions. Since these are created in the define_params(self) method of a Piece, self already exists in the namespace. For example:
python
def define_params(self):
@pzp.param.readout(self, "digit")
def digit():
return np.random.randint(0, 10)
* Param setter and getters now get unique code object names, meaning that they show up correctly when profiling.
* Thread upgrades: set_value and get_value are now threadsafe (no promises about user-defined setters and getters though!). Threaded versions of the methods are available, and can be invoked by ctrl+clicking the corresponding GUI buttons (or pressing ctrl+enter) to avoid freezing the GUI. Care should be taken with this though, as setting a value multiple times before the operation finishes can confuse hardware for example.
* Actions can now return values when called.
* The global STOP is now called on exit to help your Pieces wind down gracefully.
* Keyboard shortcuts for actions now work while focus in Popup, and new Popup.close() method added.
* New logo! Plus a Q&A section in the documentation.
Fixes:
* The Puzzle and Popups Qt objects are now marked for deletion when closed, avoiding any memory leaks or objects lingering when not expected to.
* ParamSlider no longer emits the changed Signal twice when set_value is used.
* ParamArray spinner now updates correctly for different getter/setter combinations.
* self.folder now set for Pieces before define_params/define_actions
* Assorted fixes to get readthedocs to build again
- Python
Published by jdranczewski over 1 year ago
puzzlepiece - v0.12.0
Superseded by v0.12.1, see above.
- Python
Published by jdranczewski over 1 year ago
puzzlepiece - v0.11.0
Added a tutorial! Check it out at https://puzzlepiece.readthedocs.io/en/stable/tutorial.html
New features:
* Puzzles can be indexed in additional ways as a shortcut - you can now directly say puzzle["piece:param"] to get a param. This also autocompletes in IPython.
* Child params and actions - use Popup.make_child_params to easily create settings popups that modify hidden params.
* replace_piece - an experimental method to update a Piece in place.
* done_signal for the LiveWorker emitted when it finishes.
* new extra module: ipython_shims adds two convenient magics: %%pzp_script and %%safe_run
* Improvements to DataGrids, including support for custom Rows in add_row and Popups for the Rows.
* Ability to set a Popup's title.
Fixes:
* call_stop stops threads too.
* reduced reliance on Qt spreadsheets - param changes should always indicate correctly with a red background now.
- Python
Published by jdranczewski over 1 year ago
puzzlepiece - v0.10.0 - DataGrids, sliders, shortcuts, fixes
New shortcuts: * The QApp and Puzzle name arguments are no longer required when creating a Puzzle. The QApp still needs to be created in non-IPython contexts, but it can now be inferred by the Piece. * You can directly accesss a Piece's params by indexing it like a dictionary: ```python puzzle["piece"]["param_name"]
is now equivalent to
puzzle["piece"].params["param_name"] ```
New features:
* A slider parameter type - displays a slider and a value label. Min and max values, as well as the step size, are defined on creation.
* First extra submodule - DataGrids allow for storing and interacting with data using the param abstractions in a table format. Can be added to a Piece's custom_layout to enable new data manipulation tasks.
Fixes and enhancements:
* addpiece now returns the Piece instance (useful if a class is being passed for instantiation)
* `vstepargument when creating spinboxes changes the step of the box's buttons.
* Popups now close when the Puzzle is closed.
* Default param values are cast to the right type on creation.
* IPython exception handler is now inserted correctly even ifpuzzle.process_events()` is called in the cell that creates the Puzzle.
* Pieces can now be instantiated without a parent Puzzle. This allows for using the Piece as a standalone Widget in an environment where only one Piece is needed, or a Puzzle cannot be set up, but is in general not advised.
* Option to hide the bottom buttons of a Puzzle (Tree, Export, STOP)
* All code has been re-formatted using ruff.
- Python
Published by jdranczewski about 2 years ago
puzzlepiece - v0.9.0 - Popups, progress bars, IPython exceptions, fixes
Popups are now available as a convenient way to create a modal window attached to the main Puzzle. Can be used for calibration processes, further settings, or just in general GUI that you don't want cluttering a Piece. See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.Popup for details.
Progress bar params give you a standard way to indicate progress, with tqdm-like iterable wrapping capability:
python
for i in piece.params['progress'].iter(range(10)):
print(i)
# this will automatically update the progress bar as the iteration goes on
puzzle.process_events() # you may need to refresh the Puzzle to display changes
Exceptions that arise when running in IPython and interacting with the GUI will now display an error dialog just like when running in non-interactive Python. Exceptions that arise during cell execution will still produce a traceback in the Notebook, as before.
Small fixes: all threads now stop when an exception is raised, and a getter result will be cast to the param's type if obtained during a set_value call (that is if the setter doesn't return a value and a getter is present).
See pull request https://github.com/jdranczewski/puzzlepiece/pull/2 for full changes
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - set_value and set_partial updates
set_value() now returns the new value, as it may be different than the one being set if the setter returns a value or a getter is defined.
ParamArray has a new property set_partial which allows you to set values to slices of the stored numpy array. This calls the setter of the param.
python
puzzle['piece'].params['image'].set_partial[100:200, :] = 128
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Convenient shortcuts
You can now access the QApplication class as puzzlepiece.QApp, and pass Piece classes to add_piece instead of instantiating them first - this will reduce the clutter when building applications, and bring the minimum viable app to this neater form:
```python import puzzlepiece as pzp from puzzlepiece.pieces import random_number
app = pzp.QApp([]) puzzle = pzp.Puzzle(app, "Basic example") puzzle.addpiece("random", randomnumber.Piece, 0, 0) puzzle.show() app.exec() ```
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Ensurers - capture_exception
Small amendment to v0.6.0: ensurers can now capture the exception when called directly, so they can be used in if statements easily.
```python
This will not raise an Exception is the check fails
if self.ensureconnected(capture_exception=True): print("laser is connected!") ```
Original v0.6.0 changelog follows:
An ensurer is a decorator that can be placed on getters, setters, and actions, and it will run ahead of these functions. The intended behaviour is performing checks ahead of running the function - for example checking if a laser is connected ahead of trying to set its power. This way one ensurer can be written and used in multiple places easily.
See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.ensurer for examples
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Ensurers
An ensurer is a decorator that can be placed on getters, setters, and actions, and it will run ahead of these functions. The intended behaviour is performing checks ahead of running the function - for example checking if a laser is connected ahead of trying to set its power. This way one ensurer can be written and used in multiple places easily.
See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.piece.html#puzzlepiece.piece.ensurer for examples
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Globals - variable management
It's now easier for multiple Pieces to share a device SDK with each other - they can put a hold on it in puzzle.globals and release it when done, only setting up and closing the SDK once for all Pieces.
See https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.puzzle.html#puzzlepiece.puzzle.Globals for examples
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Array and Dropdown params
Array params let you properly communicate more complex data, like images or spectra, through the unified puzzlepiece API. They use numpy arrays as the data format.
Dropdown params can be populated with default values at startup and make it much easier to select device serial numbers.
The setup method of a Piece is now called ahead of param definition, so that dropdown params can use a device SDK to search for available devices.
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - Revamp params
The previous design of how params handled being set programmatically and from input fields mostly worked, but was rather convoluted, and limited the precision of the stored value to the display precision, which is very silly.
The back-end way params work and the associated signalling has thus been reworked, and new tests were introduced to test for correctness of the new behaviour.
See https://github.com/jdranczewski/puzzlepiece/commit/af352443ceb9f10afc556b706d7af7e4d208b597 for the exact changes, but most of the behaviour should be unchanged. Most notably:
- params no longer have limited precision, should go as precise as float allows
- the
changedSignal is now emitted every timeset_valueis called, even if the value didn't necessarily change - if implementing custom params,
_input_set_valueshould block any Signals emitted by changing the input using this method. This can be achieved usingself.input.blockSignals(True)andself.input.blockSignals(False)
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - 0.2.0 Threaded Workers
This update introduces an official way to handle threaded jobs to the library with Workers and LiveWorkers! For implementation details see https://puzzlepiece.readthedocs.io/en/latest/puzzlepiece.threads.html and for an example of how to use the new PuzzleTimer and the returned Signal, see https://github.com/jdranczewski/puzzlepiece/blob/v0.2.0/puzzlepiece/pieces/plotter.py
Some convenience functions were also added to the Puzzle object, see https://github.com/jdranczewski/puzzlepiece/commit/7319dbdbf521be4e3eadaae20dd253e23856c731
- Python
Published by jdranczewski over 2 years ago
puzzlepiece - 0.1.0 PyPI Alpha
The package can now be installed from PyPI:
pip install puzzlepiece
- Python
Published by jdranczewski over 2 years ago