Skip to content

Commit 84cc55b

Browse files
some formating fixes
1 parent feb9357 commit 84cc55b

12 files changed

Lines changed: 1032 additions & 1109 deletions

File tree

Delta_mode_Keithley_6221_2182/Backends/Delta_K6221_K2182_L350_T_Sensing_Backend_v1.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def run_combined_measurement():
7979
print("\n--- Measurement Started ---")
8080
print("Press Ctrl+C to stop the measurement.")
8181
print("-" * 70)
82-
header = f"{'Time (s)':<12} | {'Current (A)':<12} | {'Voltage (V)':<15} | {'Resistance (Ohm)':<18} | {'Temperature (K)'}"
82+
header = (
83+
f"{'Time (s)':<12} | {'Current (A)':<12} | {'Voltage (V)':<15} | "
84+
f"{'Resistance (Ohm)':<18} | {'Temperature (K)'}"
85+
)
8386
print(header)
8487
print("-" * len(header))
8588

@@ -99,7 +102,11 @@ def run_combined_measurement():
99102
temperature = float(temperature_str)
100103

101104
# Print to console
102-
print(f"{elapsed_time:<12.2f} | {DELTA_CURRENT:<12.3f} | {voltage:<15.9f} | {resistance:<18.9f} | {temperature:.3f}")
105+
log_msg = (
106+
f"{elapsed_time:<12.2f} | {DELTA_CURRENT:<12.3f} | "
107+
f"{voltage:<15.9f} | {resistance:<18.9f} | {temperature:.3f}"
108+
)
109+
print(log_msg)
103110

104111
# Append to file
105112
with open(OUTPUT_FILENAME, 'a', newline='') as file:

Keithley_2400/Backends/IV_K2400_Loop_Backend_v10.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,22 @@ def IV_Measure(cur):
6969
num_steps = int(I_range / I_step)
7070
for i1 in np.linspace(0, I_range, num_steps + 1):
7171
IV_Measure(i1)
72-
72+
7373
df = pd.DataFrame({'I': current_values, 'V': Volt})
7474
print("\n--- Measurement Complete ---")
7575
print(df)
76-
77-
save_path = os.path.join('C:/Users/Instrument-DSL/Desktop/LED_IV/', f"{filename}.txt")
76+
77+
save_path = os.path.join(
78+
'C:/Users/Instrument-DSL/Desktop/LED_IV/', f"{filename}.txt")
7879
df.to_csv(save_path, index=None, sep='\t', mode='w')
7980
print(f"Data saved to {save_path}")
80-
81+
8182
sleep(0.5)
8283
keithley_2400.shutdown()
8384
print("Keithley 2400 shutdown complete.")
84-
85-
plt.plot(current_values, Volt, marker='o', linestyle='-', color='g', label='I-V Data')
85+
86+
plt.plot(current_values, Volt, marker='o',
87+
linestyle='-', color='g', label='I-V Data')
8688
plt.xlabel('Current (A)')
8789
plt.ylabel('Voltage (V)')
8890
plt.title('I-V Curve')

Keithley_2400_Keithley_2182/IV_K2400_K2182_GUI_v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def shutdown(self):
162162
self.k2182.close()
163163
except BaseException:
164164
pass
165-
print(" Instruments shut down and disconnected.") # type: ignore
165+
print(" Instruments shut down and disconnected.") # type: ignore
166166

167167
# -------------------------------------------------------------------------------
168168
# --- FRONT END (GUI) ---

Keithley_6517B/High_Resistance/Backends/IV_K6517B_L350_T_Control_Backend_v6.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ def main():
319319
keithley = Keithley6517B(KEITHLEY_VISA)
320320
print(f"Successfully connected to: {keithley.id}")
321321
perform_keithley_zero_check(keithley)
322-
323322
keithley.source_voltage = source_voltage
324323
keithley.current_nplc = 1
325324
keithley.enable_source()

Keithley_6517B/High_Resistance/Backends/IV_K6517B_Simple_Backend_v10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def plot_results(data):
102102
print("\nStarting zero correction procedure...")
103103
time.sleep(5)
104104
print("Step 1: Enabling Zero Check mode...")
105-
keithley.write(':SYSTem:ZCHeck ON') # type: ignore
105+
keithley.write(':SYSTem:ZCHeck ON') # type: ignore
106106
time.sleep(5)
107107
print("Step 2: Acquiring zero correction value...")
108108
# keithley.write(':SYSTem:ZCORrect:ACQuire')

Keithley_6517B/High_Resistance/IV_K6517B_GUI_v11.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ def initialize_instruments(self, parameters):
148148

