diff --git a/PyLTSpice/sim/sim_batch.py b/PyLTSpice/sim/sim_batch.py index c96537c..8788d65 100644 --- a/PyLTSpice/sim/sim_batch.py +++ b/PyLTSpice/sim/sim_batch.py @@ -221,7 +221,7 @@ def failSim(self): raw, log = LTC.run().wait_results() _logger.debug(f"Raw file '{raw}' | Log File '{log}'") # Sim Statistics - _logger.info('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) + _logger.info(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') def callback_function(raw_file, log_file): diff --git a/README.md b/README.md index 5a254ca..217376d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # README # -_Current Version 5.4.5_ +_Current Version 5.5.0_ PyLTSpice is a toolchain of python utilities design to interact with LTSpice Electronic Simulator. It is mostly based on the spicelib package, being the main difference to it is @@ -184,7 +184,7 @@ netlist.add_instructions( ) # Sim Statistics -print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) +print(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') enter = input("Press enter to delete created files") if enter == '': @@ -460,6 +460,10 @@ _Make sure to initialize the root logger before importing the library to be able For support and improvement requests please open an Issue in [GitHub spicelib issues](https://github.com/nunobrum/spicelib/issues) ## History ## +* Version 5.5.0 (spicelib 1.5.0) + * Dropping support for Python 3.9 + * Using f-strings across the entire codebase + * Using the new union type hinting syntax across the entire codebase * Version 5.4.5 (spicelib 1.4.7) * Implementing a lazy loading approach in RawRead * Fixing Issue #256 - Correct add_component() in SpiceEditor diff --git a/doc/modules/run_simulations.rst b/doc/modules/run_simulations.rst index fde1566..03dfb2c 100644 --- a/doc/modules/run_simulations.rst +++ b/doc/modules/run_simulations.rst @@ -103,7 +103,7 @@ each executing in parallel a simulation. This is exemplified in the modified exa # The timeout counter is reset everytime a simulation is finished. # Sim Statistics - print('Successful/Total Simulations: ' + str(runner.okSim) + '/' + str(runner.runno)) + print(f'Successful/Total Simulations: {runner.okSim}/{runner.runno}') If the ``parallel_sims`` parallel simulations is not given, it defaults to 4. This means that a fifth simulation will only start when one of the other 4 is finished. If ``parallel_sims`` needs to be adjusted according to the diff --git a/examples/raw_plotting.py b/examples/raw_plotting.py index 348de32..128e3ca 100644 --- a/examples/raw_plotting.py +++ b/examples/raw_plotting.py @@ -1,7 +1,6 @@ import sys import matplotlib.pyplot as plt import os -from os.path import split as pathsplit from os.path import join as pathjoin import numpy as np from numpy import abs as mag, angle @@ -31,14 +30,16 @@ def what_to_units(whattype): # filename = 'AC.raw' # filename = 'AC - STEP.raw' # filename = 'DC op point - STEP.raw' - trace_names = ("V(out)",) + # trace_names = ("V(out)",) filename = 'Noise.raw' trace_names = ("V(onoise)",) raw_filename = pathjoin(test_directory, filename) LTR = RawRead(raw_filename, trace_names, verbose=True) +# Calculate field width from the longest parameter name so the colon lines up vertically +field_width = max((len(str(p)) for p in LTR.raw_params.keys()), default=0) for param, value in LTR.raw_params.items(): - print("{}: {}{}".format(param, " " * (20 - len(param)), str(value).strip())) + print(f"{param:<{field_width}}: {value}") if trace_names == '*': print("Reading all the traces in the raw file") diff --git a/examples/sim_runner_asc_example.py b/examples/sim_runner_asc_example.py index 5b95af7..a45dfef 100644 --- a/examples/sim_runner_asc_example.py +++ b/examples/sim_runner_asc_example.py @@ -1,7 +1,7 @@ from PyLTSpice import SimRunner from PyLTSpice import AscEditor -# Force another simulatior +# Force another simulator simulator = r"C:\Program Files\LTC\LTspiceXVII\XVIIx64.exe" # select spice model @@ -36,7 +36,7 @@ # ... # Sim Statistics -print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) +print(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') enter = input("Press enter to delete created files") if enter == '': diff --git a/examples/sim_runner_callback_example.py b/examples/sim_runner_callback_example.py index de5af3a..e3f46b4 100644 --- a/examples/sim_runner_callback_example.py +++ b/examples/sim_runner_callback_example.py @@ -71,4 +71,8 @@ def processing_data(raw_file, log_file): results = runner.wait_completion(1, abort_all_on_timeout=True) # Sim Statistics - print('Successful/Total Simulations: ' + str(runner.okSim) + '/' + str(runner.runno)) + print(f'Successful/Total Simulations: {runner.okSim}/{runner.runno}') + +enter = input("Press enter to delete created files") +if enter == '': + runner.file_cleanup() diff --git a/examples/sim_runner_callback_process_example.py b/examples/sim_runner_callback_process_example.py index 5e54897..726cf0a 100644 --- a/examples/sim_runner_callback_process_example.py +++ b/examples/sim_runner_callback_process_example.py @@ -59,6 +59,10 @@ def callback(raw_file, log_file): results = runner.wait_completion(1, abort_all_on_timeout=True) # Sim Statistics - print('Successful/Total Simulations: ' + str(runner.okSim) + '/' + str(runner.runno)) + print(f'Successful/Total Simulations: {runner.okSim}/{runner.runno}') + + enter = input("Press enter to delete created files") + if enter == '': + runner.file_cleanup() diff --git a/examples/sim_runner_example.py b/examples/sim_runner_example.py index 35a0173..30e7ee7 100644 --- a/examples/sim_runner_example.py +++ b/examples/sim_runner_example.py @@ -44,7 +44,7 @@ ) # Sim Statistics -print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) +print(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') enter = input("Press enter to delete created files") if enter == '': diff --git a/examples/sim_stepper_example.py b/examples/sim_stepper_example.py index 7f4525b..61623f4 100644 --- a/examples/sim_stepper_example.py +++ b/examples/sim_stepper_example.py @@ -32,5 +32,5 @@ def processing_data(raw_file, log_file): Stepper.run_all(callback=processing_data) # Sim Statistics -print('Successful/Total Simulations: ' + str(Stepper.okSim) + '/' + str(Stepper.runno)) +print(f'Successful/Total Simulations: {Stepper.okSim}/{Stepper.runno}') runner.file_cleanup() diff --git a/pyproject.toml b/pyproject.toml index 257b463..93b897d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = [ build-backend = "setuptools.build_meta" [project] name = "PyLTSpice" -version = "5.4.5" +version = "5.5.0" authors = [ { name="Nuno Brum", email="me@nunobrum.com" }, ] diff --git a/unittests/test_pyltspice.py b/unittests/test_pyltspice.py index 24ad496..5872ffd 100644 --- a/unittests/test_pyltspice.py +++ b/unittests/test_pyltspice.py @@ -112,7 +112,7 @@ def processing_data(raw_file, log_file): LTC.wait_completion() # Sim Statistics - print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) + print(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') self.assertEqual(LTC.okSim, 6) self.assertEqual(LTC.runno, 6) @@ -161,7 +161,7 @@ def test_run_from_spice_editor(self): raw, log = LTC.run(netlist).wait_results() print(f"Raw file '{raw}' | Log File '{log}'") # Sim Statistics - print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno)) + print(f'Successful/Total Simulations: {LTC.okSim}/{LTC.runno}') @unittest.skipIf(skip_ltspice_tests, "Skip if not in windows environment") def test_sim_runner(self):