Skip to main content

internals.parameters

internals.parameters

Parameters: the container of a module’s or sim’s parameters (ss.Pars), and values that vary by level or in time (ss.by, ss.timeseries, ss.seasonal)

They exist so that a parameter is checked when set, and can vary in the same way however a model is written or run.

Used with: agents and compartments; declared and coded modules

Classes

Name Description
Pars Dict-like container of parameters
Static What an expression of parameters alone is evaluated with, outside the engine: see const_value()
TimeValue Base class for values that vary in time: called with the sim, they return the value at the current time
by A value for each level of one or more stratifications, or of people’s own properties
by_func A value for each level of one dimension from a function of the sim, ss.by(patch=fn), where fn(sim) gives one value per level
seasonal A value with a yearly cycle: mean × (1 + amplitude × cos(2π(t − peak))), with t in years (or another period)
timeseries A value that varies in time, given at some times and interpolated between them

Pars

internals.parameters.Pars(pars=None, **kwargs)

Dict-like container of parameters

Acts like an sc.obj(), except that adding new keys is disallowed by default, and auto-updates known types.

Parameters

Name Type Description Default
pars dict initial parameters to populate the object with None
kwargs additional key-value pairs merged with pars

Methods

Name Description
bare_units Warn about each parameter set to a bare number whose unit (that of its default) is not the sim’s, e.g. ss.SexualNet(dur=5) in a sim in days
bind Bind the values that vary (ss.timeseries, ss.seasonal, ss.by) to the module, now and when set later, so that once its model is
bounded The parameters of a module written as code that were given as ss.par (e.g. beta=ss.par(ss.peryear(0.1), bounds=[0.05, 1]), or cin_fn=dict(k=ss.par(0.3, bounds=[0.1, 0.5])) as “cin_fn.k”), by name; their values are used as any other’s
check_added Raise a KeyError for a key that was set (e.g. mod.pars.art_efficacy = 0.9) but never defined, before the
check_key_mismatch Check whether additional keys are being added to the dictionary
forget_bare Forget the notes of note_bare() for these keys: given again, or a module’s own defaults
lock Lock the parameters, so that setting a key that doesn’t exist raises an error
note_bare Note that a parameter with a unit (or a distribution of values with one) was set to a bare number, which keeps that unit
to_json Convert to JSON representation
update Update internal dict with new pars.
with_bounded The parameters as a dict, with those given as ss.par as they were given (in a dict parameter too), as update() takes them
bare_units
internals.parameters.Pars.bare_units(unit, label)

Warn about each parameter set to a bare number whose unit (that of its default) is not the sim’s, e.g. ss.SexualNet(dur=5) in a sim in days

bind
internals.parameters.Pars.bind(module)

Bind the values that vary (ss.timeseries, ss.seasonal, ss.by) to the module, now and when set later, so that once its model is built (from init_post() on), arithmetic on one (self.pars.emergence * n, np.exp(-self.pars.k)) is done on its value now (see now()), as for a declared parameter (ss.par); before then, it builds an expression, as in a rate. One of typed values is typed now, as a typed value in the parameters is, so self.pars.rate.to_prob() works on either

bounded
internals.parameters.Pars.bounded()

The parameters of a module written as code that were given as ss.par (e.g. beta=ss.par(ss.peryear(0.1), bounds=[0.05, 1]), or cin_fn=dict(k=ss.par(0.3, bounds=[0.1, 0.5])) as “cin_fn.k”), by name; their values are used as any other’s

check_added
internals.parameters.Pars.check_added(label)

Raise a KeyError for a key that was set (e.g. mod.pars.art_efficacy = 0.9) but never defined, before the parameters were locked: a misspelt or renamed parameter, which would otherwise silently do nothing

check_key_mismatch
internals.parameters.Pars.check_key_mismatch(pars)

Check whether additional keys are being added to the dictionary

forget_bare
internals.parameters.Pars.forget_bare(keys)

Forget the notes of note_bare() for these keys: given again, or a module’s own defaults