149149
# 1. Enable Zero Check
150150
print(" Step 1/4: Enabling Zero Check mode...")
151-
self.keithley.write(':SYSTem:ZCHeck ON') # type: ignore
151+
self.keithley.write(':SYSTem:ZCHeck ON') # type: ignore
152152
time.sleep(2)
153153

154154
# 2. Acquire the zero measurement
155155
print(" Step 2/4: Acquiring zero correction value...")
156-
self.keithley.write(':SYSTem:ZCORrect:ACQuire') # type: ignore
156+
self.keithley.write(':SYSTem:ZCORrect:ACQuire') # type: ignore
157157
time.sleep(2) # Allow time for acquisition
158158

159159
# 3. Disable Zero Check
160160
print(" Step 3/4: Disabling Zero Check mode...")
161-
self.keithley.write(':SYSTem:ZCHeck OFF') # type: ignore
161+
self.keithley.write(':SYSTem:ZCHeck OFF') # type: ignore
162162
time.sleep(1)
163163

164164
# 4. Enable Zero Correct
165165
print(" Step 4/4: Enabling Zero Correction for all measurements.")
166-
self.keithley.write(':SYSTem:ZCORrect ON') # type: ignore
166+
self.keithley.write(':SYSTem:ZCORrect ON') # type: ignore
167167
time.sleep(1)
168168
print(" Zero Correction Complete.")
169169

