Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class based properties #242

Open
wants to merge 35 commits into
base: version1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b84bbd9
feature(drivers): Changing driver syntax to have separate Driver and …
ammounce Oct 8, 2024
399ec75
feature: abstract driver and propertysettings
ammounce Oct 11, 2024
f340bae
changed settings to settings_dict and settings_obj
ammounce Oct 16, 2024
6031db7
"drivers: Changed values driver property setting to values_list, to n…
ammounce Oct 24, 2024
14fb411
Reverted back to 'values' from 'values_list'
ammounce Oct 28, 2024
fa3c97a
added updated class based properties
ammounce Oct 28, 2024
281ce75
ignoring .vscode
ammounce Oct 28, 2024
6d8f12c
Autotesting instrument driver works
ammounce Oct 28, 2024
ac18061
Full pytest suite now works
ammounce Oct 28, 2024
3b06014
Merge branch 'main' into class_based_properties
ammounce Oct 28, 2024
ec6b186
re-fixed driver imports
ammounce Oct 28, 2024
9a2e158
changed ms to expt in test_abstract_experiment
ammounce Oct 28, 2024
1bdf9df
Fixed read only by adding ReadOnlyPropertySetting and requiring read_…
ammounce Oct 28, 2024
5350b4c
fix(drivers): fixed stanford830 and keithley 2260b to comply with new…
Oct 29, 2024
b08095b
test(test_station): updated testing notebooks and created real_experi…
Oct 29, 2024
8f2334b
fix(): missed real_experiment save
Oct 29, 2024
d6b2e7f
syntax: fixed flake8 errors
ammounce Oct 29, 2024
a4718e9
reworked class based properties to actually have class based properties
ammounce Oct 30, 2024
10ccbbf
Merge branch 'main' into class_based_properties
ammounce Oct 30, 2024
1b115c3
test(driver): fixed stanford860 driver for new class based properties
ammounce Oct 30, 2024
543f971
Update __init__.py
i-am-mounce Oct 31, 2024
f36af4b
test: targeted only the ./test folder for pytest
ammounce Oct 31, 2024
f723504
fix(driver): doc string if not found returns blank. If multiple, tak…
ammounce Nov 4, 2024
1a1cc07
Start of newly formatted tlk drivers
Nov 4, 2024
f6871b8
Merge branch 'main' into fix_driver_docstring
i-am-mounce Nov 5, 2024
0f5f5bb
Merge branch 'main' into class_based_properties
i-am-mounce Nov 5, 2024
bde9275
Revert "Start of newly formatted tlk drivers"
ammounce Nov 5, 2024
c25e54c
revert(): accidentally added thorlabs changes
ammounce Nov 5, 2024
d5d4312
Changed thorlabs import back
ammounce Nov 5, 2024
c088912
fix(driver): fixing sr860 for new property based drivers
Nov 5, 2024
518aea4
Merge remote-tracking branch 'origin/fix_driver_docstring' into class…
Nov 5, 2024
7fb975a
test(): fixed autotesting for stanford and keithley
Nov 5, 2024
5c45047
git status
Nov 5, 2024
614cf7f
Merge branch 'version1' into class_based_properties
i-am-mounce Jan 7, 2025
54eba3b
fix(references): fixed references to itemattribute and get_pyscan_ver…
i-am-mounce Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Test with pytest
run: |
pytest
pytest ./test

- name: Test notebooks
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test_station.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ jobs:

- name: Test notebooks
run: |
python -m pytest --nbmake ./drivers_test_notebooks/srs830_test_notebook.ipynb
python -m pytest --nbmake ./drivers_test_notebooks/stanford830.ipynb
python -m pytest --nbmake ./drivers_test_notebooks/keithley2260b.ipynb
python -m pytest --nbmake ./drivers_test_notebooks/real_experiment.ipynb


# - name: Archive test results
# uses: actions/upload-artifact@v4
# with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ dmypy.json
backup
.backup
*.backup
test.ipynb
test.ipynb
.vscode
345 changes: 0 additions & 345 deletions drivers_test_notebooks/demo_test_notebook.ipynb

This file was deleted.

