opengate.utility ================ .. py:module:: opengate.utility Attributes ---------- .. autoapisummary:: opengate.utility.git opengate.utility.g4_units Classes ------- .. autoapisummary:: opengate.utility.LazyModuleLoader Functions --------- .. autoapisummary:: opengate.utility.assert_equal_dic opengate.utility.ensure_directory_exists opengate.utility.get_material_name_variants opengate.utility.g4_best_unit opengate.utility.g4_best_unit_tuple opengate.utility.assert_key opengate.utility.assert_keys opengate.utility.indent opengate.utility.assert_unique_element_name opengate.utility.make_builders opengate.utility.read_mac_file_to_commands opengate.utility.ensure_filename_is_str opengate.utility.insert_suffix_before_extension opengate.utility.get_random_folder_name opengate.utility.get_rnd_seed opengate.utility.DDF opengate.utility.DD opengate.utility.print_dic opengate.utility.get_release_date opengate.utility.get_gate_folder opengate.utility.get_data_folder opengate.utility.get_tests_folder opengate.utility.get_contrib_path opengate.utility.print_opengate_info opengate.utility.calculate_variance opengate.utility.standard_error_c4_correction Module Contents --------------- .. py:class:: LazyModuleLoader(module_name) Lazy loading allows you to delay the loading of a module until it's actually needed. This can be useful if a module is expensive to load or if it may not be used in every execution of the program. We use it for some modules that was found to delay the startup time, in particular: - radioactivedecay and pandas in phidsources - torch and gaga in gansources (only required for some features) .. py:attribute:: module_name .. py:attribute:: module :value: None .. py:method:: __getattr__(name) .. py:data:: git .. py:function:: assert_equal_dic(d1, d2, name='') .. py:function:: ensure_directory_exists(directory) .. py:data:: g4_units .. py:function:: get_material_name_variants(material_name) Get different variants of a material name, e.g. with/without prepended G4_, only first letter capital. Intended to bridge inconsistencies in naming conventions. .. py:function:: g4_best_unit(value, unit_type) .. py:function:: g4_best_unit_tuple(value, unit_type) .. py:function:: assert_key(key: str, d: box.Box) .. py:function:: assert_keys(keys: list, d: box.Box) .. py:function:: indent(amount, text, ch=' ') Prefix the text with indent spaces https://stackoverflow.com/questions/8234274/how-to-indent-the-contents-of-a-multi-line-string .. py:function:: assert_unique_element_name(elements, name) .. py:function:: make_builders(class_names) Consider a list of Classname. For each, it builds a key/value, with: - the type of the class as key - and a lambda function that create an object of this class as value .. py:function:: read_mac_file_to_commands(filename) .. py:function:: ensure_filename_is_str(filename) .. py:function:: insert_suffix_before_extension(file_path, suffix, suffix_separator='-') .. py:function:: get_random_folder_name(size=8, create=True) .. py:function:: get_rnd_seed(seed) .. py:function:: DDF() Debug print current Function name .. py:function:: DD(arg) Debug print variable name and its value .. py:function:: print_dic(dic) .. py:function:: get_release_date(opengate_version) .. py:function:: get_gate_folder() .. py:function:: get_data_folder() .. py:function:: get_tests_folder() .. py:function:: get_contrib_path() .. py:function:: print_opengate_info() Print information about OpenGate and the environment .. py:function:: calculate_variance(value_array, squared_value_array, number_of_samples) .. py:function:: standard_error_c4_correction(n) Parameters ---------- n : integer Number of subsets (of the samples). Returns ------- c4 : double Factor to convert the biased standard error of the mean of subsets of the sample into an unbiased - assuming a normal distribution . Usage: standard_error(unbiased) = standard_deviation_of_mean(=biased) / c4 The reason is that the standard deviation of the mean of subsets of the sample X underestimates the true standard error. For n = 2 this underestimation is about 25%. Values for c4: n=2: 0.7979; n= 9: 0.9693