MetaWards.utils API Detail

Functions

accepts_stage(func)

Return whether the passed function accepts the “stage” argument, meaning that it can do different things for different day stages

add_lookup(network[, nthreads])

Add in metadata about the network that can be used to look up wards by name of location or region etc.

add_wards_network_distance(network, nthreads)

Reads the location data in network.parameters.input_files.position and adds those locations to all of the nodes in the passed network.

aggregate_networks(network, profiler, nthreads)

Aggregate all of the Susceptibles data from the demographic sub-networks into an overall total set of data that is stored in the overall network

assert_sane_network(network, profiler)

This function runs through and checks that the passed network is sane.

build_play_matrix(network, max_nodes, …)

Build the play matrix for the passed network

build_wards_network(params, profiler, …)

Creates a network of wards using the information provided in the file specified in parameters.input_files.work.

call_function_on_network(network, …[, …])

Call either ‘func’ or ‘parallel’ (depending on the number of threads, nthreads) on the passed Network, or on all demographic subnetworks

check_for_updates([dry_run])

Check if a newer version of MetaWards is available.

clear_all_infections(infections, …)

Clears all infections associated with a model run

Console()

This is a singleton class that provides access to printing and logging functions to the console.

create_int_array(size, default)

Create a new array.array of the specified size.

create_double_array(size, default)

Create a new array.array of the specified size.

create_string_array(size, unicode default)

Create an array of python strings of size ‘size’, optionally initialised with ‘default’

create_thread_generators(rng, nthreads)

Return a set of random number generators, one for each thread - these are seeded using the next ‘nthreads’ random numbers drawn from the passed generator

delete_ran_binomial(rng)

Delete the passed random number generator.

fill_in_gaps(network, max_nodes)

Fills in gaps in the network

get_available_num_threads()

Return the maximum number of threads that are recommended for this computer (the OMP_NUM_THREADS value)

get_functions(stage, network, population, …)

Return the functions that must be called for the specified stage of the day;

get_initialise_functions(**kwargs)

Convenience function that returns all of the functions that should be called during the initialisation step of the model (e.g.

get_finalise_functions(trajectory, **kwargs)

Convenience function that returns all of the functions that should be called during the finalisation step of the model (e.g.

get_model_loop_functions(**kwargs)

Convenience function that returns all of the functions that should be called during the model loop (i.e.

get_min_max_distances(network, nthreads, …)

Return the minimum and maximum distances recorded in the network

get_number_of_processes(parallel_scheme[, …])

This function works out how many processes have been set by the paralellisation system called ‘parallel_scheme’

initialise_infections(network)

Initialise the data structure used to store the infections

initialise_play_infections(network)

Initialise the space used to store the play infections

move_population_from_work_to_play(network, …)

This function is not used or implemented, but is implied by the naming scheme…

move_population_from_play_to_work(network, …)

And Vice Versa From Work to Play The relevant parameters are network.params.play_to_work and network.params.work_to_play

prepare_worker(params, demographics, options)

Prepare a worker to receive work to run a model using the passed parameters.

ran_binomial(rng, double p, n)

Return a random number drawn from the binomial distribution [p,n] (see gsl_ran_binomial for documentation)

ran_int(rng[, lower, upper])

Draw a random integer from [0,upper] inclusive

ran_uniform(rng)

Return a random double drawn from a uniform distribution between zero and one

read_done_file(filename)

This function reads the ‘done_file’ from ‘filename’ returning the list of seeded nodes

recalculate_work_denominator_day(network, …)

Recalculate the denominator_d for the wards (nodes) in the network for the normal links

recalculate_play_denominator_day(network, …)

Recalculate the denominator_d for the wards (nodes) in the network for the play links

rescale_play_matrix(network, nthreads, profiler)

Static Play At Home rescaling.

resize_array(a, size, default)

Resize the passed array to size ‘size’, adding ‘default’ if this will grow the array

reset_everything(network, profiler, nthreads)

Reset everything in the passed network so that it can be used for a new model run

reset_play_matrix(network, nthreads)

Resets the play entries in the passed Network.

reset_play_susceptibles(network, nthreads)

Resets the ward entries in the passed Network.

reset_work_matrix(network[, nthreads])

Resets the work entries in the passed Network.

run_model(network, infections, rngs, output_dir)

Actually run the model.

run_models(network, variables, population, …)

Run all of the models on the passed Network that are described by the passed VariableSets

run_worker(arguments)

Ask the worker to run a model using the passed variables and options.

safe_eval_number(s)

Convert ‘s’ to a number.

scale_link_susceptibles(links, ratio)

Scale the number of susceptibles in the passed Links by the passed scale ratio.

scale_node_susceptibles(nodes, ratio, …)

Scale the number of susceptibles in the passed Nodes by the passed scale ratios.

seed_ran_binomial(seed)

Seed and return the random binomial generator.

string_to_ints([string, strings])

Convert the passed string (or strings) containing integers (or ranges of integers) into a single sorted list of integers where no value is repeated

update_metawards([dry_run, user])

Update MetaWards to the latest version.

zero_workspace(workspace)

Classes

Profiler(name[, parent])

This is a simple profiling class that supports manual instrumenting of the code.

NullProfiler(name[, parent])

This is a null profiler that does nothing