Skip to content

Commit 66b2147

Browse files
[pre-commit.ci] pre-commit autoupdate (#484)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent 73eb126 commit 66b2147

30 files changed

+114
-151
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
with:
4747
qt: true
4848
pyvista: false
49+
wm: false
4950
# Use -dev here just to get whichever version is right (e.g., 22.04 has a different version from 24.04)
5051
- run: sudo apt install -q libavutil-dev libavcodec-dev libavformat-dev libswscale-dev libglu1-mesa gstreamer1.0-alsa gstreamer1.0-libav
5152
if: ${{ startsWith(matrix.os, 'ubuntu') }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# Ruff mne
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.8.6
4+
rev: v0.9.1
55
hooks:
66
- id: ruff
77
name: ruff lint expyfun

doc/git_diagram.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
legend = "".join(legend.split("\n"))
2121

2222
nodes = dict(
23-
upstream="LABSN/expyfun\n" "master\n" " ",
24-
maint="Eric89GXL/expyfun\n" "master\n" "other_branch",
25-
dev="rkmaddox/expyfun\n" "master\n" "fix_branch",
23+
upstream="LABSN/expyfun\nmaster\n ",
24+
maint="Eric89GXL/expyfun\nmaster\nother_branch",
25+
dev="rkmaddox/expyfun\nmaster\nfix_branch",
2626
maint_clone="/home/larsoner/expyfun\n"
2727
"master (origin/master)\n"
2828
"other_branch (origin/other_branch)\n"
@@ -31,7 +31,7 @@
3131
"master (origin/master)\n"
3232
"fix_branch (origin/fix_branch)\n"
3333
" ",
34-
user_clone="/home/akclee/expyfun\n" "master (origin/master)\n" " \n" " ",
34+
user_clone="/home/akclee/expyfun\nmaster (origin/master)\n \n ",
3535
legend=legend,
3636
)
3737

examples/experiments/keypress.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
###############
3838
# screen_prompt
3939
pressed = ec.screen_prompt(
40-
"press any key\n\nscreen_prompt(" f"max_wait={wait_dur})",
40+
f"press any key\n\nscreen_prompt(max_wait={wait_dur})",
4141
max_wait=wait_dur,
4242
timestamp=True,
4343
)
@@ -51,7 +51,7 @@
5151

5252
##################
5353
# wait_for_presses
54-
ec.screen_text(f"press some keys\n\nwait_for_presses(max_wait={wait_dur})" "")
54+
ec.screen_text(f"press some keys\n\nwait_for_presses(max_wait={wait_dur})")
5555
screenshot = ec.screenshot()
5656
ec.flip()
5757
pressed = ec.wait_for_presses(wait_dur)
@@ -60,7 +60,7 @@
6060
message = "no keys pressed"
6161
else:
6262
message = [
63-
f"{key} pressed after {round(time, 4)} secs\n" "" for key, time in pressed
63+
f"{key} pressed after {round(time, 4)} secs\n" for key, time in pressed
6464
]
6565
message = "".join(message)
6666
ec.screen_prompt(message, msg_dur)
@@ -69,25 +69,23 @@
6969
############################################
7070
# wait_for_presses, relative to master clock
7171
ec.screen_text(
72-
f"press some keys\n\nwait_for_presses(max_wait={wait_dur}, " "relative_to=0.0)"
72+
f"press some keys\n\nwait_for_presses(max_wait={wait_dur}, relative_to=0.0)"
7373
)
7474
ec.flip()
7575
pressed = ec.wait_for_presses(wait_dur, relative_to=0.0)
7676
ec.write_data_line("wait_for_presses relative_to 0.0", pressed)
7777
if not len(pressed):
7878
message = "no keys pressed"
7979
else:
80-
message = [
81-
f"{key} pressed at {round(time, 4)} secs\n" "" for key, time in pressed
82-
]
80+
message = [f"{key} pressed at {round(time, 4)} secs\n" for key, time in pressed]
8381
message = "".join(message)
8482
ec.screen_prompt(message, msg_dur)
8583
ec.wait_secs(isi)
8684

8785
##########################################
8886
# listen_presses / wait_secs / get_presses
8987
ec.screen_text(
90-
f"press some keys\n\nlisten_presses()\nwait_secs({wait_dur})" "\nget_presses()"
88+
f"press some keys\n\nlisten_presses()\nwait_secs({wait_dur})\nget_presses()"
9189
)
9290
ec.flip()
9391
ec.listen_presses()
@@ -98,7 +96,7 @@
9896
message = "no keys pressed"
9997
else:
10098
message = [
101-
f"{key} pressed after {round(time, 4)} secs\n" "" for key, time in pressed
99+
f"{key} pressed after {round(time, 4)} secs\n" for key, time in pressed
102100
]
103101
message = "".join(message)
104102
ec.screen_prompt(message, msg_dur)
@@ -119,9 +117,7 @@
119117
if not len(pressed):
120118
message = "no keys pressed"
121119
else:
122-
message = [
123-
f"{key} pressed at {round(time, 4)} secs\n" "" for key, time in pressed
124-
]
120+
message = [f"{key} pressed at {round(time, 4)} secs\n" for key, time in pressed]
125121
message = "".join(message)
126122
ec.screen_prompt(message, msg_dur)
127123
ec.wait_secs(isi)
@@ -132,7 +128,7 @@
132128
countdown = ec.current_time + disp_time
133129
ec.call_on_next_flip(ec.listen_presses)
134130
ec.screen_text(
135-
"press some keys\n\nlisten_presses()" f"\nwhile loop {disp_time}\nget_presses()"
131+
f"press some keys\n\nlisten_presses()\nwhile loop {disp_time}\nget_presses()"
136132
)
137133
ec.flip()
138134
while ec.current_time < countdown:
@@ -151,7 +147,7 @@
151147
message = "no keys pressed"
152148
else:
153149
message = [
154-
f"{key} pressed after {round(time, 4)} secs\n" "" for key, time in pressed
150+
f"{key} pressed after {round(time, 4)} secs\n" for key, time in pressed
155151
]
156152
message = "".join(message)
157153
ec.screen_prompt(message, msg_dur)
@@ -183,9 +179,7 @@
183179
if not len(pressed):
184180
message = "no keys pressed"
185181
else:
186-
message = [
187-
f"{key} pressed at {round(time, 4)} secs\n" "" for key, time in pressed
188-
]
182+
message = [f"{key} pressed at {round(time, 4)} secs\n" for key, time in pressed]
189183
message = "".join(message)
190184
ec.screen_prompt(message, msg_dur)
191185

examples/experiments/keyrelease.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
if not len(events):
7070
message = "no keys pressed"
7171
else:
72-
message = [f"{k} {r} after {round(t, 4)} secs\n" "" for k, t, r in events]
72+
message = [f"{k} {r} after {round(t, 4)} secs\n" for k, t, r in events]
7373
message = "".join(message)
7474
ec.screen_prompt(message, msg_dur)
7575
ec.wait_secs(isi)

examples/experiments/progress_bar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
pb = ProgressBar(ec, [0, -0.1, 1.5, 0.1], units="norm")
3131

3232
ec.screen_prompt(
33-
"Press the number shown on the screen. Start by pressing" " 1.",
33+
"Press the number shown on the screen. Start by pressing 1.",
3434
font_size=16,
3535
live_keys=[1],
3636
max_wait=max_wait,
@@ -51,7 +51,7 @@
5151
pb.update_bar(percent)
5252
# display the progress bar with some text
5353
ec.screen_text(
54-
f"You've completed {percent} %. Press any key to proceed." "",
54+
f"You've completed {percent} %. Press any key to proceed.",
5555
[0, 0.1],
5656
wrap=False,
5757
font_size=16,

examples/simple_experiment.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,9 @@
147147
message = "Too slow!"
148148
elif int(pressed) == stim_num + 1:
149149
running_total += 1
150-
message = "Correct! Your reaction time was " f"{round(timestamp, 3)}"
150+
message = f"Correct! Your reaction time was {round(timestamp, 3)}"
151151
else:
152-
message = (
153-
f"You pressed {pressed}, the correct answer was " f"{stim_num + 1}."
154-
)
152+
message = f"You pressed {pressed}, the correct answer was {stim_num + 1}."
155153
ec.screen_prompt(message, max_wait=feedback_dur)
156154
ec.wait_secs(isi)
157155

@@ -184,7 +182,7 @@
184182
running_total += sum(correct)
185183
ec.call_on_next_flip(ec.stop_noise())
186184
ec.screen_prompt(
187-
f"You got {sum(correct)} out of {len(answers)} correct." "",
185+
f"You got {sum(correct)} out of {len(answers)} correct.",
188186
max_wait=feedback_dur,
189187
)
190188
ec.trial_ok()

examples/stimuli/crm_stimuli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
)
5454

5555
# print the valid callsigns
56-
print(f'Valid callsigns are {crm_info()["callsign"]}')
56+
print(f"Valid callsigns are {crm_info()['callsign']}")
5757

5858
# read a sentence in from the hard drive
5959
x1 = 0.5 * crm_sentence(fs, "m", "0", "c", "r", "5", path=crm_path)
@@ -79,7 +79,7 @@
7979
stim_fs=40000,
8080
) as ec:
8181
ec.screen_text(
82-
"Report the color and number spoken by the female " "talker.", wrap=True
82+
"Report the color and number spoken by the female talker.", wrap=True
8383
)
8484
screenshot = ec.screenshot()
8585
ec.flip()

expyfun/_experiment_controller.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def __init__(
255255
and value is not None
256256
and not isinstance(value, str)
257257
):
258-
raise TypeError(f"{value} must be string or None" "")
258+
raise TypeError(f"{value} must be string or None")
259259
if key in edit_list and value is None:
260260
self._exp_info[key] = get_keyboard_input(f"{key}: ")
261261
else:
@@ -272,7 +272,7 @@ def __init__(
272272
os.mkdir(output_dir)
273273
basename = op.join(
274274
output_dir,
275-
"{}_{}" "".format(
275+
"{}_{}".format(
276276
self._exp_info["participant"], self._exp_info["date"]
277277
),
278278
)
@@ -298,8 +298,7 @@ def __init__(
298298
safe_flipping = not (get_config("SAFE_FLIPPING", "").lower() == "false")
299299
if not safe_flipping:
300300
logger.warning(
301-
"Expyfun: Unsafe flipping mode enabled, flip "
302-
"timing not guaranteed"
301+
"Expyfun: Unsafe flipping mode enabled, flip timing not guaranteed"
303302
)
304303
self.safe_flipping = safe_flipping
305304

@@ -323,7 +322,7 @@ def __init__(
323322
req_mon_keys = ["SCREEN_WIDTH", "SCREEN_DISTANCE", "SCREEN_SIZE_PIX"]
324323
missing_keys = [key for key in req_mon_keys if key not in monitor]
325324
if missing_keys:
326-
raise KeyError(f"monitor is missing required keys {missing_keys}" "")
325+
raise KeyError(f"monitor is missing required keys {missing_keys}")
327326
mon_size = monitor["SCREEN_SIZE_PIX"]
328327
monitor["SCREEN_DPI"] = monitor["SCREEN_SIZE_PIX"][0] / (
329328
monitor["SCREEN_WIDTH"] * 0.393701
@@ -365,7 +364,7 @@ def __init__(
365364
response_device = get_config("RESPONSE_DEVICE", "keyboard")
366365
if response_device not in ["keyboard", "tdt", "cedrus"]:
367366
raise ValueError(
368-
'response_device must be "keyboard", "tdt", ' '"cedrus", or None'
367+
'response_device must be "keyboard", "tdt", "cedrus", or None'
369368
)
370369
self._response_device = response_device
371370

@@ -447,7 +446,7 @@ def __init__(
447446
window_size = [int(w) for w in window_size]
448447
window_size = np.array(window_size)
449448
if window_size.ndim != 1 or window_size.size != 2:
450-
raise ValueError("window_size must be 2-element array-like or " "None")
449+
raise ValueError("window_size must be 2-element array-like or None")
451450

452451
# open window and setup GL config
453452
self._setup_window(window_size, exp_name, full_screen, screen)
@@ -458,7 +457,7 @@ def __init__(
458457
elif response_device == "tdt":
459458
if not isinstance(self._ac, TDTController):
460459
raise ValueError(
461-
'response_device can only be "tdt" if ' "tdt is used for audio"
460+
'response_device can only be "tdt" if tdt is used for audio'
462461
)
463462
self._response_handler = self._ac
464463
self._ac._add_keyboard_init(self, force_quit)
@@ -489,13 +488,12 @@ def __init__(
489488
f"{known_keys}, got {set(trigger_controller)}"
490489
)
491490
logger.info(
492-
f'Expyfun: Initializing {trigger_controller["TYPE"]} ' 'triggering mode'
491+
f"Expyfun: Initializing {trigger_controller['TYPE']} triggering mode"
493492
)
494493
if trigger_controller["TYPE"] == "tdt":
495494
if not isinstance(self._ac, TDTController):
496495
raise ValueError(
497-
'trigger_controller can only be "tdt" if '
498-
"tdt is used for audio"
496+
'trigger_controller can only be "tdt" if tdt is used for audio'
499497
)
500498
self._tc = self._ac
501499
elif trigger_controller["TYPE"] == "sound_card":
@@ -543,9 +541,9 @@ def __init__(
543541
# finish initialization
544542
logger.info("Expyfun: Initialization complete")
545543
logger.exp(
546-
"Expyfun: Participant: {0}" "".format(self._exp_info["participant"])
544+
"Expyfun: Participant: {0}".format(self._exp_info["participant"])
547545
)
548-
logger.exp("Expyfun: Session: {0}" "".format(self._exp_info["session"]))
546+
logger.exp("Expyfun: Session: {0}".format(self._exp_info["session"]))
549547
ok_log = partial(self.write_data_line, "trial_ok", None)
550548
self._on_trial_ok.append(ok_log)
551549
self._on_trial_ok.append(self.flush)
@@ -558,7 +556,7 @@ def __init__(
558556

559557
def __repr__(self):
560558
"""Return a useful string representation of the experiment"""
561-
string = '<ExperimentController ({3}): "{0}" {1} ({2})>' "".format(
559+
string = '<ExperimentController ({3}): "{0}" {1} ({2})>'.format(
562560
self._exp_info["exp_name"],
563561
self._exp_info["participant"],
564562
self._exp_info["session"],
@@ -792,9 +790,7 @@ def start_stimulus(self, start_of_trial=True, flip=True, when=None):
792790
"""
793791
if start_of_trial:
794792
if self._trial_progress != "identified":
795-
raise RuntimeError(
796-
"Trial ID must be stamped before starting " "the trial"
797-
)
793+
raise RuntimeError("Trial ID must be stamped before starting the trial")
798794
self._trial_progress = "started"
799795
extra = "flipping screen and " if flip else ""
800796
logger.exp(f"Expyfun: Starting stimuli: {extra}playing audio")
@@ -1392,7 +1388,7 @@ def check_force_quit(self):
13921388
def text_input(
13931389
self,
13941390
stop_key="return",
1395-
instruction_string="Type" " response below",
1391+
instruction_string="Type response below",
13961392
pos=(0, 0),
13971393
color="white",
13981394
font_name="Arial",
@@ -1863,12 +1859,12 @@ def load_buffer(self, samples):
18631859
"""
18641860
if self._playing:
18651861
raise RuntimeError(
1866-
"Previous audio must be stopped before loading " "the buffer"
1862+
"Previous audio must be stopped before loading the buffer"
18671863
)
18681864
samples = self._validate_audio(samples)
18691865
if not np.isclose(self._stim_scaler, 1.0):
18701866
samples = samples * self._stim_scaler
1871-
logger.exp(f"Expyfun: Loading {samples.size} samples to buffer" "")
1867+
logger.exp(f"Expyfun: Loading {samples.size} samples to buffer")
18721868
self._ac.load_buffer(samples)
18731869

18741870
def play(self):
@@ -1997,7 +1993,7 @@ def _validate_audio(self, samples):
19971993
max_samples = 4000000 - 1
19981994
if samples.shape[0] > max_samples:
19991995
raise RuntimeError(
2000-
f"Sample too long {samples.shape[0]} > {max_samples}" ""
1996+
f"Sample too long {samples.shape[0]} > {max_samples}"
20011997
)
20021998

20031999
# resample if needed
@@ -2066,7 +2062,7 @@ def set_rms_checking(self, check_rms):
20662062
"""
20672063
if check_rms not in [None, "wholefile", "windowed"]:
20682064
raise ValueError(
2069-
'check_rms must be one of "wholefile", "windowed"' ", or None."
2065+
'check_rms must be one of "wholefile", "windowed", or None.'
20702066
)
20712067
self._slow_rms_warned = False
20722068
self._check_rms = check_rms
@@ -2235,7 +2231,7 @@ def identify_trial(self, **ids):
22352231
)
22362232
ll = max([len(key) for key in ids.keys()])
22372233
for key, id_ in ids.items():
2238-
logger.exp(f"Expyfun: Stamp trial ID to {key.ljust(ll)} : {str(id_)}" "")
2234+
logger.exp(f"Expyfun: Stamp trial ID to {key.ljust(ll)} : {str(id_)}")
22392235
if isinstance(id_, dict):
22402236
self._id_call_dict[key](**id_)
22412237
else:
@@ -2318,7 +2314,7 @@ def stamp_triggers(self, ids, check="binary", wait_for_last=True):
23182314
_vals = [1, 2, 4, 8]
23192315
if not all(id_ in _vals for id_ in ids):
23202316
raise ValueError(
2321-
'with check="binary", ids must all be ' f"1, 2, 4, or 8: {ids}"
2317+
f'with check="binary", ids must all be 1, 2, 4, or 8: {ids}'
23222318
)
23232319
self._stamp_ttl_triggers(ids, wait_for_last, False)
23242320

0 commit comments

Comments
 (0)