Skip to content

Commit

Permalink
assert the timeseries-twa algorithm more leniently (cherry pick from pr
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Aug 25, 2022
1 parent 918d104 commit e482225
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ def test_range_advanced(client):
assert [(0, 5.0), (5, 6.0)] == client.ts().range(
1, 0, 10, aggregation_type="count", bucket_size_msec=10, align=5
)
assert [(0, 2.5500000000000003), (10, 3.95)] == client.ts().range(
1, 0, 10, aggregation_type="twa", bucket_size_msec=10
)

# the twa algorithm can produce slightly different results based on implementation.
# just check that the first bucket is approcimately correct.
result = client.ts().range(1, 0, 10, aggregation_type="twa", bucket_size_msec=10)
rounded = [(a, round(b, 2)) for (a, b) in result]
assert (0, 2.55) == rounded[0]


@pytest.mark.redismod
Expand Down

0 comments on commit e482225

Please sign in to comment.