opengate.base ============= .. py:module:: opengate.base Classes ------- .. autoapisummary:: opengate.base.MetaUserInfo opengate.base.MetaUserInfoSingleton opengate.base.GateObjectSingleton opengate.base.GateObject Functions --------- .. autoapisummary:: opengate.base.process_cls opengate.base.check_property_name opengate.base.check_property opengate.base.digest_user_info_defaults opengate.base.add_properties_to_class opengate.base._make_property opengate.base.make_docstring opengate.base.restore_userinfo_properties opengate.base.attach_methods opengate.base.recursive_userinfo_to_dict opengate.base.find_paths_in_gate_object_dictionary opengate.base.recursively_search_object opengate.base.find_all_gate_objects opengate.base.find_all_paths opengate.base._get_user_info_options opengate.base.create_gate_object_from_dict Module Contents --------------- .. py:class:: MetaUserInfo Bases: :py:obj:`type` .. py:attribute:: _created_classes .. py:method:: __call__(*args, **kwargs) .. py:class:: MetaUserInfoSingleton Bases: :py:obj:`type` .. py:attribute:: _instances .. py:attribute:: _created_classes .. py:method:: __call__(*args, **kwargs) .. py:function:: process_cls(cls) Digest the class's user_infos and store the augmented class in a dictionary inside the meta class which handles the class creation. Note: type(cls) yields the meta class MetaUserInfo or MetaUserInfoSingleton, depending on the class in question (e.g. GateObject, GateObjectSingleton). .. py:function:: check_property_name(name) .. py:function:: check_property(property_name, value, defaultvalue) .. py:function:: digest_user_info_defaults(cls) .. py:function:: add_properties_to_class(cls, user_info_defaults) Add user_info defaults as properties to class if not yet present. .. py:function:: _make_property(property_name, options=None, container_dict=None) Return a property that stores the user_info item in a dictionary which is an attribute of the object (self). .. py:function:: make_docstring(cls, user_info_defaults) .. py:function:: restore_userinfo_properties(cls, attributes) .. py:function:: attach_methods(GateObjectClass) Convenience function to avoid redundant code. Can be used to add common methods to classes that differ otherwise, e.g. GateObject and GateObjectSingleton. .. py:class:: GateObjectSingleton .. py:attribute:: user_info_defaults .. py:class:: GateObject .. py:attribute:: user_info_defaults .. py:method:: clone_user_info(other_obj) .. py:method:: to_dictionary() .. py:method:: from_dictionary(d) .. py:function:: recursive_userinfo_to_dict(obj) Walk recursively across entries of user_info and convert to appropriate structure. Dictionary-like structures are mapped to dictionary and walked across recursively. List-like structures are mapped to lists and walked across recursively. GateObject-like objects are converted through their to_dictionary() method. All other input (presumably common data types including numpy structures) is left untouched. .. py:function:: find_paths_in_gate_object_dictionary(go_dict, only_input_files=False) .. py:function:: recursively_search_object(obj, condition=lambda x: True) .. py:function:: find_all_gate_objects(dct) .. py:function:: find_all_paths(dct) .. py:function:: _get_user_info_options(user_info_name, object_type, class_module) Utility function to retrieve the options associated with a user info given the class name, the module in which the class is defined, and the name of the user info. .. py:function:: create_gate_object_from_dict(dct) Function to (re-)create an object derived from GateObject based on a dictionary. Used as part of the deserialization chain, when reading simulations stored as JSON file.