commutazzio.utils package

Submodules

commutazzio.utils.compressed_dict module

class commutazzio.utils.compressed_dict.CompressedDict(data=None)

Bases: dict

class commutazzio.utils.compressed_dict.CompressedDictManager(address=None, authkey=None, serializer='pickle', ctx=None)

Bases: BaseManager

CompressedDict(*args, **kwds)
commutazzio.utils.compressed_dict.compress(x)

commutazzio.utils.file_operations module

commutazzio.utils.file_operations.clean(directory)

delete all files in a folder

commutazzio.utils.file_operations.clean_all()
commutazzio.utils.file_operations.create_directory(new_dir)
commutazzio.utils.file_operations.delete_file(file_path)
commutazzio.utils.file_operations.filename_logger(obj, filename)

Log the filename and important information to a file.

commutazzio.utils.file_operations.filepath_generator(dirname='./', filename=None, extension=None, overwrite=False)

Generate a filename with a given name and extension. If the file exists, append datetime to the provided name

commutazzio.utils.file_operations.pickle_load(file_path=None)

Load an object from a pickle file. If file_path is none, load the latest pickle file recorded in files.log.

commutazzio.utils.file_operations.pickle_load_latest(number)

Load the latest n pickle file recorded in files.log.

commutazzio.utils.file_operations.pickle_save(obj, file_path=None)

Save an object to a pickle file.

commutazzio.utils.file_operations.read_data(directory, file_format='json')

read all data from json files in directory data

commutazzio.utils.joblib_progress module

commutazzio.utils.joblib_progress.tqdm_joblib(tqdm_object)

Context manager to patch joblib to report into tqdm progress bar given as argument

commutazzio.utils.labelled_point_cloud module

commutazzio.utils.labelled_point_cloud.attach_level(data: array, fn: str, space_dim: int = 3, survival_rates: list = [0.5, 1]) None

attach levels to the point cloud of atoms

Parameters:
datanp.array

coordinates of atoms of the specified lattice

fnstr

file name of the output

space_dimint, optional

dimension of the space, by default 3

survival_rateslist

survival rates of the levels, by default [0.5,1] in the order of layer zero, layer one

commutazzio.utils.memory_tools module

