From b37673a12227db7cb021ffd3643e44e73807adb3 Mon Sep 17 00:00:00 2001 From: arsadri Date: Thu, 29 Aug 2024 14:31:13 +1000 Subject: [PATCH] critical error removed --- HISTORY.rst | 8 ++++++-- lognflow/__init__.py | 5 ++--- lognflow/utils.py | 6 ++++-- setup.cfg | 2 +- setup.py | 2 +- tests/test_utils.py | 27 ++++++++++----------------- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b517b29..fda7eea 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -326,8 +326,12 @@ History ------------------- * the bug in scatter3 without animation is fixed. -0.12.12 (2024-09-01) +0.12.12 (2024-09-08) ------------------- * log_dir assertion only throws a warning * printvar try 1. -* pyrunner try 1. is added \ No newline at end of file +* pyrunner try 1. is added + +0.12.12 (2024-09-08) +------------------- +* critical error removed \ No newline at end of file diff --git a/lognflow/__init__.py b/lognflow/__init__.py index 99fbbe0..38e5f09 100644 --- a/lognflow/__init__.py +++ b/lognflow/__init__.py @@ -2,7 +2,7 @@ __author__ = 'Alireza Sadri' __email__ = 'arsadri@gmail.com' -__version__ = '0.12.12' +__version__ = '0.12.13' from .lognflow import lognflow from .logviewer import logviewer @@ -13,10 +13,9 @@ from .utils import ( select_directory, select_file, repr_raw, replace_all, is_builtin_collection, text_to_collection, stack_to_frame, - stacks_to_frames, ssh_system, printvar) + stacks_to_frames, ssh_system, printvar, Pyrunner) from .multiprocessor import multiprocessor from .loopprocessor import loopprocessor -from .pyrunner import Pyrunner getLogger = lognflow def basicConfig(*args, **kwargs): ... \ No newline at end of file diff --git a/lognflow/utils.py b/lognflow/utils.py index 1fe1c64..7e4cc5a 100644 --- a/lognflow/utils.py +++ b/lognflow/utils.py @@ -385,7 +385,10 @@ def show(self, globals_, figsize = (3, 2)) -> (str, int): show_and_ask_result = question_dialog( question='Choose a cell number', figsize=figsize, buttons=buttons) - if show_and_ask_result == str(show_and_ask_result): + if show_and_ask_result is None: + self.logger(f'pyrunner: closing reloads, press Exit to close.') + return + elif show_and_ask_result == str(show_and_ask_result): if show_and_ask_result == 'exit': self.exit = True return @@ -407,7 +410,6 @@ def show(self, globals_, figsize = (3, 2)) -> (str, int): self.saved_state.pop(key) self.logger(f'Deleted state: {key}') return - elif show_and_ask_result == int(show_and_ask_result): globals_['pyrunner_code'] = pyrunner_code globals_['pyrunner_cell_no'] = show_and_ask_result diff --git a/setup.cfg b/setup.cfg index a88e32d..0b0060f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.12.11 +current_version = 0.12.12 commit = True tag = True diff --git a/setup.py b/setup.py index 64d496b..2c78ecf 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ __author__ = 'Alireza Sadri' __email__ = 'arsadri@gmail.com' -__version__ = '0.12.12' +__version__ = '0.12.13' with open('README.rst') as readme_file: readme = readme_file.read() diff --git a/tests/test_utils.py b/tests/test_utils.py index e9cbd16..ab32204 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -31,14 +31,13 @@ def test_is_builtin_collection(): test_tuple = (1, 2, 3) test_array = np.array([1, 2, 3]) - print(lognflow.is_builtin_collection(test_list)) # Expected: True - print(lognflow.is_builtin_collection(test_string)) # Expected: False - print(lognflow.is_builtin_collection(test_dict)) # Expected: True - print(lognflow.is_builtin_collection(test_set)) # Expected: True + print(lognflow.is_builtin_collection(test_list)) # Expected: True + print(lognflow.is_builtin_collection(test_string)) # Expected: False + print(lognflow.is_builtin_collection(test_dict)) # Expected: True + print(lognflow.is_builtin_collection(test_set)) # Expected: True print(lognflow.is_builtin_collection(test_tuple)) # Expected: True print(lognflow.is_builtin_collection(test_array)) # Expected: False - def test_ssh_system(): try: ssh = ssh_system( @@ -56,29 +55,23 @@ def test_printvar(): lognflow.utils.printvar(test1) test2 = 123 lognflow.utils.printvar(test2) - test3 = [1243, 'sadf', 21] + test3 = [1243, 'asdf', 21] lognflow.utils.printvar(test3) def test_save_or_load_kernel_state(): - - # Example code that sets up some variables vec = np.random.rand(100) vec_orig = vec.copy() - another_variable = "Hello, World!" + another_variable = "Hello" - # Save the current state of the kernel (interpreter) current_kernel_state = lognflow.utils.save_or_load_kernel_state() - # Modify the variables vec = vec ** 2 - another_variable = "Goodbye, World!" + another_variable = "Goodbye" - # Restore the previous state lognflow.utils.save_or_load_kernel_state(current_kernel_state) - # Check that the state has been restored assert (vec == vec_orig).all() - assert another_variable == "Hello, World!" + assert another_variable == "Hello" print("State restored successfully!") @@ -87,8 +80,8 @@ def test_Pyrunner(): Pyrunner(Path('./test_pyrunner_code.py'), logger = print) if __name__ == '__main__': - test_Pyrunner();exit() + test_Pyrunner() test_printvar() test_is_builtin_collection() test_stack_to_frame() - test_ssh_system() + test_ssh_system() \ No newline at end of file