Skip to content

Commit

Permalink
removed dependency on dill
Browse files Browse the repository at this point in the history
  • Loading branch information
ARSadri committed Aug 29, 2024
1 parent b37673a commit 81e6d3c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
10 changes: 7 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,16 @@ History
-------------------
* the bug in scatter3 without animation is fixed.

0.12.12 (2024-09-08)
0.12.12 (2024-08-28)
-------------------
* log_dir assertion only throws a warning
* printvar try 1.
* pyrunner try 1. is added

0.12.12 (2024-09-08)
0.12.12 (2024-08-29)
-------------------
* critical error removed
* critical error removed

0.12.12 (2024-08-30)
-------------------
* removed dependency on dill
2 changes: 1 addition & 1 deletion lognflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Alireza Sadri'
__email__ = '[email protected]'
__version__ = '0.12.13'
__version__ = '0.12.14'

from .lognflow import lognflow
from .logviewer import logviewer
Expand Down
29 changes: 19 additions & 10 deletions lognflow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import pathlib
import numpy as np
import dill as pickle
from pathlib import Path
from .plt_utils import question_dialog

Expand All @@ -13,22 +12,29 @@ def is_builtin_collection(obj):
"""
Determine if an object is a strictly built-in Python collection.
This function uses a heuristic based on the object type's module being either 'builtins',
'collections', or 'collections.abc', excluding strings and bytes explicitly, to identify
if the given object is a built-in collection type (list, tuple, dict, set). It checks if the
object belongs to one of Python's built-in collection modules and possesses both __len__ and
This function uses a heuristic based on the object
type's module being either 'builtins',
'collections', or 'collections.abc', excluding
strings and bytes explicitly, to identify
if the given object is a built-in collection
type (list, tuple, dict, set). It checks if the
object belongs to one of Python's built-in
collection modules and possesses both __len__ and
__iter__ methods, which are typical characteristics of collections.
Args:
obj: The object to be checked.
Returns:
bool: True if the object is a built-in Python collection (excluding strings and bytes),
bool: True if the object is a built-in Python
collection (excluding strings and bytes),
False otherwise.
Note:
This function aims to exclude objects from external libraries (e.g., NumPy arrays) that,
while iterable and having a __len__ method, are not considered built-in Python collections.
This function aims to exclude objects from external
libraries (e.g., NumPy arrays) that,
while iterable and having a __len__ method,
are not considered built-in Python collections.
"""
obj_type = type(obj)
module = obj_type.__module__
Expand Down Expand Up @@ -134,7 +140,8 @@ def parse_node(node):
if isinstance(node, ast.List):
return [parse_node(elem) for elem in node.elts]
elif isinstance(node, ast.Dict):
return {parse_node(key): parse_node(value) for key, value in zip(node.keys, node.values)}
return {parse_node(key): parse_node(value)
for key, value in zip(node.keys, node.values)}
elif isinstance(node, ast.Constant):
return node.value
elif isinstance(node, ast.Num): # For Python < 3.8
Expand Down Expand Up @@ -252,7 +259,8 @@ def __init__(self, hostname, username, password):
import paramiko
self.ssh_client = paramiko.SSHClient()
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh_client.connect(hostname=hostname, username=username, password=password)
self.ssh_client.connect(
hostname=hostname, username=username, password=password)
self.sftp_client = self.ssh_client.open_sftp()

def ssh_ls(self, path: Path):
Expand Down Expand Up @@ -354,6 +362,7 @@ def logger(self, toprint, end = '\n'):
self.logger_(toprint)

def save_or_load_kernel_state(self, globals_, saved_state = None):
import dill as pickle
if saved_state is None:
return pickle.dumps(
{k: v for k, v in globals_.items()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.12.12
current_version = 0.12.13
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

__author__ = 'Alireza Sadri'
__email__ = '[email protected]'
__version__ = '0.12.13'
__version__ = '0.12.14'

with open('README.rst') as readme_file:
readme = readme_file.read()
Expand Down

0 comments on commit 81e6d3c

Please sign in to comment.