lock
internals.parameters.Pars.lock(locked=True)

Lock the parameters, so that setting a key that doesn’t exist raises an error

Parameters are locked when the sim is initialized, so that e.g. a typo in sim.pars['rand_sed'] = 2 raises an error rather than silently doing nothing. Use pars.lock(False) to unlock, or pars.update(create=True) to add a new key.

Parameters
Name Type Description Default
locked bool whether to lock, or unlock with False True
note_bare
internals.parameters.Pars.note_bare(key, old, new)

Note that a parameter with a unit (or a distribution of values with one) was set to a bare number, which keeps that unit

to_json
internals.parameters.Pars.to_json(**kwargs)

Convert to JSON representation

Parameters
Name Type Description Default
**kwargs dict passed to sc.jsonify()
update
internals.parameters.Pars.update(pars=None, create=False, **kwargs)

Update internal dict with new pars.

A new value replaces the old one, except that a declared parameter (ss.par) takes the value and keeps its name and bounds, a bare number for a typed value keeps its unit, and a single value for a distribution sets its main parameter (see _update_dist()). To change one parameter of a distribution, use its own method, e.g. pars.dur_inf.set(mean=8).

Parameters
Name Type Description Default
pars dict the parameters to update (if None, do nothing) None
create bool if create is False, then raise a KeyNotFoundError if the key does not already exist False
kwargs dict merged with pars
with_bounded
internals.parameters.Pars.with_bounded()

The parameters as a dict, with those given as ss.par as they were given (in a dict parameter too), as update() takes them

Static

internals.parameters.Static()

What an expression of parameters alone is evaluated with, outside the engine: see const_value()

It exists so that such an expression can be read before the sim has an engine.

TimeValue

internals.parameters.TimeValue()

Base class for values that vary in time: called with the sim, they return the value at the current time

It exists so that ss.timeseries and ss.seasonal can be used wherever a number can.

Attributes

Name Description
pars The parameters in its values, e.g. smin in ss.seasonal(mean=(1 + smin)/2, …)
typed The typed quantities it holds, used to infer the sim’s unit

Methods

Name Description
series The value at each of an array of years, converted to plain numbers by convert
series
internals.parameters.TimeValue.series(years, sim, convert)

The value at each of an array of years, converted to plain numbers by convert

Parameters
Name Type Description Default
years array the years, as decimals required
sim ss.Sim the sim required
convert func the function to convert each value to a number required

by

internals.parameters.by(table=None, dims=None, **kwargs)

A value for each level of one or more stratifications, or of people’s own properties

Use it for a parameter that differs between groups, e.g. a higher transmission rate for children, or a death rate by age and sex.

With several dimensions as keywords, the value of a group is the product of its value in each. A table gives every combination directly: it has a column for each stratification (holding the labels of its levels) and a column of values.

A property of people that is not a dimension of the sim (e.g. sex, read from people.female, or a property such as urban) is read from each person, as agents: give its values by name (sex=dict(female=..., male=...)), or as a table. A column of numbers in a table holds the lower edges of bins (the last one open-ended), so a table by single year of age works as agents whatever the model’s age groups (a compartmental run needs bins whose edges are those of the groups, or coarser: a group split by a bin has no one value, and is refused); a row whose key is None gives the value for people with no value of the property, who otherwise get the mean over the levels.

Parameters

Name Type Description Default
table df / array a dataframe (or a dict of columns) with a column per stratification or property and a column named value; or, with dims, an array with one axis per dimension None
dims list the dimensions of the axes of an array given as table None
kwargs dict each dimension, and one value per level (a list, by position), or a dict of values by label (or, for one dimension, by lower bin edge if the keys are numbers, as in a table: ss.by(age={0: 0, 15: 0.3}))

A value may itself vary in time (ss.timeseries or ss.seasonal), in the keyword and table forms.

Arithmetic with a number, or with another ss.by over the same levels, gives an ss.by; anything else (e.g. tables by different bins, a count, or np.minimum(by, 1)) is an expression, worked out where it is used.

