Remarking

Got something to highlight? Make a remark!

trigger condition

To add a remark, pass a condition; upon meeting that condition, the remarks will appear.

[1]:
import numpy as np
import ahlive as ah
xs = np.array([0, 1, 2])
ys = np.array([3, 4, 5])
arr = ah.Array(xs, ys)
arr = arr.remark(
    condition=ys == 4,
    remarks='y equals to 4!!'
)
arr.render()
[########################################] | 100% Completed |  5.7s
[1]:

remark does not save the object inplace so be sure to either save it to a new variable or same variable!

delay durations

It is also possible to add delays, in seconds, where there was a remark through durations.

[2]:
import numpy as np
import ahlive as ah
xs = np.array([0, 1, 2])
ys = np.array([3, 4, 5])
arr = ah.Array(xs, ys)
arr = arr.remark(
    condition=ys == 4,
    remarks='y equals to 4!!',
    durations=2
)
arr.render()
[########################################] | 100% Completed |  5.7s
[2]:

durations only work with GIFs!

convenient conditions

Instead of formulating a condition, for convenience, values can be passed to xs, ys, cs, state_labels, and inline_labels.

When the data values match the conditional values for the given label, remarks will trigger.

[3]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.remark(xs=1, remarks='x equals to 1!!')
arr.render()
[########################################] | 100% Completed |  5.8s
[3]:

Besides scalars, xs, ys, cs, state_labels, and inline_labels support Iterables too.

[4]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.remark(xs=[1, 2], remarks='xs condition is met!!')
arr.render()
[########################################] | 100% Completed |  5.8s
[4]:

Multiple remarks can be passed too, as long as it matches the number of states.

[5]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.remark(xs=[1, 2], remarks=['wont show', '1st show', '2nd show'])
arr.render()
[########################################] | 100% Completed |  5.8s
[5]:

dynamic remarks

Rather than setting static values for remarks, passing a label from the dataset, e.g. x, y, c, state_label, and inline_label (without the “s” suffix), can dynamically grab the value for that label at that given condition. Any labels listed under “Data variables” is valid for use as long as it contains a state dimension.

[6]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
print(arr)
arr = arr.remark(xs=[1, 2], remarks='x')
arr.render()
<ahlive.Data>
Subplot:         (1, 1)
Dimensions:      (item: 1, state: 3)
Data variables:
    x        (item, state) float64 0.0 1.0 2.0
    y        (item, state) float64 3.0 4.0 5.0
    chart    (item) <U7 'scatter'
    label    (item) <U1 ''
    group    (item) <U1 ''
    interp   (item) <U5 'cubic'
    ease     (item) <U6 'in_out'
Attributes (0/47):


[########################################] | 100% Completed |  5.8s
[6]:

Note, remarks will be triggered every time the conditional value is met.

[7]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 4])
arr = arr.remark(ys=4, remarks='y')
arr.render()
[########################################] | 100% Completed |  6.0s
[7]:

first encounter

To have the remarks trigger only once on the initial match, set first to True.

[8]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 4])
arr = arr.remark(ys=4, remarks='y', first=True)
arr.render()
[########################################] | 100% Completed |  5.9s
[8]:

first operates separately on each conditional value, i.e. remarks will trigger for 3 and the first 4, but not the last 4.

[9]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 4])
arr = arr.remark(ys=[3, 4], remarks='y', first=True)
arr.render()
[########################################] | 100% Completed |  5.9s
[9]:

tolerance levels

An absolute tolerance atol can be specified for inexact matching.

[10]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 4])
arr = arr.remark(ys=4.15, remarks='y', atol=0.5)
arr.render()
[########################################] | 100% Completed |  5.9s
[10]:

A relative tolerance rtol can be passed too.

[11]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 4])
arr = arr.remark(ys=4.15, remarks='y', rtol=0.1)
arr.render()
[########################################] | 100% Completed |  6.0s
[11]:

rtol and atol cannot be used with the condition keyword.