Skip to content

PyPalmSens 1.5.0

Choose a tag to compare

@stefsmeets stefsmeets released this 19 Dec 15:00
8fdf6e8

PyPalmSens 1.5.0 is now available on PyPi.

To upgrade pip install pypalmsens -U.

Validation

This release brings improvements to how the methods are defined. We migrated to Pydantic to define methods. Pydantic offers automatic runtime validations against the type specification. This makes it more robust for user facing configs.

All values set on the methods are automatically validated, and converted to the correct type where possible. This protects against mistakes and typos.

For example:

>>> cv = ps.CyclicVoltammetry(scanraet=2.0)
scanraet
  Extra inputs are not permitted [type=extra_forbidden, input_value=1.0, input_type=float]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden

For more examples, see the documentation.

Specifying current / potential ranges

We also changed how current and potential ranges are defined. From this release onwards, current ranges should be specified as strings. This means less typing, and makes the code more readable.

So instead of using:

cv = ps.CyclicVoltammetry(
    current_range=ps.settings.CurrentRange(
        min=ps.settings.CURRENT_RANGE.cr_1_uA,
        max=ps.settings.CURRENT_RANGE.cr_10_mA,
    )
)

You can pass the current range directly as a dictionary of strings:

cv = ps.CyclicVoltammetry(current_range={'min': '1uA', 'max': '10mA'})

A list of allowed values is available via

Thanks to how the methods are validated, a warning will be raised if an incorrect value is passed:

>>> ps.CyclicVoltammetry(current_range={'start':'fail'})
ValidationError: 1 validation error for CyclicVoltammetry
current_range.start
  Input should be '100pA', '1nA', '10nA', '100nA', '1uA', '10uA', '100uA', '1mA', '10mA', '100mA', '2uA', '4uA', '8uA', '16uA', '32uA', '63uA', '125uA', '250uA', '500uA', '5mA', '6uA', '13uA', '25uA', '50uA', '200uA' or '1A' [type=literal_error, input_value='fail', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/literal_error

What's Changed

Full Changelog: python-1.4.0...python-1.5.0