indicator

indicator.cache

indicator.cache.CACHEABLE_TYPES

Indicator output types that can be cached.

indicator.cache.STR_FUNCTIONS

A mapping of a type => function to use to turn an object of this type into a cache key

indicator.cache.cache_indicator(cls, ind_func, period, data_in)[source]

cache_indicator() is the function used to cache return values of indicator.indicator.Indicator.

Parameters:
  • cls (subclass of indicator.indicator.Indicator) – Indicator to cache
  • ind_func (function) – Function which generates the indicator value
  • period – The time period with which to compute the indicator value
  • data_in – The input data to the indicator
indicator.cache.cache_simple(func, timeout=7200)[source]

cache_simple() is a decorator for caching a function of a single argument that returns a pickle-able object

indicator.indicator

class indicator.indicator.Indicator[source]
cache

A boolean indicating whether or not this indicator should be cached. Should be False for indicators with non-pickle-able output values.

classmethod input_is_query_set()[source]

True if the input type is a QuerySet

long_name

A long human-readable name for this indicator, like “Percentage of women 15-49 using modern family planning methods.

classmethod output_is_number()[source]

True if the output type is a subclass of numbers.Number.

classmethod output_is_percentage()[source]

True if the output type is indicator.percentage.Percentage.

short_name

A short human-readable name for this indicator, like “% FP”.

slug

A machine-friendly identifier string for this indicator, using a-z, A-Z, 0-9, and underscore.

type_in

Type of the data argument to this indicator. Often this will be an instantiated indicator.query_set_type.QuerySetType like QuerySetType(Patient).

type_out

The type of the return value of this indicator. Used to figure out whether or not it can be cached.

valid_for

How long to keep cached values for before expiring them.

class indicator.indicator.IndicatorDifference[source]

Subclass of indicator.indicator.Indicator for difference values. You give it the two indicators that make up the numerator and denominator values and it gives you back their difference.

cls_first

The inital indicator.indicator.Indicator value

cls_second

The number to subtract from the initial indicator.indicator.Indicator value

class indicator.indicator.IndicatorPercentage[source]

Subclass of indicator.indicator.Indicator for percentage values. You give it the two indicators that make up the numerator and denominator values and it gives you back a indicator.percentage.Percentage.

cls_den

The denominator indicator.indicator.Indicator

cls_num

The numerator indicator.indicator.Indicator

type_out

alias of Percentage

indicator.percentage

class indicator.percentage.Percentage[source]

This is exactly like fractions.Fraction except that Percentage never simplifies the numerator or denominator.

empty[source]
short_str()[source]

indicator.query_set_type

class indicator.query_set_type.QuerySetType(mtype)[source]

QuerySetType is a bogus type just used with indicator.indicator.Indicator definitions to specify the particular model type of the QuerySet it accepts as an input argument.

This is not duck-typing and it makes me feel dirty. Let’s figure out a better way to do this.

Table Of Contents

Previous topic

checksum

Next topic

Frequently Asked Questions

This Page