Skip to content

Commit 71e4ce3

Browse files
Small fixes (#83)
* Updated build_docs.py - Enhanced docstrings - Added debug info * Added pypicosdk/ to mkdocs watchlist * Fixed get_all_enumerated_units. - Now won't raise error when a scope is disconnected * Added example to convert_time_axis()
1 parent 1ef994a commit 71e4ce3

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

build-tools/build_docs.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
raise FileNotFoundError('docs/ does not exist in this directory')
1414

1515
ref_dir = 'docs/docs/ref/'
16-
copy_dir = 'psospa'
16+
copy_dir = 'psospa' # Main copy dir (truth source)
17+
18+
# Paste directory list with an exclude for certain files
1719
paste_dir_list = [
18-
'ps6000a'
20+
{'name': 'ps6000a', 'exclude': ['led.md',]}
1921
]
2022

23+
# List of files to copy from copy_dir to paste_dir
2124
file_list = [
25+
# 'init.md', Do not include init.md
2226
'buffers.md',
2327
'captures.md',
2428
'channel.md',
@@ -30,11 +34,23 @@
3034
'setup.md',
3135
'siggen.md',
3236
'trigger.md',
37+
'led.md',
3338
]
3439

35-
for paste_dir in paste_dir_list:
40+
# Report any files that aren't included for info
41+
all_files = os.listdir(os.path.join(ref_dir, copy_dir))
42+
missing_files = [f for f in all_files if f not in file_list]
43+
print('Files not included in copy:', missing_files)
44+
45+
# Copy each file to each paste_dir
46+
for paste_dir_dict in paste_dir_list:
47+
paste_dir = paste_dir_dict['name']
48+
exclude_list = paste_dir_dict['exclude']
3649
for f in file_list:
50+
if f in exclude_list:
51+
continue
3752
copy_fp = os.path.join(ref_dir, copy_dir, f)
3853
paste_fp = os.path.join(ref_dir, paste_dir, f)
54+
print(f'Copying {f} to {paste_fp}')
3955
with open(copy_fp) as f: text = f.read()
4056
with open(paste_fp, 'w') as f: f.write(text.replace(copy_dir, paste_dir))

docs/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ nav:
4242
- Current Support: dev/current.md
4343
- Upcoming Roadmap: dev/roadmap.md
4444

45+
watch:
46+
- '../pypicosdk'
4547

4648
plugins:
4749
- include-markdown

pypicosdk/pypicosdk.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@
1515
)
1616

1717
def get_all_enumerated_units() -> tuple[int, list[str]]:
18-
"""Enumerate all supported PicoScope units."""
18+
"""Enumerate all supported PicoScope units.
19+
20+
Returns:
21+
Tuple containing number of units and a list of unit serials.
22+
23+
Examples:
24+
>>> from pypicosdk import get_all_enumerated_units
25+
>>> n_units, unit_list = get_all_enumerated_units()
26+
>>> print(n_units, unit_list)
27+
"""
1928
n_units = 0
2029
unit_serial: list[str] = []
2130
for scope in [ps6000a(), psospa()]:
22-
units = scope.get_enumerated_units()
31+
try:
32+
units = scope.get_enumerated_units()
33+
except PicoSDKException:
34+
continue
2335
n_units += units[0]
2436
unit_serial += units[1].split(',')
2537
return n_units, unit_serial
@@ -79,6 +91,10 @@ def convert_time_axis(
7991
Returns:
8092
A tuple containing the new NumPy array scaled to the target units,
8193
and a string representing the target units.
94+
95+
Examples:
96+
>>> from pypicosdk import convert_time_axis
97+
>>> new_time_axis = convert_time_axis(old_time_axis, 'ns', 'ms')
8298
"""
8399
diff = time_standard_form_m[convert_units] - time_standard_form_m[current_units]
84100
time_axis = np.multiply(time_axis, 10**diff)

0 commit comments

Comments
 (0)