Skip to content

Commit

Permalink
test: use const
Browse files Browse the repository at this point in the history
type of actual and expected are now incompatible.
  • Loading branch information
scarf005 committed Nov 18, 2024
1 parent d802fa5 commit e13e1f8
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 217 deletions.
38 changes: 22 additions & 16 deletions __tests__/dataframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,8 @@ describe("dataframe", () => {
]);
expect(actual).toFrameEqual(expected);
});
test("pivot", () => {
let df = pl.DataFrame({
{
const df = pl.DataFrame({
a: pl.Series([1, 2, 3]).cast(pl.Int32),
b: pl
.Series([
Expand All @@ -1326,7 +1326,7 @@ describe("dataframe", () => {
.cast(pl.List(pl.Int32)),
});

let expected = pl
const expected = pl
.DataFrame({
a: pl.Series([1, 2, 3]).cast(pl.Int32),
"1": pl.Series([[1, 1], null, null]).cast(pl.List(pl.Int32)),
Expand All @@ -1335,82 +1335,88 @@ describe("dataframe", () => {
})
.select("a", "1", "2", "3");

let actual = df.pivot("b", {
const actual = df.pivot("b", {
index: "a",
on: "a",
aggregateFunc: "first",
sortColumns: true,
});

expect(actual).toFrameEqual(expected, true);
}

df = pl.DataFrame({
{
const df = pl.DataFrame({
a: ["beep", "bop"],
b: ["a", "b"],
c: ["s", "f"],
d: [7, 8],
e: ["x", "y"],
});
actual = df.pivot(["a", "e"], {
const actual = df.pivot(["a", "e"], {
index: "b",
on: ["b"],
aggregateFunc: "first",
separator: "|",
maintainOrder: true,
});

expected = pl.DataFrame({
const expected = pl.DataFrame({
b: ["a", "b"],
"a|a": ["beep", null],
"a|b": [null, "bop"],
"e|a": ["x", null],
"e|b": [null, "y"],
});
expect(actual).toFrameEqual(expected, true);

df = pl.DataFrame({
}
{
const df = pl.DataFrame({
foo: ["A", "A", "B", "B", "C"],
N: [1, 2, 2, 4, 2],
bar: ["k", "l", "m", "n", "o"],
});
actual = df.pivot(["N"], {
const actual = df.pivot(["N"], {
index: "foo",
on: "bar",
aggregateFunc: "first",
});
expected = pl.DataFrame({

const expected = pl.DataFrame({
foo: ["A", "B", "C"],
k: [1, null, null],
l: [2, null, null],
m: [null, 2, null],
n: [null, 4, null],
o: [null, null, 2],
});
expect(actual).toFrameEqual(expected, true);

df = pl.DataFrame({
expect(actual).toFrameEqual(expected, true);
}
{
const df = pl.DataFrame({
ix: [1, 1, 2, 2, 1, 2],
col: ["a", "a", "a", "a", "b", "b"],
foo: [0, 1, 2, 2, 7, 1],
bar: [0, 2, 0, 0, 9, 4],
});

actual = df.pivot(["foo", "bar"], {
const actual = df.pivot(["foo", "bar"], {
index: "ix",
on: "col",
aggregateFunc: "sum",
separator: "/",
});

expected = pl.DataFrame({
const expected = pl.DataFrame({
ix: [1, 2],
"foo/a": [1, 4],
"foo/b": [7, 1],
"bar/a": [2, 0],
"bar/b": [9, 4],
});
expect(actual).toFrameEqual(expected, true);
});
}
});
describe("join", () => {
test("on", () => {
Expand Down
Loading

0 comments on commit e13e1f8

Please sign in to comment.