340 changes: 340 additions & 0 deletions drivers_test_notebooks/keithley2260b.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"metadata": {}
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"import pyscan as ps\n",
"from pyscan.drivers.testing.auto_test_driver_properties import auto_test_driver_properties\n",
"from pyvisa import ResourceManager, VisaIOError"
]
},
{
"cell_type": "markdown",
"metadata": {
"metadata": {}
},
"source": [
"# Connect device"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"metadata": {}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ASRL3::INSTR Keithley Instruments Inc.,Model 2260B-80-27,1403238,01.72.20150702\n",
"\n"
]
}
],
"source": [
"rm = ResourceManager()\n",
"\n",
"rs = rm.list_resources()\n",
"# print(rs)\n",
"for r in rs:\n",
" res = rm.open_resource(r)\n",
" try: \n",
" name = res.query('*IDN?')\n",
" if 'Keithley Instruments Inc.,Model 2260B' in name:\n",
" print(r, name)\n",
" break\n",
" except VisaIOError:\n",
" pass\n",
" res.close()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"isource = ps.Keithley2260B(res)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test Properties"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"metadata": {}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"current\n",
"voltage\n",
"Initial state for the Keithley2260B was: \n",
"{'current': 0.0,\n",
" 'current_falling_slew_rate': 0.01,\n",
" 'current_protection_state': 'off',\n",
" 'current_rising_slew_rate': 0.01,\n",
" 'current_trigger_amplitude': 0.0,\n",
" 'output': 'off',\n",
" 'output_mode': 'CVHS',\n",
" 'output_off_delay': 0.0,\n",
" 'output_on_delay': 0.0,\n",
" 'output_trigger_source': 'BUS',\n",
" 'output_trigger_state': 'off',\n",
" 'over_current_level': 29.7,\n",
" 'over_voltage_level': 8.0,\n",
" 'resistance': 0.01,\n",
" 'transient_trigger_source': 'BUS',\n",
" 'voltage': 0.0,\n",
" 'voltage_falling_slew_rate': 0.1,\n",
" 'voltage_rising_slew_rate': 0.1,\n",
" 'voltage_trigger_amplitude': 0.0}\n",
"\n",
"\n",
"\n",
"Beginning tests for: Keithley2260B version 0.1.3\n",
"output_on_delay\n",
"output_off_delay\n",
"output_mode\n",
"output\n",
"output_trigger_state\n",
"current_trigger_amplitude\n",
"over_current_level\n",
"Warning, changing over_current_level changed current_protection_state from off to on\n",
"current_protection_state\n",
"current_rising_slew_rate\n",
"current_falling_slew_rate\n",
"resistance\n",
"voltage_trigger_amplitude\n",
"over_voltage_level\n",
"voltage_rising_slew_rate\n",
"voltage_falling_slew_rate\n",
"transient_trigger_source\n",
"output_trigger_source\n",
"\n",
"11 range properties found and tested out of 17 total settings found.\n",
"2 values properties found and tested out of 17 total settings found.\n",
"4 indexed values properties found and tested out of 17 total settings found.\n",
"0 dict values properties found and tested out of 17 total settings found.\n",
"2 blacklisted settings not testing\n",
"17 properties tested out of 17 total settings.\n",
"\n",
"Settings restored to: \n",
"{'current': 0.0,\n",
" 'current_falling_slew_rate': 0.01,\n",
" 'current_protection_state': 'off',\n",
" 'current_rising_slew_rate': 0.01,\n",
" 'current_trigger_amplitude': 0.0,\n",
" 'output': 'off',\n",
" 'output_mode': 'CVHS',\n",
" 'output_off_delay': 0.0,\n",
" 'output_on_delay': 0.0,\n",
" 'output_trigger_source': 'BUS',\n",
" 'output_trigger_state': 'off',\n",
" 'over_current_level': 29.7,\n",
" 'over_voltage_level': 8.0,\n",
" 'resistance': 0.01,\n",
" 'transient_trigger_source': 'BUS',\n",
" 'voltage': 0.0,\n",
" 'voltage_falling_slew_rate': 0.1,\n",
" 'voltage_rising_slew_rate': 0.1,\n",
" 'voltage_trigger_amplitude': 0.0}\n",
"\u001b[92m Property implementation tests passed, instrument: Keithley2260B. \u001b[0m\n",
"Testing driver doc string.\n",
"\u001b[92m Docstring tests passed. \u001b[0m\n",
"The new test log for this driver is: Passed with keithley2260b version v0.1.3 tested on pyscan version v0.8.5 at 2024-11-05 11:24:08\n",
"\u001b[1;32m Keithley2260B test results logged. \u001b[0m\n"
]
}
],
"source": [
"auto_test_driver_properties(isource)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"metadata": {}
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isource.measure_current()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"metadata": {}
},
"outputs": [],
"source": [
"# voltage is blacklisted for safety, just try 0 voltage\n",
"\n",
"isource.voltage\n",
"isource.voltage = 0"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"metadata": {}
},
"outputs": [],
"source": [
"# current is blacklisted for safety, just try 0\n",
"\n",
"isource.current\n",
"isource.current = 0"
]
},
{
"cell_type": "markdown",
"metadata": {
"metadata": {}
},
"source": [
"# Test methods"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"metadata": {}
},
"outputs": [
{
"data": {
"text/plain": [
"-0.003"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isource.measure_voltage()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"metadata": {}
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isource.measure_power()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"metadata": {}
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isource.measure_current()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Close device"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"metadata": {}
},
"outputs": [],
"source": [
"try:\n",
" del isource\n",
"except: \n",
" pass"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading