brainstate.util.split_total

Contents

brainstate.util.split_total#

brainstate.util.split_total(total, fraction)[source]#

Calculate the number of epochs for simulation based on a total and a fraction.

This function determines the number of epochs to simulate given a total number of epochs and either a fraction or a specific number of epochs to run.

Parameters:
  • total (int) – The total number of epochs. Must be a positive integer.

  • fraction (int | float) – If float: A value between 0 and 1 representing the fraction of total epochs to run. If int: The specific number of epochs to run, must not exceed the total.

Returns:

The calculated number of epochs to simulate.

Return type:

int

Raises:
  • TypeError – If total is not an integer.

  • ValueError – If total is not positive, fraction is negative, or if fraction as float is > 1 or as int is > total.

Examples

>>> split_total(100, 0.5)
50
>>> split_total(100, 25)
25
>>> split_total(100, 1.5)  # Raises ValueError
ValueError: 'fraction' value cannot be greater than 1.