tisane.Exactly

class tisane.Exactly(value)

Bases: tisane.variable.NumberValue

Class for expressing exact values

Used to represent when the number_of_instances parameter of a variable (such as tisane.Unit, Numeric/tisane.Unit.numeric(), etc.) is supposed to be exactly value

Parameters

value (int) – the exact value to be used.

Methods

per([cardinality, number_of_instances])

Express a per relationship on a given Exactly

get_value

is_equal_to_one

is_greater_than_one

per(cardinality=None, number_of_instances=None)

Express a per relationship on a given Exactly

Even though cardinality and number_of_instances are both optional parameters, this method requires exactly one of them to be specified – you currently cannot specify both.

Parameters
  • cardinality (AbstractVariable, optional) – The AbstractVariable whose cardinality we want to use

  • number_of_instances (AbstractVariable, optional) – The AbstractVariable whose number of instances we want to use

Returns

An object representing a “_ per _” relationship.

Return type

tisane.variable.Per

See also

tisane.AtMost.per

create a per relationship with an AtMost multiplier

Examples

Rats are either given a supplement or a placebo three times a day, so exactly 3 per day

>>> import tisane as ts
>>> from tisane import Exactly
>>> rat = ts.Unit(name="rat_id", cardinality=30) # 30 rats in the study
>>> days = rat.ordinal(name="day_num", cardinality=28) # 4 weeks of data for each rat
>>> memory_test_result = rat.numeric(name="memory_test_result",
...                                  number_of_instances=days)
>>> supplements = rat.nominal(name="supplement",
...                           categories=["placebo", "supp"],
...                           number_of_instances=Exactly(3).per(cardinality=days))