Examples

beta = ss.by(age=[0.08, 0.05, 0.03])
beta = ss.by(age=[0.08, 0.05, 0.03], sex=[1.0, 0.8]) # One per age group and sex: the product
init = ss.by(dict(age=['child', 'adult'], patch=['north', 'north'], value=[10, 5])) # Every other combination is 0
pop = ss.by([[3000, 1000], [5000, 2000]], dims=['age', 'patch']) # Ages by row, places by column
beta = ss.by(age=[ss.timeseries({2020: 0.08, 2021: 0.04}), 0.05, 0.03]) # Children's value changes in 2021
mu = ss.by(sex=dict(female=0.008, male=0.011)) # From people.female, with or without a dimension by sex
p = ss.by(dict(age=range(15, 50), value=vals)) # By single year of age (bins with these lower edges)

Attributes

Name Description
dim The dimension, if there is one
items Every value it holds
values The values, if there is one dimension
varies Whether any of its values varies in time

Methods

Name Description
as_table The values as a table, if they are one or are given by label over one dimension (ss.by(sex=dict(...))); else None
cached Something worked out from the values once, until they change (e.g. a table’s layout); with sim, for that sim only
check Check the values against the sim’s dimensions, and that a property of people that is not one is given by value; returns the positions of the sim’s dimensions it is by, and those dimensions
converter A function that gives a value as a number: a value that varies in time is taken at the sim’s current time, or at year if given
grid The value for every combination of the levels of its dimensions: its values (see tabulate()) at the position of each group
group_positions The number of positions along one of the sim’s dimensions, and each group’s position along it: its level, the key of its label, or the bin its lower edge is in (a group split by a table’s bins raising, since it has no one value)
is_count Whether the values are whole numbers (so that a 1 is one person rather than everyone)
keys How the values along one dimension are given: (‘edges’, array) for a table’s column of numbers (lower bin edges), (‘keys’, labels) for a table’s column of labels or a dict of values by label, or None for values by position
keys_id The keys of one dimension as a hashable tuple, for caching the positions of agents along it
level_items The values given for a dimension, in the order of its levels (rest for a level left out): whether it is one value for every level, and the values
lookup As agents: the value of each agent (indexed by UID, or for uids), from their own value of each property, or their level of each dimension:
map A new ss.by with a function applied to each value, e.g. 1/by (with several dimensions as keywords, only scaling, since the value of a group is their product)
on_people Whether, as agents, it is read from each person’s own values rather than by group: over a property that is not a dimension of the sim, or a table whose numbers are bin edges other than the dimension’s (e.g. single years of age, against age groups)
per_group The value for each group of the sim
position_plan How to find agents’ positions along one dimension: a function of the UIDs (None for everyone) that gives the number of levels and the positions; see positions()
positions As agents: the number of levels along one dimension, and each agent’s position along it (indexed by UID, or for uids), with that number for people with no value
row_index A table’s rows as positions along each of its dimensions, by its own keys (see keys()), with the number of keys for a row with no value
row_values A table’s values, one per row, as numbers
series The value for each group of the sim at each of an array of years (years by groups), as per_group() gives them one year at a time, with
split_groups The first dimension whose groups a table’s bins split (an edge inside a group, e.g. single years of age on 5-year age groups), so that a group has no one value and only agents can read it; None if there is none
tabulate The value at every combination of positions along its dimensions (sizes of each, as positions() or group_positions() give them), as
to_json The value as plain data, for sim.to_json()
as_table
internals.parameters.by.as_table()

The values as a table, if they are one or are given by label over one dimension (ss.by(sex=dict(...))); else None

cached
internals.parameters.by.cached(key, func, sim=None)

Something worked out from the values once, until they change (e.g. a table’s layout); with sim, for that sim only

check
internals.parameters.by.check(sim)

Check the values against the sim’s dimensions, and that a property of people that is not one is given by value; returns the positions of the sim’s dimensions it is by, and those dimensions

