Run Settings

Created on Tue Sep 27 16:45:51 2016

Contain methods to change settings in the whole package

@author: Jonas Eschle “Mayou36”

raredecay.settings.figure_save_config(file_formats=None, to_pickle=True, dpi=150)[source]

Change the save-options of figures.

If you initialized an output-path, the figures that are plotted during the run will be f. On one hand, they are saved as pictures in the given formats, on the other hand the figures (matplotlib) will be saved as a pickle-object (also in the output-folder) If the run was not initialized with an output-path, this function will have no effect on the behaviour of your script.

Parameters:
  • file_formats (str or list[str, str, str,..]) –

    The possible formats to save the figures to. Currently implemented are: [‘png’, ‘jpg’, ‘pdf’, ‘svg’]

    The default value (None) is [‘png’, ‘svg’]

  • to_pickle (boolean) – If True, the matplotlib-figures will be saved as a pickle-file allowing for later plotting. They are saved in the output-folder.
  • dpi (int) – The resolution of the images.
raredecay.settings.finalize(show_plots=True, play_sound_at_end=False)[source]

Finalize the run, (save figures and output) and return output.

Parameters:
  • show_plots (boolean) – If True, show the plots (plt.show()), if user prompt is activated, you first have to press enter to show them.
  • play_sound_at_end (boolean) – If true, a beep will be played at the end of the run
raredecay.settings.get_output_handler()[source]

Return an output handler, instance of OutputHandler().

This can be used to add output (text as well as figures) and save them easely. For more information see the docs of the OutputHandler

Returns:out – Return the output-handler currently in use by the script.
Return type:instance of OutputHandler
raredecay.settings.initialize(output_path=None, run_name='Test run', overwrite_existing=False, run_message='This is a test-run to test the package', verbosity=3, plot_verbosity=3, prompt_for_input=False, no_interactive_plots=False, logger_console_level='warning', logger_file_level='debug', n_cpu=1, gpu_in_use=False)[source]

Place before Imports! Initialize/change several parameters for the package.

Initialize a run and return an output handler. Most of the implemented function have things to plot or print, which are given to the output handler. You can also add output to it by yourself.

If an output_path is specified, all the output collected will be saved at the end of the run by calling finalize()

Parameters:
  • output_path (str or None) –

    If a string is provided, it is taken as the path to a folder, in which a folder containing all the output of the run will be created.

    If None, the output won’ be saved.

  • run_name (str) – The name of the run as well as of the folder that gets created.
  • overwrite_existing (boolean) – If True and the folder (run-name) exists already, it will be over-written. Else a number will be added to the name to create a new folder.
  • run_message (str) – A message, will be displayed in the output at the beginning.
  • verbosity (int {0, 1, 2, 3, 4, 5}) – How much of the output will be printed. There is a tradeoff between verbosity and importance.
  • plot_verbosity (int {0, 1, 2, 3, 4, 5}) – How much of the plots will be plotted for show. There is a tradeoff between plot_verbosity and plot_importance.
  • prompt_for_input (boolean) – If True, at the beginning of the run, a string can be entered to extend the run-name.
  • no_interactive_plots (boolean) – If True, the matplotlib backend is changed to a non-interactive one. This is required if no X-server is run, as for example on grids is the case.
  • logger_console_level (str {'debug', 'info', 'warning', 'error', 'critical'}) – The logger level on the consol
  • logger_file_level (str {'debug', 'info', 'warning', 'error', 'critical'}) – The logger level for files. Ignored if no output-path is specified.
  • n_cpu (int) – The number of cpus to use. Can be a negative number as well, where -1 means all, -2 all but one, -3 all but 2 etc.
  • gpu_in_use (boolean) – If True, the parallelisation for Theanets is switched of in order to be able to use it with (a single) gpu.
Returns:

out – Return the output-handler currently in use by the script.

Return type:

instance of OutputHandler

raredecay.settings.parallel_profile(n_cpu=-1, gpu_in_use=False)[source]

Set the parallel profile, the n_cpu to use.

Most of the functions do not have a number of threads option. You can change that here by either:

  • using a positive integer, which corresponds to the number of threads to use
  • using a negative integer. Then, -1 means to use all available (virtual) cores (resp. the number of threads). But sometimes you want to still work on your machine and have not all cpus used up. Therefore you can just use -2 (which will use all except of one; “all up to the second last”), -3 (which will use all except two; “all up to the third last”) etc.
Parameters:
  • n_cpu (int (not 0)) – The number of cpus to use, explanation see above.
  • gpu_in_use (boolean) – If a gpu is in use (say for nn), you can set this boolean to true in order to avoid parallel computation of the nn or to activate any other implemented gpu assistance.
raredecay.settings.set_random_seed(seed=None)[source]

Set the seed to the random generator to reproduce results.

Parameters:seed (int) – The seed for the random generator. If None, it won’t change anything
raredecay.settings.set_verbosity(verbosity=3, plot_verbosity=3)[source]

Change the verbosity of the package.