PyPalmSens 1.5.0
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_forbiddenFor 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_errorWhat's Changed
- Forbid extra keys in structure by @stefsmeets in #201
- Improve firmware warning by @stefsmeets in #202
- Add regression test for aux input by @stefsmeets in #205
- Add validation to method classes by @stefsmeets in #210
- Use literal strings for config objects by @stefsmeets in #206
Full Changelog: python-1.4.0...python-1.5.0