API Reference¶
Subpackages¶
- fireant.database package
- fireant.slicer package
- Subpackages
- fireant.slicer.queries package
- Submodules
- fireant.slicer.queries.builder module
- fireant.slicer.queries.database module
- fireant.slicer.queries.finders module
- fireant.slicer.queries.logger module
- fireant.slicer.queries.makers module
- fireant.slicer.queries.references module
- fireant.slicer.queries.special_cases module
- Module contents
- fireant.slicer.widgets package
- Submodules
- fireant.slicer.widgets.base module
- fireant.slicer.widgets.csv module
- fireant.slicer.widgets.datatables module
- fireant.slicer.widgets.helpers module
- fireant.slicer.widgets.highcharts module
- fireant.slicer.widgets.matplotlib module
- fireant.slicer.widgets.pandas module
- fireant.slicer.widgets.reacttable module
- Module contents
- fireant.slicer.queries package
- Submodules
- fireant.slicer.base module
- fireant.slicer.dimensions module
- fireant.slicer.exceptions module
- fireant.slicer.filters module
- fireant.slicer.intervals module
- fireant.slicer.joins module
- fireant.slicer.metrics module
- fireant.slicer.operations module
- fireant.slicer.references module
- fireant.slicer.slicers module
- Module contents
- Subpackages
- fireant.tests package
- Subpackages
- fireant.tests.database package
- fireant.tests.slicer package
- Subpackages
- fireant.tests.slicer.queries package
- Submodules
- fireant.tests.slicer.queries.test_build_dimension_filters module
- fireant.tests.slicer.queries.test_build_dimensions module
- fireant.tests.slicer.queries.test_build_joins module
- fireant.tests.slicer.queries.test_build_metric_filters module
- fireant.tests.slicer.queries.test_build_metrics module
- fireant.tests.slicer.queries.test_build_operations module
- fireant.tests.slicer.queries.test_build_orderbys module
- fireant.tests.slicer.queries.test_build_pagination module
- fireant.tests.slicer.queries.test_build_references module
- fireant.tests.slicer.queries.test_build_render module
- fireant.tests.slicer.queries.test_builder module
- fireant.tests.slicer.queries.test_database module
- fireant.tests.slicer.queries.test_dimension_choices module
- Module contents
- fireant.tests.slicer.widgets package
- Submodules
- fireant.tests.slicer.widgets.test_csv module
- fireant.tests.slicer.widgets.test_datatables module
- fireant.tests.slicer.widgets.test_highcharts module
- fireant.tests.slicer.widgets.test_pandas module
- fireant.tests.slicer.widgets.test_reacttable module
- fireant.tests.slicer.widgets.test_widgets module
- Module contents
- fireant.tests.slicer.queries package
- Submodules
- fireant.tests.slicer.matchers module
- fireant.tests.slicer.mocks module
- fireant.tests.slicer.test_dimensions module
- fireant.tests.slicer.test_operations module
- fireant.tests.slicer.test_slicer module
- Module contents
- Subpackages
- Submodules
- fireant.tests.test_formats module
- fireant.tests.utils module
- Module contents
- Subpackages
Submodules¶
fireant.formats module¶
-
fireant.formats.
dimension_value
(value)[source]¶ Format a dimension value. This will coerce the raw string or date values into a proper primitive value like a string, float, or int.
Parameters: - value – The raw str or datetime value
- str_date – When True, dates and datetimes will be converted to ISO strings. The time is omitted for dates. When False, the datetime will be converted to a POSIX timestamp (millis-since-epoch).
-
fireant.formats.
metric_display
(value, prefix=None, suffix=None, precision=None)[source]¶ Converts a metric value into the display value by applying formatting.
Parameters: - value – The raw metric value.
- prefix – An optional prefix.
- suffix – An optional suffix.
- precision – The decimal precision, the number of decimal places to round to.
Returns: A formatted string containing the display value for the metric.
fireant.settings module¶
fireant.utils module¶
-
fireant.utils.
getdeepattr
(d, keys, default_value=None)[source]¶ Similar to the built-in getattr, this function accepts a list/tuple of keys to get a value deep in a dict
Given the following dict structure
d = { 'A': { '0': { 'a': 1, 'b': 2, } }, }
Calling getdeepattr with a key path to a value deep in the structure will return that value. If the value or any of the objects in the key path do not exist, then the default value is returned.
assert 1 == getdeepattr(d, ('A', '0', 'a')) assert 2 == getdeepattr(d, ('A', '0', 'b')) assert 0 == getdeepattr(d, ('A', '0', 'c'), default_value=0) assert 0 == getdeepattr(d, ('X', '0', 'a'), default_value=0)
Parameters: - d – A dict value with nested dict attributes.
- keys – A list/tuple path of keys in d to the desired value
- default_value – A default value that will be returned if the path keys does not yield a value.
Returns: The value following the path keys or default_value
-
fireant.utils.
groupby
(items, by)[source]¶ Group items using a function to derive a key.
Parameters: - items – The items to group
- by – A lambda function to create a key based on the item
Returns: an Ordered dict
-
fireant.utils.
immutable
(func)[source]¶ Decorator for wrapper “builder” functions. These are functions on the Query class or other classes used for building queries which mutate the query and return self. To make the build functions immutable, this decorator is used which will deepcopy the current instance. This decorator will return the return value of the inner function or the new copy of the instance. The inner function does not need to return self.
-
fireant.utils.
merge_dicts
(*dict_args)[source]¶ Given any number of dicts, shallow copy and merge into a new dict, precedence goes to key value pairs in latter dicts.
-
fireant.utils.
setdeepattr
(d, keys, value)[source]¶ Similar to the built-in setattr, this function accepts a list/tuple of keys to set a value deep in a dict
Given the following dict structure
d = { 'A': { '0': { 'a': 1, 'b': 2, } }, }
Calling setdeepattr with a key path to a value deep in the structure will set that value. If the value or any of the objects in the key path do not exist, then a dict will be created.
# Overwrites the value in `d` at A.0.a, which was 1, to 3 setdeepattr(d, ('A', '0', 'a'), 3) # Adds an entry in `d` to A.0 with the key 'c' and the value 3 setdeepattr(d, ('A', '0', 'c'), 3) # Adds an entry in `d` with the key 'X' and the value a new dict # Adds an entry in `d` to `X` with the key '0' and the value a new dict # Adds an entry in `d` to `X.0` with the key 'a' and the value 0 setdeepattr(d, ('X', '0', 'a'), 0)
Parameters: - d – A dict value with nested dict attributes.
- keys – A list/tuple path of keys in d to the desired value
- value – The value to set at the given path keys.