@@ -313,9 +313,10 @@ def setup_styles(self):
313313
focusthickness=0,
314314
focuscolor='none')
315315
style.map(
316-
'TButton', background=[
317-
('active', self.CLR_ACCENT_GOLD), ('hover', self.CLR_ACCENT_GOLD)], foreground=[
318-
('active', self.CLR_TEXT_DARK), ('hover', self.CLR_TEXT_DARK)])
316+
'TButton',
317+
background=[('active', self.CLR_ACCENT_GOLD), ('hover', self.CLR_ACCENT_GOLD)],
318+
foreground=[('active', self.CLR_TEXT_DARK), ('hover', self.CLR_TEXT_DARK)]
319+
)
319320
style.configure(
320321
'Start.TButton',
321322
background=self.CLR_ACCENT_GREEN,

Keithley_6517B/Pyroelectricity/Backends/Pyroelectric_K6517B_Working_Backend_v10.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from datetime import datetime
1414
import traceback
1515

16+
1617
def main():
1718
"""
1819
Main function to run the pyroelectric measurement experiment.

Keithley_6517B/Pyroelectricity/Pyroelectric_K6517B_L350_GUI_v4.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,12 @@ def _process_data_queue(self):
848848

849849
elif state == 'ramping':
850850
elapsed_time = time.time() - self.start_time
851-
self.log(
852-
f"Ramping... Time: {elapsed_time:7.1f}s | Temp: {current_temp:8.4f}K | Current: {current_val:.3e} A")
851+
log_msg = (
852+
f"Ramping... Time: {elapsed_time:7.1f}s | "
853+
f"Temp: {current_temp:8.4f}K | "
854+
f"Current: {current_val:.3e} A"
855+
)
856+
self.log(log_msg)
853857

854858
with open(self.data_filepath, 'a', newline='') as f:
855859
f.write(

PICA_v6.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ class PICALauncherApp:
126126
# Based on Updates.md, using the latest versions of scripts.
127127
"Delta Mode I-V Sweep": resource_path("Delta_mode_Keithley_6221_2182/IV_K6221_DC_Sweep_GUI_V10.py"),
128128
"Delta Mode R-T": resource_path("Delta_mode_Keithley_6221_2182/Delta_RT_K6221_K2182_L350_T_Control_GUI_v5.py"),
129-
"Delta Mode R-T (T_Sensing)": resource_path("Delta_mode_Keithley_6221_2182/Delta_RT_K6221_K2182_L350_Sensing_GUI_v5.py"),
129+
"Delta Mode R-T (T_Sensing)": resource_path(
130+
"Delta_mode_Keithley_6221_2182/Delta_RT_K6221_K2182_L350_Sensing_GUI_v5.py"),
130131
"K2400 I-V": resource_path("Keithley_2400/IV_K2400_GUI_v5.py"),
131132
"K2400 R-T": resource_path("Keithley_2400/RT_K2400_L350_T_Control_GUI_v3.py"),
132133
"K2400 R-T (T_Sensing)": resource_path("Keithley_2400/RT_K2400_L350_T_Sensing_GUI_v4.py"),
133134
"K2400_2182 I-V": resource_path("Keithley_2400_Keithley_2182/IV_K2400_K2182_GUI_v3.py"),
134135
"K2400_2182 R-T": resource_path("Keithley_2400_Keithley_2182/RT_K2400_K2182_T_Control_GUI_v3.py"),
135-
"K2400_2182 R-T (T_Sensing)": resource_path("Keithley_2400_Keithley_2182/RT_K2400_2182_L350_T_Sensing_GUI_v2.py"),
136+
"K2400_2182 R-T (T_Sensing)": resource_path(
137+
"Keithley_2400_Keithley_2182/RT_K2400_2182_L350_T_Sensing_GUI_v2.py"),
136138
"K6517B I-V": resource_path("Keithley_6517B/High_Resistance/IV_K6517B_GUI_v11.py"),
137139
"K6517B R-T": resource_path("Keithley_6517B/High_Resistance/RT_K6517B_L350_T_Control_GUI_v13.py"),
138140
"K6517B R-T (T_Sensing)": resource_path("Keithley_6517B/High_Resistance/RT_K6517B_L350_T_Sensing_GUI_v14.py"),
@@ -332,7 +334,6 @@ def create_resource_panel(self, parent):
332334
util_frame.pack(fill='x', expand=False, pady=5)
333335
# --- Make the README button bigger by spanning two columns ---
334336
util_frame.grid_columnconfigure((0, 1, 2, 3), weight=1)
335-
336337
ttk.Button(
337338
util_frame,
338339
text="GPIB Utils",

tests/test_iv_k2400_loop_backend.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import unittest
22
from unittest.mock import patch, MagicMock
3-
import sys
4-
import os
53

6-
# Add the root directory to the Python path
7-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
84

95
# Now we can import the module to be tested
106
from Keithley_2400.Backends import IV_K2400_Loop_Backend_v10 as iv_backend
117

8+
129
class TestIVK2400LoopBackend(unittest.TestCase):
1310

1411
@patch('builtins.input', side_effect=['10', '2', 'test_output'])
@@ -28,20 +25,22 @@ def test_main_full_run(self, mock_to_csv, mock_plt_show, mock_keithley_class, mo
2825
# Let's return a voltage that is proportional to the current
2926
def voltage_side_effect():
3027
# A simple linear relationship for testing
31-
return mock_keithley_instance.source_current * 10
28+
return mock_keithley_instance.source_current * 10
3229

3330
# We can't directly access the source_current from ramp_to_current,
3431
# so we will use a side effect to track it
3532
latest_current = [0]
33+
3634
def ramp_side_effect(current):
3735
latest_current[0] = current
3836
# Also update the mock's internal state
3937
mock_keithley_instance.source_current = current
40-
38+
4139
mock_keithley_instance.ramp_to_current.side_effect = ramp_side_effect
42-
40+
4341
# When .voltage is accessed, return the calculated value
44-
type(mock_keithley_instance).voltage = unittest.mock.PropertyMock(side_effect=voltage_side_effect)
42+
type(mock_keithley_instance).voltage = unittest.mock.PropertyMock(
43+
side_effect=voltage_side_effect)
4544

4645
# --- EXECUTE SCRIPT ---
4746
iv_backend.main()
@@ -63,9 +62,11 @@ def ramp_side_effect(current):
6362
# np.linspace(0, 10, int(10/2) + 1) -> linspace(0, 10, 6)
6463
# The values will be [0., 2., 4., 6., 8., 10.]
6564
expected_currents_uA = [0., 2., 4., 6., 8., 10.]
66-
expected_calls = [unittest.mock.call(c * 1e-6) for c in expected_currents_uA]
67-
mock_keithley_instance.ramp_to_current.assert_has_calls(expected_calls)
68-
65+
expected_calls = [unittest.mock.call(
66+
c * 1e-6) for c in expected_currents_uA]
67+
mock_keithley_instance.ramp_to_current.assert_has_calls(
68+
expected_calls)
69+
6970
# 4. Verify the number of measurements taken
7071
self.assertEqual(mock_keithley_instance.ramp_to_current.call_count, 6)
7172
# Voltage is read once per loop
@@ -77,12 +78,13 @@ def ramp_side_effect(current):
7778
call_args = mock_to_csv.call_args
7879
save_path = call_args[0][0]
7980
self.assertIn('test_output.txt', save_path)
80-
81+
8182
# 6. Check that the instrument was shut down
8283
mock_keithley_instance.shutdown.assert_called_once()
83-
84+
8485
# 7. Check that the plot was displayed
8586
mock_plt_show.assert_called_once()
8687

88+
8789
if __name__ == '__main__':
8890
unittest.main()

0 commit comments

Comments
 (0)