Skip to content

Commit ad4f80e

Browse files
committed
use expect.toStrictEqual when comparing dtypes
1 parent 1a5c40e commit ad4f80e

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

__tests__/dataframe.test.ts

+19-14
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ describe("dataframe", () => {
99
]);
1010

1111
test("dtypes", () => {
12-
const expected = [pl.Float64, pl.Utf8];
12+
const expected = [pl.Float64, pl.String];
1313
const actual = pl.DataFrame({ a: [1, 2, 3], b: ["a", "b", "c"] }).dtypes;
14-
expect(actual).toEqual(expected);
14+
expect(actual).toStrictEqual(expected);
1515
});
1616
test("height", () => {
1717
const expected = 3;
@@ -447,7 +447,7 @@ describe("dataframe", () => {
447447
ham: ["a", "b", "c"],
448448
})
449449
.hashRows();
450-
expect(actual.dtype).toEqual(pl.UInt64);
450+
expect(actual.dtype).toStrictEqual(pl.UInt64);
451451
});
452452
test.each([[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]])(
453453
"hashRows:positional",
@@ -458,7 +458,7 @@ describe("dataframe", () => {
458458
ham: ["a", "b", "c"],
459459
})
460460
.hashRows(...args);
461-
expect(actual.dtype).toEqual(pl.UInt64);
461+
expect(actual.dtype).toStrictEqual(pl.UInt64);
462462
},
463463
);
464464
test.each([
@@ -473,7 +473,7 @@ describe("dataframe", () => {
473473
ham: ["a", "b", "c"],
474474
})
475475
.hashRows(opts);
476-
expect(actual.dtype).toEqual(pl.UInt64);
476+
expect(actual.dtype).toStrictEqual(pl.UInt64);
477477
});
478478
test("head", () => {
479479
const actual = pl
@@ -1777,8 +1777,8 @@ describe("create", () => {
17771777
date_nulls: pl.Date,
17781778
datetime: pl.Datetime("ms"),
17791779
datetime_nulls: pl.Datetime("ms"),
1780-
string: pl.Utf8,
1781-
string_nulls: pl.Utf8,
1780+
string: pl.String,
1781+
string_nulls: pl.String,
17821782
categorical: pl.Categorical,
17831783
categorical_nulls: pl.Categorical,
17841784
list: pl.List(pl.Float64),
@@ -1798,7 +1798,7 @@ describe("create", () => {
17981798
float_64_typed: pl.Float64,
17991799
};
18001800
const actual = df.schema;
1801-
expect(actual).toEqual(expectedSchema);
1801+
expect(actual).toStrictEqual(expectedSchema);
18021802
});
18031803
test("from series-array", () => {
18041804
const s1 = pl.Series("num", [1, 2, 3]);
@@ -1894,6 +1894,11 @@ describe("create", () => {
18941894

18951895
const df = pl.readRecords(rows, { inferSchemaLength: 1 });
18961896
expect(df.toRecords()).toEqual(expected);
1897+
expect(df.schema).toStrictEqual({
1898+
num: pl.Int32,
1899+
date: pl.Datetime("ms"),
1900+
string: pl.String,
1901+
});
18971902
});
18981903
test("from row objects, with schema", () => {
18991904
const rows = [
@@ -1908,12 +1913,12 @@ describe("create", () => {
19081913

19091914
const schema = {
19101915
num: pl.Int32,
1911-
date: pl.Utf8,
1912-
string: pl.Utf8,
1916+
date: pl.String,
1917+
string: pl.String,
19131918
};
19141919
const df = pl.readRecords(rows, { schema });
19151920
expect(df.toRecords()).toEqual(expected);
1916-
expect(df.schema).toEqual(schema);
1921+
expect(df.schema).toStrictEqual(schema);
19171922
});
19181923

19191924
test("from nulls", () => {
@@ -1954,7 +1959,7 @@ describe("create", () => {
19541959
},
19551960
},
19561961
);
1957-
expect(df.schema).toEqual({ x: pl.Int32, y: pl.String });
1962+
expect(df.schema).toStrictEqual({ x: pl.Int32, y: pl.String });
19581963
});
19591964
test("with schema", () => {
19601965
const df = pl.DataFrame(
@@ -1969,7 +1974,7 @@ describe("create", () => {
19691974
},
19701975
},
19711976
);
1972-
expect(df.schema).toEqual({ x: pl.Int32, y: pl.String });
1977+
expect(df.schema).toStrictEqual({ x: pl.Int32, y: pl.String });
19731978
});
19741979
test("with schema overrides", () => {
19751980
const df = pl.DataFrame(
@@ -1983,7 +1988,7 @@ describe("create", () => {
19831988
},
19841989
},
19851990
);
1986-
expect(df.schema).toEqual({ a: pl.Int32, b: pl.String });
1991+
expect(df.schema).toStrictEqual({ a: pl.Int32, b: pl.String });
19871992
});
19881993
test("errors if schemaOverrides and schema are both specified", () => {
19891994
const fn = () =>

__tests__/lazy_functions.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe("lazy functions", () => {
172172
const df = pl.DataFrame({ a: [1, 2], b: [3, 4] });
173173
const result = df.select(pl.intRanges("a", "b"));
174174
const expected_schema = { a: pl.List(pl.Int64) };
175-
expect(result.schema).toEqual(expected_schema);
175+
expect(result.schema).toStrictEqual(expected_schema);
176176
});
177177

178178
test("intRanges:eager", () => {

0 commit comments

Comments
 (0)