Skip to content

Commit 7a51c6d

Browse files
Added a violation fix for adc conversion of channel buffers (#166)
* Refactor _adc_to_ method in PicoScopeBase (base.py) to improve buffer handling * Renamed parameter 'data' to 'buffer' for clarity. * Enhanced buffer processing to handle both channel_buffer dictionaries and single values. * Updated conversion logic to ensure consistent output for different input types. * Upversioned to 1.6.5
1 parent 18a6cf4 commit 7a51c6d

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ Current PicoScope support:
6969
- [pypi-nightly (dev repo)](https://pypi.org/project/pypicosdk-nightly/)
7070

7171
## Version Control
72-
pyPicoSDK: 1.6.4
72+
pyPicoSDK: 1.6.5
7373

7474
Docs: 0.4.1

pypi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ Current PicoScope support:
6666
- [pypi-nightly (dev repo)](https://pypi.org/project/pypicosdk-nightly/)
6767

6868
## Version Control
69-
pyPicoSDK: 1.6.4
69+
pyPicoSDK: 1.6.5
7070

7171
Docs: 0.4.1

pypicosdk/base.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def _adc_conversion(
916916

917917
def _adc_to_(
918918
self,
919-
data: dict | int | np.ndarray,
919+
buffer: dict | int | np.ndarray,
920920
channel: int | CHANNEL | str | channel_literal = None,
921921
unit: OutputUnitV_L = 'mv',
922922
) -> dict | float | np.ndarray:
@@ -939,14 +939,18 @@ def _adc_to_(
939939
# Update last used
940940
self.last_used_volt_unit = unit
941941

942-
if isinstance(data, dict):
943-
for channel, adc in data.items():
944-
data[channel] = self._adc_conversion(adc, channel, output_unit=unit)
942+
# If buffer is a channel_buffer dictionary
943+
if isinstance(buffer, dict):
944+
# Convert each buffer per channel and update to dictionary
945+
buffer = {channel: self._adc_conversion(adc, channel, output_unit=unit) \
946+
for channel, adc in buffer.items()}
945947
else:
948+
# If channel is a string, treat as a single value (int or ndarray)
946949
if isinstance(channel, str):
947950
channel = _get_literal(channel, channel_map)
948-
data = self._adc_conversion(data, channel, output_unit=unit)
949-
return data
951+
buffer = self._adc_conversion(buffer, channel, output_unit=unit)
952+
# Return the converted buffer
953+
return buffer
950954

951955
def adc_to_mv(
952956
self,

pypicosdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Copyright (C) 2025-2025 Pico Technology Ltd. See LICENSE file for terms."""
2-
VERSION = "1.6.4"
2+
VERSION = "1.6.5"

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Master version file for all scripts.
33
# Update these variables first then run `python build-tools\version_updater.py`
44
docs_version = "0.4.1"
5-
package_version = "1.6.4"
5+
package_version = "1.6.5"

0 commit comments

Comments
 (0)