converter
internals.parameters.by.converter(sim, convert=None, year=None)

A function that gives a value as a number: a value that varies in time is taken at the sim’s current time, or at year if given

grid
internals.parameters.by.grid(sim, convert=None, year=None)

The value for every combination of the levels of its dimensions: its values (see tabulate()) at the position of each group

Returns the positions of the dimensions in the sim, and an array with one axis for each. A value that varies in time is taken at the sim’s current time, or at year if given.

group_positions
internals.parameters.by.group_positions(sim, strat)

The number of positions along one of the sim’s dimensions, and each group’s position along it: its level, the key of its label, or the bin its lower edge is in (a group split by a table’s bins raising, since it has no one value)

is_count
internals.parameters.by.is_count()

Whether the values are whole numbers (so that a 1 is one person rather than everyone)

keys
internals.parameters.by.keys(dim)

How the values along one dimension are given: (‘edges’, array) for a table’s column of numbers (lower bin edges), (‘keys’, labels) for a table’s column of labels or a dict of values by label, or None for values by position

keys_id
internals.parameters.by.keys_id(dim)

The keys of one dimension as a hashable tuple, for caching the positions of agents along it

level_items
internals.parameters.by.level_items(strat, vals, rest=None)

The values given for a dimension, in the order of its levels (rest for a level left out): whether it is one value for every level, and the values

lookup
internals.parameters.by.lookup(
    sim,
    convert=None,
    year=None,
    cache=None,
    uids=None,
)

As agents: the value of each agent (indexed by UID, or for uids), from their own value of each property, or their level of each dimension: its values (see tabulate()) at each agent’s positions

Parameters
Name Type Description Default
cache dict where to keep each agent’s position along a dimension, for other values by the same keys (e.g. the same age bins), and the table, while people’s values are unchanged None
uids uids these agents alone, which is much faster when they are few (e.g. those entering a state); the value of people with no value along a dimension is then worked out only if one of them has none None
map
internals.parameters.by.map(func)

A new ss.by with a function applied to each value, e.g. 1/by (with several dimensions as keywords, only scaling, since the value of a group is their product)

Parameters
Name Type Description Default
func func the function, called on each value required
on_people
internals.parameters.by.on_people(sim)

Whether, as agents, it is read from each person’s own values rather than by group: over a property that is not a dimension of the sim, or a table whose numbers are bin edges other than the dimension’s (e.g. single years of age, against age groups)

per_group
internals.parameters.by.per_group(sim, convert=None, year=None)

The value for each group of the sim

Parameters
Name Type Description Default
sim ss.Sim the sim required
convert func the function to convert each value to a number None
year float the year, for a value that varies in time; if None, the current time None
position_plan
internals.parameters.by.position_plan(sim, dim)

How to find agents’ positions along one dimension: a function of the UIDs (None for everyone) that gives the number of levels and the positions; see positions()

positions
internals.parameters.by.positions(sim, dim, uids=None)

As agents: the number of levels along one dimension, and each agent’s position along it (indexed by UID, or for uids), with that number for people with no value

row_index
internals.parameters.by.row_index()

A table’s rows as positions along each of its dimensions, by its own keys (see keys()), with the number of keys for a row with no value

row_values
internals.parameters.by.row_values(convert)

A table’s values, one per row, as numbers

series
internals.parameters.by.series(years, sim, convert=None)

The value for each group of the sim at each of an array of years (years by groups), as per_group() gives them one year at a time, with each value that varies in time worked out for every year at once (a value for each level of some dimensions: otherwise a year at a time)

Parameters
Name Type Description Default
years array the years, as decimals required
sim ss.Sim the sim required
convert func the function to convert each value to a number None
split_groups
internals.parameters.by.split_groups(sim)

The first dimension whose groups a table’s bins split (an edge inside a group, e.g. single years of age on 5-year age groups), so that a group has no one value and only agents can read it; None if there is none

tabulate
internals.parameters.by.tabulate(sizes, convert, weights=None)

