aiidalab_widgets_base.utils package#

Submodules#

aiidalab_widgets_base.utils.exceptions module#

exception aiidalab_widgets_base.utils.exceptions.ListOrTuppleError(value)[source]#

Bases: TypeError

Raised when the provided value is not a list or a tupple.

__init__(value)[source]#
__module__ = 'aiidalab_widgets_base.utils.exceptions'#
__weakref__#

list of weak references to the object (if defined)

Module contents#

Some utility functions used acrross the repository.

class aiidalab_widgets_base.utils.PinholeCamera(matrix)[source]#

Bases: object

__dict__ = mappingproxy({'__module__': 'aiidalab_widgets_base.utils', '__init__': <function PinholeCamera.__init__>, 'screen_to_vector': <function PinholeCamera.screen_to_vector>, 'inverse_matrix': <property object>, '__dict__': <attribute '__dict__' of 'PinholeCamera' objects>, '__weakref__': <attribute '__weakref__' of 'PinholeCamera' objects>, '__doc__': None, '__annotations__': {}})#
__init__(matrix)[source]#
__module__ = 'aiidalab_widgets_base.utils'#
__weakref__#

list of weak references to the object (if defined)

property inverse_matrix#
screen_to_vector(move_vector)[source]#

Converts vector from the screen coordinates to the normalized vector in 3D.

class aiidalab_widgets_base.utils.StatusHTML(**kwargs: Any)[source]#

Bases: _StatusWidgetMixin, HTML

Show temporary HTML messages for example for status updates.

__annotations__ = {}#
__module__ = 'aiidalab_widgets_base.utils'#
_all_trait_default_generators: t.Dict[str, t.Any] = {'_display_callbacks': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, '_dom_classes': <bound method TraitType.default of <ipywidgets.widgets.trait_types.TypedTuple object>>, '_model_module': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, '_model_module_version': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, '_model_name': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, '_msg_callbacks': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, '_property_lock': <bound method TraitType.default of <traitlets.traitlets.Dict object>>, '_states_to_send': <bound method TraitType.default of <traitlets.traitlets.Set object>>, '_view_count': <bound method TraitType.default of <traitlets.traitlets.Int object>>, '_view_module': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, '_view_module_version': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, '_view_name': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, 'comm': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, 'description': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, 'description_tooltip': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, 'keys': <traitlets.traitlets.DefaultHandler object>, 'layout': <bound method TraitType.default of <ipywidgets.widgets.trait_types.InstanceDict object>>, 'log': <traitlets.traitlets.DefaultHandler object>, 'message': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, 'placeholder': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>, 'style': <bound method TraitType.default of <ipywidgets.widgets.trait_types.InstanceDict object>>, 'value': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>}#
_descriptors = [<traitlets.traitlets.ObserveHandler object>, <traitlets.traitlets.DefaultHandler object>, <traitlets.traitlets.Instance object>, <ipywidgets.widgets.trait_types.TypedTuple object>, <traitlets.traitlets.DefaultHandler object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.ObserveHandler object>, <traitlets.traitlets.Dict object>, <traitlets.traitlets.Set object>, <traitlets.traitlets.Int object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.List object>, <ipywidgets.widgets.trait_types.InstanceDict object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.Unicode object>, <traitlets.traitlets.Unicode object>, <ipywidgets.widgets.trait_types.InstanceDict object>, <traitlets.traitlets.Unicode object>]#
_instance_inits = [<bound method ObserveHandler.instance_init of <traitlets.traitlets.ObserveHandler object>>, <bound method BaseDescriptor.instance_init of <traitlets.traitlets.DefaultHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method BaseDescriptor.instance_init of <traitlets.traitlets.DefaultHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method ObserveHandler.instance_init of <traitlets.traitlets.ObserveHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method Instance.instance_init of <ipywidgets.widgets.trait_types.InstanceDict object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method Instance.instance_init of <ipywidgets.widgets.trait_types.InstanceDict object>>]#
_observe_message#
_static_immutable_initial_values: t.Dict[str, t.Any] = {'_model_module': '@jupyter-widgets/controls', '_model_module_version': '1.5.0', '_model_name': 'HTMLModel', '_view_count': None, '_view_module': '@jupyter-widgets/controls', '_view_module_version': '1.5.0', '_view_name': 'HTMLView', 'comm': None, 'description': '', 'description_tooltip': None, 'message': '', 'placeholder': '\u200b', 'value': ''}#
_trait_default_generators = {}#
_traits: t.Dict[str, t.Any] = {'_display_callbacks': <traitlets.traitlets.Instance object>, '_dom_classes': <ipywidgets.widgets.trait_types.TypedTuple object>, '_model_module': <traitlets.traitlets.Unicode object>, '_model_module_version': <traitlets.traitlets.Unicode object>, '_model_name': <traitlets.traitlets.Unicode object>, '_msg_callbacks': <traitlets.traitlets.Instance object>, '_property_lock': <traitlets.traitlets.Dict object>, '_states_to_send': <traitlets.traitlets.Set object>, '_view_count': <traitlets.traitlets.Int object>, '_view_module': <traitlets.traitlets.Unicode object>, '_view_module_version': <traitlets.traitlets.Unicode object>, '_view_name': <traitlets.traitlets.Unicode object>, 'comm': <traitlets.traitlets.Instance object>, 'description': <traitlets.traitlets.Unicode object>, 'description_tooltip': <traitlets.traitlets.Unicode object>, 'keys': <traitlets.traitlets.List object>, 'layout': <ipywidgets.widgets.trait_types.InstanceDict object>, 'log': <traitlets.traitlets.Instance object>, 'message': <traitlets.traitlets.Unicode object>, 'placeholder': <traitlets.traitlets.Unicode object>, 'style': <ipywidgets.widgets.trait_types.InstanceDict object>, 'value': <traitlets.traitlets.Unicode object>}#
new_line = '<br>'#
class aiidalab_widgets_base.utils._StatusWidgetMixin(**kwargs: Any)[source]#

