@@ -96,6 +96,18 @@ describe("expr", () => {
96
96
const fn = ( ) => df . select ( col ( "a" ) . cast ( pl . Int16 , true ) ) ;
97
97
expect ( fn ) . toThrow ( ) ;
98
98
} ) ;
99
+ test ( "cos" , ( ) => {
100
+ const df = pl . DataFrame ( { a : [ 1 , 2 , 3 ] } ) ;
101
+ const expected = pl . DataFrame ( { cos : [ 0.540302 , - 0.416147 , - 0.989992 ] } ) ;
102
+ const actual = df . select ( col ( "a" ) . cos ( ) . round ( 6 ) . as ( "cos" ) ) ;
103
+ expect ( actual ) . toFrameEqual ( expected ) ;
104
+ } ) ;
105
+ test ( "cot" , ( ) => {
106
+ const df = pl . DataFrame ( { a : [ 1 , 2 , 3 ] } ) ;
107
+ const expected = pl . DataFrame ( { cot : [ 0.642093 , - 0.457658 , - 7.015253 ] } ) ;
108
+ const actual = df . select ( col ( "a" ) . cot ( ) . round ( 6 ) . as ( "cot" ) ) ;
109
+ expect ( actual ) . toFrameEqual ( expected ) ;
110
+ } ) ;
99
111
test ( "count" , ( ) => {
100
112
const df = pl . DataFrame ( { a : [ 1 , 0 , 3 , 4 , 6 , 0 ] } ) ;
101
113
const expected = pl . DataFrame ( { a : [ 6 ] } ) ;
@@ -208,6 +220,12 @@ describe("expr", () => {
208
220
const actual = df . select ( col ( "*" ) . exclude ( "b" , "c" ) ) ;
209
221
expect ( actual ) . toFrameEqual ( expected ) ;
210
222
} ) ;
223
+ test ( "exp" , ( ) => {
224
+ const df = pl . DataFrame ( { a : [ 1.0 ] } ) ;
225
+ const actual = df . select ( pl . col ( "a" ) . exp ( ) ) ;
226
+ const expected = pl . DataFrame ( { a : [ Math . E ] } ) ;
227
+ expect ( actual ) . toFrameEqual ( expected ) ;
228
+ } ) ;
211
229
test ( "explode" , ( ) => {
212
230
const df = pl . DataFrame ( {
213
231
letters : [ "c" , "a" ] ,
@@ -329,6 +347,15 @@ describe("expr", () => {
329
347
const actual = df . select ( col ( "a" ) . gtEq ( 0 ) ) ;
330
348
expect ( actual ) . toFrameEqual ( expected ) ;
331
349
} ) ;
350
+ test ( "gatherEvery" , ( ) => {
351
+ const df = pl . DataFrame ( { a : [ 1 , 1 , 2 , 2 , 3 , 3 , 8 , null , 1 ] } ) ;
352
+ let expected = pl . DataFrame ( { everyother : [ 1 , 2 , 3 , 8 , 1 ] } ) ;
353
+ let actual = df . select ( col ( "a" ) . gatherEvery ( 2 ) . as ( "everyother" ) ) ;
354
+ expect ( actual ) . toFrameEqual ( expected ) ;
355
+ expected = pl . DataFrame ( { everyother : [ 2 , 3 , 8 , 1 ] } ) ;
356
+ actual = df . select ( col ( "a" ) . gatherEvery ( 2 , 2 ) . as ( "everyother" ) ) ;
357
+ expect ( actual ) . toFrameEqual ( expected ) ;
358
+ } ) ;
332
359
test . each `
333
360
args | hashValue
334
361
${ [ 0 ] } | ${ 7355865757046787768n }
@@ -514,6 +541,16 @@ describe("expr", () => {
514
541
const actual = df . select ( col ( "a" ) . ltEq ( 2 ) . as ( "lt" ) ) ;
515
542
expect ( actual ) . toFrameEqual ( expected ) ;
516
543
} ) ;
544
+ test ( "log" , ( ) => {
545
+ let df = pl . DataFrame ( { a : [ 1 , 2 , 3 ] } ) ;
546
+ let actual = df . select ( col ( "a" ) . log ( 2 ) . round ( 6 ) . as ( "log" ) ) ;
547
+ let expected = pl . DataFrame ( { log : [ 0.0 , 1.0 , 1.584963 ] } ) ;
548
+ expect ( actual ) . toFrameEqual ( expected ) ;
549
+ df = pl . DataFrame ( { a : [ 2 ] } ) ;
550
+ actual = df . select ( col ( "a" ) . log ( ) . as ( "log" ) ) ;
551
+ expected = pl . DataFrame ( { log : [ Math . LN2 ] } ) ;
552
+ expect ( actual ) . toFrameEqual ( expected ) ;
553
+ } ) ;
517
554
test ( "max" , ( ) => {
518
555
const df = pl . DataFrame ( { a : [ 1 , 5 , 3 ] } ) ;
519
556
const expected = pl . DataFrame ( { max : [ 5 ] } ) ;
@@ -709,6 +746,12 @@ describe("expr", () => {
709
746
const actual = df . select ( col ( "a" ) , ...shifts ) ;
710
747
expect ( actual ) . toFrameStrictEqual ( expected ) ;
711
748
} ) ;
749
+ test ( "sin" , ( ) => {
750
+ const df = pl . DataFrame ( { a : [ 1 , 2 , 3 ] } ) ;
751
+ const expected = pl . DataFrame ( { sin : [ 0.841471 , 0.909297 , 0.14112 ] } ) ;
752
+ const actual = df . select ( col ( "a" ) . sin ( ) . round ( 6 ) . as ( "sin" ) ) ;
753
+ expect ( actual ) . toFrameEqual ( expected ) ;
754
+ } ) ;
712
755
test ( "skew" , ( ) => {
713
756
const df = pl . DataFrame ( { a : [ 1 , 2 , 3 , 3 ] } ) ;
714
757
const expected = pl . DataFrame ( {
@@ -870,13 +913,10 @@ describe("expr", () => {
870
913
) ;
871
914
expect ( actual ) . toFrameEqual ( expected ) ;
872
915
} ) ;
873
- test ( "gatherEvery" , ( ) => {
874
- const df = pl . DataFrame ( { a : [ 1 , 1 , 2 , 2 , 3 , 3 , 8 , null , 1 ] } ) ;
875
- let expected = pl . DataFrame ( { everyother : [ 1 , 2 , 3 , 8 , 1 ] } ) ;
876
- let actual = df . select ( col ( "a" ) . gatherEvery ( 2 ) . as ( "everyother" ) ) ;
877
- expect ( actual ) . toFrameEqual ( expected ) ;
878
- expected = pl . DataFrame ( { everyother : [ 2 , 3 , 8 , 1 ] } ) ;
879
- actual = df . select ( col ( "a" ) . gatherEvery ( 2 , 2 ) . as ( "everyother" ) ) ;
916
+ test ( "tan" , ( ) => {
917
+ const df = pl . DataFrame ( { a : [ 1 , 2 , 3 ] } ) ;
918
+ const expected = pl . DataFrame ( { tan : [ 1.557408 , - 2.18504 , - 0.142547 ] } ) ;
919
+ const actual = df . select ( col ( "a" ) . tan ( ) . round ( 6 ) . as ( "tan" ) ) ;
880
920
expect ( actual ) . toFrameEqual ( expected ) ;
881
921
} ) ;
882
922
test ( "unique" , ( ) => {
0 commit comments