The value at every combination of positions along its dimensions (sizes of each, as positions() or group_positions() give them), as numbers, with one more position along each for no value: given by a row for no value, or, with weights (for each dimension, the people at each position, or None where no one needs it), the mean over the positions; otherwise 0 (a table) or NaN

to_json
internals.parameters.by.to_json()

The value as plain data, for sim.to_json()

by_func

internals.parameters.by_func(dim, func)

A value for each level of one dimension from a function of the sim, ss.by(patch=fn), where fn(sim) gives one value per level (e.g. a value for each place from code beside a declared model), worked out once a step and read by every solver as a value by level (ss.by(patch=[...])) is, whatever other dimensions the sim has

Parameters

Name Type Description Default
dim str the dimension required
func func a function of the sim, giving one value per level of the dimension (or one number) required

Methods

Name Description
levels The function’s values now, converted to numbers in the sim’s unit: one number, or an ss.by over the dimension, which each solver reads as it reads any
levels
internals.parameters.by_func.levels(sim, convert)

The function’s values now, converted to numbers in the sim’s unit: one number, or an ss.by over the dimension, which each solver reads as it reads any

seasonal

internals.parameters.seasonal(mean=1.0, amplitude=0.0, peak=0.0, period=None)

A value with a yearly cycle: mean × (1 + amplitude × cos(2π(t − peak))), with t in years (or another period)

It can be used wherever a value or a function of the sim can. In a sim with no dates, time starts at the beginning of a year.

Parameters

Name Type Description Default
mean any the mean over the year: a number or a typed quantity 1.0
amplitude float the size of the cycle relative to the mean (0.3 means from 70% to 130% of it) 0.0
peak str / float / dur when the value is highest: a month (its middle is used), a fraction of the year (0 to 1), or a time of year (e.g. ss.days(142)) 0.0
period dur / float the length of the cycle (default a year), e.g. ss.years(0.5) for two peaks a year, the first at peak; a number is in years None

Examples

beta = ss.seasonal(mean=0.3, amplitude=0.4, peak='January')
S, I = ss.states(2)
sis = ss.Disease(infection=S >> I @ beta*I, recovery=ss.Transition(I, S, dur=10), init_prev=0.01)
sim = ss.Sim(sis, start='2020-01-01', stop='2023-01-01').run()
rains = ss.seasonal(amplitude=0.5, peak='April', period=ss.years(0.5)) # Peaks in April and October

Methods

Name Description
at The value at a year
factor The value relative to the mean, at a year or an array of them
series The value at each of an array of years, converted to plain numbers by convert
at
internals.parameters.seasonal.at(year, sim=None)

The value at a year

Parameters
Name Type Description Default
year float the year, as a decimal required
sim ss.Sim not used; present to match ss.timeseries None
factor
internals.parameters.seasonal.factor(year)

The value relative to the mean, at a year or an array of them

Parameters
Name Type Description Default
year float / array the year or years, as decimals required
series
internals.parameters.seasonal.series(years, sim, convert)

The value at each of an array of years, converted to plain numbers by convert

Parameters
Name Type Description Default
years array the years, as decimals required
sim ss.Sim the sim required
convert func the function to convert each value to a number required

timeseries

internals.parameters.timeseries(
    data,
    values=None,
    interpolation='step',
    period=None,
)

A value that varies in time, given at some times and interpolated between them

It can be used wherever a value or a function of the sim can: as a rate or a duration, as the amount of ss.modify(), or as the coverage or capacity of a delivery. Before the first time the first value is used, and after the last time the last, so a value that holds from before the sim needs no time of its own: give it at the first time you have. A bare time is read as the sim reads any (see ss.timeline): a calendar year if the sim has a calendar (a start that is a date or a year), however small, else a time in its unit from 0; a duration is a time after the start (e.g. ss.days(91), 91 days in; with no calendar, day 91, the same when the start is 0). A bare value is read in the module’s unit, as any other; to give the values a unit, put the series in a type (ss.peryear(ss.timeseries(...)), a series of rates per year), or give each value one.