commutazzio.utils.memory_tools.print_memory_usage(var)
commutazzio.utils.memory_tools.print_memory_usage_of_all_variables(scope={'__annotations__': {}, '__builtins__': {'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'AssertionError'>, 'AttributeError': <class 'AttributeError'>, 'BaseException': <class 'BaseException'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'BufferError': <class 'BufferError'>, 'BytesWarning': <class 'BytesWarning'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionError': <class 'ConnectionError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'EOFError': <class 'EOFError'>, 'Ellipsis': Ellipsis, 'EncodingWarning': <class 'EncodingWarning'>, 'EnvironmentError': <class 'OSError'>, 'Exception': <class 'Exception'>, 'False': False, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'FutureWarning': <class 'FutureWarning'>, 'GeneratorExit': <class 'GeneratorExit'>, 'IOError': <class 'OSError'>, 'ImportError': <class 'ImportError'>, 'ImportWarning': <class 'ImportWarning'>, 'IndentationError': <class 'IndentationError'>, 'IndexError': <class 'IndexError'>, 'InterruptedError': <class 'InterruptedError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'KeyError': <class 'KeyError'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'LookupError': <class 'LookupError'>, 'MemoryError': <class 'MemoryError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'NameError': <class 'NameError'>, 'None': None, 'NotADirectoryError': <class 'NotADirectoryError'>, 'NotImplemented': NotImplemented, 'NotImplementedError': <class 'NotImplementedError'>, 'OSError': <class 'OSError'>, 'OverflowError': <class 'OverflowError'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'RecursionError': <class 'RecursionError'>, 'ReferenceError': <class 'ReferenceError'>, 'ResourceWarning': <class 'ResourceWarning'>, 'RuntimeError': <class 'RuntimeError'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'SyntaxError': <class 'SyntaxError'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'SystemError': <class 'SystemError'>, 'SystemExit': <class 'SystemExit'>, 'TabError': <class 'TabError'>, 'TimeoutError': <class 'TimeoutError'>, 'True': True, 'TypeError': <class 'TypeError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'UserWarning': <class 'UserWarning'>, 'ValueError': <class 'ValueError'>, 'Warning': <class 'Warning'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, '__build_class__': <built-in function __build_class__>, '__debug__': True, '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__import__': <built-in function __import__>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__name__': 'builtins', '__package__': '', '__pybind11_internals_v4_gcc_libstdcpp_cxxabi1014__': <capsule object NULL>, '__pybind11_internals_v4_gcc_libstdcpp_cxxabi1016__': <capsule object NULL>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'), 'abs': <built-in function abs>, 'aiter': <built-in function aiter>, 'all': <built-in function all>, 'anext': <built-in function anext>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'bool': <class 'bool'>, 'breakpoint': <built-in function breakpoint>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'classmethod': <class 'classmethod'>, 'compile': <built-in function compile>, 'complex': <class 'complex'>, 'copyright': Copyright (c) 2001-2023 Python Software Foundation. All Rights Reserved.  Copyright (c) 2000 BeOpen.com. All Rights Reserved.  Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved.  Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands     for supporting Python development.  See www.python.org for more information., 'delattr': <built-in function delattr>, 'dict': <class 'dict'>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'enumerate': <class 'enumerate'>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'filter': <class 'filter'>, 'float': <class 'float'>, 'format': <built-in function format>, 'frozenset': <class 'frozenset'>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'help': Type help() for interactive help, or help(object) for help about object., 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'int': <class 'int'>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'license': Type license() to see the full license text, 'list': <class 'list'>, 'locals': <built-in function locals>, 'map': <class 'map'>, 'max': <built-in function max>, 'memoryview': <class 'memoryview'>, 'min': <built-in function min>, 'next': <built-in function next>, 'object': <class 'object'>, 'oct': <built-in function oct>, 'open': <built-in function open>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'property': <class 'property'>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'range': <class 'range'>, 'repr': <built-in function repr>, 'reversed': <class 'reversed'>, 'round': <built-in function round>, 'set': <class 'set'>, 'setattr': <built-in function setattr>, 'slice': <class 'slice'>, 'sorted': <built-in function sorted>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'sum': <built-in function sum>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'vars': <built-in function vars>, 'zip': <class 'zip'>}, '__cached__': '/home/runner/work/commutazzio/commutazzio/commutazzio/utils/__pycache__/memory_tools.cpython-310.pyc', '__doc__': None, '__file__': '/home/runner/work/commutazzio/commutazzio/commutazzio/utils/memory_tools.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': 'commutazzio.utils.memory_tools', '__package__': 'commutazzio.utils', '__spec__': ModuleSpec(name='commutazzio.utils.memory_tools', loader=<_frozen_importlib_external.SourceFileLoader object>, origin='/home/runner/work/commutazzio/commutazzio/commutazzio/utils/memory_tools.py'), 'asizeof': <module 'pympler.asizeof' from '/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pympler/asizeof.py'>, 'print_memory_usage': <function print_memory_usage>, 'print_memory_usage_of_all_variables': <function print_memory_usage_of_all_variables>})

commutazzio.utils.radius_tools module

commutazzio.utils.radius_tools.join_and_unique(arr1, arr2, precision=3)
commutazzio.utils.radius_tools.radii_generator(start, end, ladder_length)

Return a list of radius based on the input values.

commutazzio.utils.watch module

commutazzio.utils.watch.timeit(method)

https://medium.com/pythonhive/python-decorator-to-measure-the-execution-time-of-methods-fa04cb6bb36d

Module contents