Bases: HasTraits

Show temporary messages for example for status updates. This is a mixin class that is meant to be part of an inheritance tree of an actual widget with a ‘value’ traitlet that is used to convey a status message. See the non-private classes below for examples.

__annotations__ = {}#
__init__(clear_after=3, *args, **kwargs)[source]#
__module__ = 'aiidalab_widgets_base.utils'#
_all_trait_default_generators: t.Dict[str, t.Any] = {'message': <bound method TraitType.default of <traitlets.traitlets.Unicode object>>}#
_clear_value()[source]#

Set widget .value to be an empty string.

_descriptors = [<traitlets.traitlets.Unicode object>]#
_instance_inits = []#
_static_immutable_initial_values: t.Dict[str, t.Any] = {'message': ''}#
_trait_default_generators = {}#
_traits: t.Dict[str, t.Any] = {'message': <traitlets.traitlets.Unicode object>}#
message#

A trait for unicode strings.

new_line = '\n'#
show_temporary_message(value, clear_after=None)[source]#

Show a temporary message and clear it after the given interval.

aiidalab_widgets_base.utils.ase2spglib(ase_structure: Atoms) Tuple[Any, Any, Any][source]#

Convert ase Atoms instance to spglib cell in the format defined at https://spglib.github.io/spglib/python-spglib.html#crystal-structure-cell

aiidalab_widgets_base.utils.find_ranges(iterable)[source]#

Yield range of consecutive numbers.

aiidalab_widgets_base.utils.get_ase_from_file(fname, file_format=None)[source]#

Get ASE structure object.

aiidalab_widgets_base.utils.get_formula(data_node)[source]#

A wrapper for getting a molecular formula out of the AiiDA Data node

aiidalab_widgets_base.utils.list_to_string_range(lst, shift=1)[source]#

Converts a list like [0, 2, 3, 4] into a string like ‘1 3..5’.

Shift used when e.g. for a user interface numbering starts from 1 not from 0

aiidalab_widgets_base.utils.predefine_settings(obj, **kwargs)[source]#

Specify some pre-defined settings.

aiidalab_widgets_base.utils.string_range_to_list(strng, shift=-1)[source]#

Converts a string like ‘1 3..5’ into a list like [0, 2, 3, 4].

Shift used when e.g. for a user interface numbering starts from 1 not from 0

aiidalab_widgets_base.utils.valid_arguments(arguments, valid_args)[source]#

Check whether provided arguments are valid.