Parameters

Name Type Description Default
data dict / str / dataframe / list the value at each time, as a dict, a dataframe (the first column is the time, the second the value), or the name of a file holding one; or the times, with the values as the second argument (ss.timeseries(times, values)). A time is a date, a bare number (a calendar year in a sim with a calendar, e.g. 2030, and otherwise a time in the sim’s unit from 0), or a duration, that long after the start of the sim required
values list the values, if data is the times None
interpolation str how to interpolate: ‘step’ (each value holds until the next, as for a policy that starts on a date), ‘linear’ (a steady change from each value to the next, as for coverage that is scaled up), or ‘cosine’ (a smooth S-shaped change between each value and the next, as MEmilio’s dampings) 'step'
period dur if given, the series repeats with this period, measured from its first time (e.g. ss.years(1) for a yearly pattern given over one year); keyed by durations, they are the times within each cycle, from the start of the sim (e.g. {ss.years(k/12): v[k] ...}, one value per month) None

Examples

beta = ss.timeseries({'2020-01-01': 0.3, '2020-03-15': 0.1, '2020-06-01': 0.2})
decay = ss.timeseries({0: 0.1, 91: 0.2, 183: 0.15, 274: 0.1}, period=ss.days(365)) # The same each year, in a sim in days with no calendar
season = ss.timeseries({ss.months(k): v for k,v in enumerate([1, 2, 4, 2, 1, 1])}, period=ss.months(6)) # Twice a year from the sim's start, with or without a calendar
mortality = ss.peryear(ss.timeseries({2000: 0.05, 2020: 0.02})) # Rates per year: 0.05 before 2000, and 0.02 after 2020
S, I, R = ss.states(3)
sir = ss.Disease(infection=S >> I @ beta*I, recovery=ss.Transition(I, R, dur=10), init_prev=0.01)
sim = ss.Sim(sir, start='2020-01-01', stop='2020-09-01').run()

Methods

Name Description
at The value at a year, interpolated between the times given
map A new time series with a function applied to each value, e.g. ss.peryear(ts), whose values are rates per year
series The value at each of an array of years, converted to plain numbers by convert
weights For a year (or an array of them), the index of the value before it, and the weight of the value after it
years The times as years on the sim’s timeline (a bare time is a year if the sim has a calendar, else a time in its unit from 0; a duration is that long after the sim’s start with a calendar, else a time from 0)
at
internals.parameters.timeseries.at(year, sim)

The value at a year, interpolated between the times given

Parameters
Name Type Description Default
year float the year, as a decimal required
sim ss.Sim the sim required
map
internals.parameters.timeseries.map(func)

A new time series with a function applied to each value, e.g. ss.peryear(ts), whose values are rates per year

Parameters
Name Type Description Default
func func the function, called on each value required
series
internals.parameters.timeseries.series(years, sim, convert)

The value at each of an array of years, converted to plain numbers by convert

Parameters
Name Type Description Default
years array the years, as decimals required
sim ss.Sim the sim required
convert func the function to convert each value to a number required
weights
internals.parameters.timeseries.weights(year, sim)

For a year (or an array of them), the index of the value before it, and the weight of the value after it

Parameters
Name Type Description Default
year float / array the year or years, as decimals required
sim ss.Sim the sim required
years
internals.parameters.timeseries.years(sim)

The times as years on the sim’s timeline (a bare time is a year if the sim has a calendar, else a time in its unit from 0; a duration is that long after the sim’s start with a calendar, else a time from 0)

Parameters
Name Type Description Default
sim ss.Sim the sim required

Functions

