Skip to content

Commit

Permalink
Added some tests for round function
Browse files Browse the repository at this point in the history
  • Loading branch information
nipsn committed Nov 28, 2023
1 parent 9e15cbc commit 80693c1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_pandas_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,20 @@ def test_pandas_abs(kx, q):
with pytest.raises(kx.QError):
tab.abs()

def test_pandas_round(kx, q):
q_tab = q('([]c1:1.0 .1 .01 .001 .0001 .00001;c2:1.2 1.02 1.002 1.0002 1.00002;c3:til 6;c4:`a`b`c`d`e`f)')
pd_tab = q_tab.pd()
round_dict = {'c1': 0, 'c2': 2}

assert all(pd_tab.round() == q_tab.round().pd())
assert all(q_tab.round(0).pd() == q_tab.round().pd())
assert all(pd_tab.round(2) == q_tab.round(2).pd())
assert all(pd_tab.round(round_dict) == q_tab.round(round_dict).pd())

round_dict2 = {'c1': 0, 'c3': 2}
# TODO: following assert should not throw any errors, it should be ignored
# assert all(pd_tab.round(round_dict2) == q_tab.round(round_dict2).pd())


def test_pandas_min(q):
tab = q('([] sym: 100?`foo`bar`baz`qux; price: 250.0f - 100?500.0f; ints: 100 - 100?200)')
Expand Down

0 comments on commit 80693c1

Please sign in to comment.