From 44ac920dca6ce13eb872c2a37c6d62e4715cf511 Mon Sep 17 00:00:00 2001 From: christian-B Date: Thu, 3 Sep 2026 13:01:56 +0100 Subject: [PATCH] use f string --- .../extra_models_examples/stdp_triplet.py | 6 ++-- .../stdp_neuromodulated_example_split.py | 2 +- ...ral_plasticity_with_stdp_neuromodulated.py | 2 +- examples/split_examples/va_benchmark_split.py | 36 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/extra_models_examples/stdp_triplet.py b/examples/extra_models_examples/stdp_triplet.py index 64d47ac..f855236 100644 --- a/examples/extra_models_examples/stdp_triplet.py +++ b/examples/extra_models_examples/stdp_triplet.py @@ -151,7 +151,7 @@ def generate_fixed_frequency_test_data( size="xx-large") line_styles = ["--", "-"] -for m_w, d_w, d_e, line_style, t in zip( +for m_w, d_w, d_e, line_style, ms in zip( weights, data_w, data_e, line_styles, delta_t): # Calculate deltas from end weights delta_w = [(w - start_w) / start_w for w in m_w] @@ -159,11 +159,11 @@ def generate_fixed_frequency_test_data( # Plot experimental data and error bars axis.errorbar( frequencies, d_w, yerr=d_e, color="black", linestyle=line_style, - label=r"Experimental data, delta $(\Delta{t}=%dms)$" % t) + label=rf"Experimental data, delta $(\Delta{t}={ms}ms)$") # Plot model data axis.plot(frequencies, delta_w, color="blue", linestyle=line_style, - label=r"Triplet rule, delta $(\Delta{t}=%dms)$" % t) + label=rf"Triplet rule, delta $(\Delta{t}={ms}ms)$") axis.legend(loc="upper right", bbox_to_anchor=(1.0, 1.0)) diff --git a/examples/split_examples/stdp_neuromodulated_example_split.py b/examples/split_examples/stdp_neuromodulated_example_split.py index 2da26fb..84e6545 100644 --- a/examples/split_examples/stdp_neuromodulated_example_split.py +++ b/examples/split_examples/stdp_neuromodulated_example_split.py @@ -138,7 +138,7 @@ def plot_spikes(spikes, title, n_neurons): pylab.plot(punishments, [0.5 for x in punishments], 'r^') pylab.show() -print("Weights(Initial %s)" % plastic_weights) +print(f"Weights(Initial {plastic_weights})") for x in weights: print(x) diff --git a/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py b/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py index e015e3d..9486013 100644 --- a/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py +++ b/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py @@ -170,7 +170,7 @@ def plot_spikes(spikes, title, n_pops, n_neurons): pylab.plot(punishments, [0.5 for x in punishments], 'r^') pylab.show() -print("Weights(Initial %s)" % plastic_weights) +print(f"Weights(Initial {plastic_weights})") for x in weights: print(x) diff --git a/examples/split_examples/va_benchmark_split.py b/examples/split_examples/va_benchmark_split.py index c42eaf2..a6d9d28 100755 --- a/examples/split_examples/va_benchmark_split.py +++ b/examples/split_examples/va_benchmark_split.py @@ -115,7 +115,7 @@ # === Build the network === extra = {'threads': threads, - 'filename': "va_%s.xml" % benchmark, + 'filename': f"va_{benchmark}.xml", 'label': 'VA'} if simulator_name == "neuroml": extra["file"] = "VAbenchmarks.xml" @@ -129,10 +129,10 @@ np = 1 host_name = socket.gethostname() -print("Host #%d is on %s" % (np, host_name)) +print(f"Host #{np} is on {host_name}") -print("%s Initialising the simulator with %d thread(s)..." % ( - node_id, extra['threads'])) +print(f"{node_id} Initialising the simulator with " + f"{extra['threads']} thread(s)...") cell_params = {'tau_m': tau_m, 'tau_syn_E': tau_exc, @@ -153,7 +153,7 @@ timer.start() -print("%s Creating cell populations..." % node_id) +print(f"{node_id} Creating cell populations...") exc_cells = p.Population( n_exc, celltype(**cell_params), label="Excitatory_Cells", seed=1) inh_cells = p.Population( @@ -168,12 +168,12 @@ ext_conn = p.FixedProbabilityConnector(rconn) ext_stim.record("spikes") -print("%s Initialising membrane potential to random values..." % node_id) +print(f"{node_id} Initialising membrane potential to random values...") uniformDistr = RandomDistribution('uniform', [v_reset, v_thresh]) exc_cells.initialize(v=uniformDistr) inh_cells.initialize(v=uniformDistr) -print("%s Connecting populations..." % node_id) +print(f"{node_id} Connecting populations...") exc_conn = p.FixedProbabilityConnector(pconn) inh_conn = p.FixedProbabilityConnector(pconn) @@ -200,13 +200,13 @@ synapse_type=p.StaticSynapse(weight=0.1)) # === Setup recording === -print("%s Setting up recording..." % node_id) +print(f"{node_id} Setting up recording...") exc_cells.record("spikes") buildCPUTime = timer.diff() # === Run simulation === -print("%d Running simulation..." % node_id) +print(f"{node_id} Running simulation...") print(f"timings: number of neurons: {n}") print(f"timings: number of synapses: {n * n * pconn}") @@ -232,15 +232,15 @@ if node_id == 0: print("\n--- Vogels-Abbott Network Simulation ---") - print("Nodes : %d" % np) - print("Simulation type : %s" % benchmark) - print("Number of Neurons : %d" % n) - print("Number of Synapses : %s" % connections) - print("Excitatory conductance : %g nS" % Gexc) - print("Inhibitory conductance : %g nS" % Ginh) - print("Build time : %g s" % buildCPUTime) - print("Simulation time : %g s" % simCPUTime) - print("Writing time : %g s" % writeCPUTime) + print(f"Nodes : {np}") + print(f"Simulation type : {benchmark}") + print(f"Number of Neurons : {n}") + print(f"Number of Synapses : {connections}") + print(f"Excitatory conductance : {Gexc} nS") + print(f"Inhibitory conductance : {Ginh} nS") + print(f"Build time : {buildCPUTime} s") + print(f"Simulation time : {simCPUTime} s") + print(f"Writing time : {writeCPUTime} s") # === Finished with simulator ===