Name Description
bind Bind a value that varies (ss.timeseries, ss.seasonal, ss.by), or a parameter that its module’s model does not use (e.g. one kept for its code), to the module whose parameter it is (see Pars.bind())
check_verbose Check that verbose is 0 (print nothing), a fraction (as 1, with progress each time that fraction of the run is done, e.g. 0.1 for every 10%), 1 (the solver, notes, and progress), or 2 or more (everything), and return it as an integer or the fraction
const_value The value of a number or of an expression of parameters (e.g. (1 + smin)/2), as it is now
current_value A value as code reads it now, in the sim’s unit (see ss.Module._value()): a typed value as a number, a value that varies in time at the current time, and a value by level for each level; cache keeps the typed values converted (see ss.solvers.convert())
has_par Whether a value is a plain dict with a value given as ss.par, e.g. dict(k=ss.par(0.3, bounds=[0.1, 0.5])) (see Pars.update())
isnull Whether a value in a table is missing (None or NaN), e.g. the row for people with no value of a property
now The value now of a value that varies, bound to a module (see Pars.bind()) whose sim is initialized; else None. If its values are
replaced_dist Warn that a single value given for a declared parameter whose default is a distribution (not an exponential) replaces it, e.g. dur=ss.days(10) for a lognormal is an exponential
starting A starting value (init=, init_n=, or init_prev=, or a parameter holding one), where an ss.by given by label may leave levels out,
typed_attr A typed value’s own attribute (e.g. .to_prob()) of a value that varies, on its value now (see now()); for __getattr__()
typed_now The value now of a value that varies whose values are typed, as a typed value (for an ss.by of one dimension, one per level, if all of one kind); else None

bind

internals.parameters.bind(val, module, key)

Bind a value that varies (ss.timeseries, ss.seasonal, ss.by), or a parameter that its module’s model does not use (e.g. one kept for its code), to the module whose parameter it is (see Pars.bind())

check_verbose

internals.parameters.check_verbose(verbose)

Check that verbose is 0 (print nothing), a fraction (as 1, with progress each time that fraction of the run is done, e.g. 0.1 for every 10%), 1 (the solver, notes, and progress), or 2 or more (everything), and return it as an integer or the fraction

const_value

internals.parameters.const_value(val)

The value of a number or of an expression of parameters (e.g. (1 + smin)/2), as it is now

current_value

internals.parameters.current_value(val, sim, cache=None)

A value as code reads it now, in the sim’s unit (see ss.Module._value()): a typed value as a number, a value that varies in time at the current time, and a value by level for each level; cache keeps the typed values converted (see ss.solvers.convert())

has_par

internals.parameters.has_par(value)

Whether a value is a plain dict with a value given as ss.par, e.g. dict(k=ss.par(0.3, bounds=[0.1, 0.5])) (see Pars.update())

isnull

internals.parameters.isnull(val)

Whether a value in a table is missing (None or NaN), e.g. the row for people with no value of a property

now

internals.parameters.now(val)

The value now of a value that varies, bound to a module (see Pars.bind()) whose sim is initialized; else None. If its values are typed (e.g. ss.timeseries({2000: ss.peryear(0.1), 2010: ss.peryear(0.2)})), it is typed (an ss.peryear), as a typed value in a module’s parameters is, so .to_prob() and .to_dt() work on either (see typed_now()); otherwise a number in the sim’s unit, as current_value() gives it

replaced_dist

internals.parameters.replaced_dist(key, old, new)

Warn that a single value given for a declared parameter whose default is a distribution (not an exponential) replaces it, e.g. dur=ss.days(10) for a lognormal is an exponential

starting

internals.parameters.starting(val)

A starting value (init=, init_n=, or init_prev=, or a parameter holding one), where an ss.by given by label may leave levels out, which start at 0, e.g. init_n=dict(I=ss.by(patch={'Nairobi': 10})); a rate or other parameter by label needs every level, since a missing one there is more likely a mistake. Returns the value to use (a copy, so the same ss.by used elsewhere still needs every level).

typed_attr

internals.parameters.typed_attr(val, attr)

A typed value’s own attribute (e.g. .to_prob()) of a value that varies, on its value now (see now()); for __getattr__()

typed_now

internals.parameters.typed_now(val, sim)

The value now of a value that varies whose values are typed, as a typed value (for an ss.by of one dimension, one per level, if all of one kind); else None