Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating libraries #148

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/create-js-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: nodejs-polars
env:
DEBUG: napi:*
APP_NAME: nodejs-polars
MACOSX_DEPLOYMENT_TARGET: "10.13"
MACOSX_DEPLOYMENT_TARGET: "12.0"
"on":
push:
# Sequence of patterns matched against refs/tags
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: 20
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v3
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
Expand All @@ -165,7 +165,7 @@ jobs:
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: polars/*.node
Expand All @@ -179,7 +179,7 @@ jobs:
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-apple-darwin
path: polars
Expand All @@ -192,7 +192,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
Expand All @@ -203,7 +203,7 @@ jobs:
run: yarn install

- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
node: ["18", "20"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
Expand Down
55 changes: 25 additions & 30 deletions __tests__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ expect.extend({
message: () => "series matches",
pass: true,
};
} else {
return {
message: () => `
}
return {
message: () => `
Expected:
>>${expected}
Received:
>>${actual}`,
pass: false,
};
}
pass: false,
};
},
toSeriesEqual(actual, expected) {
const pass = actual.seriesEqual(expected);
Expand All @@ -27,16 +26,15 @@ Received:
message: () => "series matches",
pass: true,
};
} else {
return {
message: () => `
}
return {
message: () => `
Expected:
>>${expected}
Received:
>>${actual}`,
pass: false,
};
}
pass: false,
};
},
toFrameEqual(actual, expected, nullEqual?) {
const pass = actual.frameEqual(expected, nullEqual);
Expand All @@ -45,16 +43,15 @@ Received:
message: () => "dataframes match",
pass: true,
};
} else {
return {
message: () => `
}
return {
message: () => `
Expected:
>>${expected}
Received:
>>${actual}`,
pass: false,
};
}
pass: false,
};
},
toFrameStrictEqual(actual, expected) {
const frameEq = actual.frameEqual(expected);
Expand All @@ -64,16 +61,15 @@ Received:
message: () => "dataframes match",
pass: true,
};
} else {
return {
message: () => `
}
return {
message: () => `
Expected:
>>${expected}
Received:
>>${actual}`,
pass: false,
};
}
pass: false,
};
},
toFrameEqualIgnoringOrder(act: pl.DataFrame, exp: pl.DataFrame) {
const actual = act.sort(act.columns.sort());
Expand All @@ -84,16 +80,15 @@ Received:
message: () => "dataframes match",
pass: true,
};
} else {
return {
message: () => `
}
return {
message: () => `
Expected:
>>${expected}
Received:
>>${actual}`,
pass: false,
};
}
pass: false,
};
},
});

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@
"precommit": "yarn lint && yarn test"
},
"devDependencies": {
"@biomejs/biome": "^1.3.3",
"@napi-rs/cli": "^2.16.5",
"@biomejs/biome": "^1.4.1",
"@napi-rs/cli": "^2.17.0",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.6",
"chance": "^1.1.11",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.3",
"typescript": "5.3.2"
"ts-node": "^10.9.2",
"typedoc": "^0.25.6",
"typescript": "5.3.3"
},
"packageManager": "yarn@4.0.2",
"workspaces": [
Expand Down
49 changes: 18 additions & 31 deletions polars/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1708,9 +1708,8 @@ export interface DataFrame
function prepareOtherArg(anyValue: any): Series {
if (Series.isSeries(anyValue)) {
return anyValue;
} else {
return Series([anyValue]) as Series;
}
return Series([anyValue]) as Series;
}

function map(df: DataFrame, fn: (...args: any[]) => any[]) {
Expand Down Expand Up @@ -1841,9 +1840,8 @@ export const _DataFrame = (_df: any): DataFrame => {
df.getColumns().map((s) => {
if (s.isNumeric() || s.isBoolean()) {
return s.cast(DataType.Float64);
} else {
return s;
}
return s;
}),
);
};
Expand Down Expand Up @@ -1877,9 +1875,8 @@ export const _DataFrame = (_df: any): DataFrame => {
dropNulls(...subset) {
if (subset.length) {
return wrap("dropNulls", subset.flat(2));
} else {
return wrap("dropNulls");
}
return wrap("dropNulls");
},
distinct(opts: any = false, subset?, keep = "first") {
return this.unique(opts, subset);
Expand Down Expand Up @@ -2037,9 +2034,8 @@ export const _DataFrame = (_df: any): DataFrame => {
max(axis = 0) {
if (axis === 1) {
return _Series(_df.hmax() as any) as any;
} else {
return wrap("max");
}
return wrap("max");
},
mean(axis = 0, nullStrategy = "ignore") {
if (axis === 1) {
Expand All @@ -2057,9 +2053,8 @@ export const _DataFrame = (_df: any): DataFrame => {
min(axis = 0) {
if (axis === 1) {
return _Series(_df.hmin() as any) as any;
} else {
return wrap("min");
}
return wrap("min");
},
nChunks() {
return _df.nChunks();
Expand Down Expand Up @@ -2168,28 +2163,25 @@ export const _DataFrame = (_df: any): DataFrame => {
false,
seed,
);
} else {
throw new TypeError("must specify either 'frac' or 'n'");
}
throw new TypeError("must specify either 'frac' or 'n'");
},
select(...selection) {
const hasExpr = selection.flat().some((s) => Expr.isExpr(s));
if (hasExpr) {
return _DataFrame(_df).lazy().select(selection).collectSync();
} else {
return wrap("select", columnOrColumnsStrict(selection as any));
}
return wrap("select", columnOrColumnsStrict(selection as any));
},
shift: (opt) => wrap("shift", opt?.periods ?? opt),
shiftAndFill(n: any, fillValue?: number | undefined) {
if (typeof n === "number" && fillValue) {
return _DataFrame(_df).lazy().shiftAndFill(n, fillValue).collectSync();
} else {
return _DataFrame(_df)
.lazy()
.shiftAndFill(n.n, n.fillValue)
.collectSync();
}
return _DataFrame(_df)
.lazy()
.shiftAndFill(n.n, n.fillValue)
.collectSync();
},
shrinkToFit(inPlace: any = false): any {
if (inPlace) {
Expand Down Expand Up @@ -2408,9 +2400,8 @@ export const _DataFrame = (_df: any): DataFrame => {
}
if (!options?.columnNames) {
return wrap("transpose", keep_names_as, undefined);
} else {
return wrap("transpose", keep_names_as, options.columnNames);
}
return wrap("transpose", keep_names_as, options.columnNames);
},
unnest(names) {
names = Array.isArray(names) ? names : [names];
Expand All @@ -2428,28 +2419,25 @@ export const _DataFrame = (_df: any): DataFrame => {
withColumn(column: Series | Expr) {
if (Series.isSeries(column)) {
return wrap("withColumn", column.inner());
} else {
return this.withColumns(column);
}
return this.withColumns(column);
},
withColumns(...columns: (Expr | Series)[]) {
if (isSeriesArray(columns)) {
return columns.reduce(
(acc, curr) => acc.withColumn(curr),
_DataFrame(_df),
);
} else {
return this.lazy()
.withColumns(columns)
.collectSync({ noOptimization: true, stringCache: false });
}
return this.lazy()
.withColumns(columns)
.collectSync({ noOptimization: true, stringCache: false });
},
withColumnRenamed(opt, replacement?) {
if (typeof opt === "string") {
return this.rename({ [opt]: replacement });
} else {
return this.rename({ [opt.existing]: opt.replacement });
}
return this.rename({ [opt.existing]: opt.replacement });
},
withRowCount(name = "row_nr") {
return wrap("withRowCount", name);
Expand Down Expand Up @@ -2477,9 +2465,8 @@ export const _DataFrame = (_df: any): DataFrame => {
}
if (typeof prop !== "symbol" && !Number.isNaN(Number(prop))) {
return target.row(Number(prop));
} else {
return Reflect.get(target, prop, receiver);
}
return Reflect.get(target, prop, receiver);
},
set(target: DataFrame, prop, receiver) {
if (Series.isSeries(receiver)) {
Expand Down
Loading