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

Upgrading biome and fixing linting errors #139

Merged
merged 2 commits into from
Oct 27, 2023
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
10 changes: 5 additions & 5 deletions .github/workflows/create-js-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ jobs:
architecture: x64
target: aarch64-linux-android
build: |
export CLANG_VERSION=`ls ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang | sed 's/ *$//g'`
touch "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
chmod 777 "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
echo "INPUT(-lunwind)" > "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
export CLANG_VERSION=`ls ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang | sed 's/ *$//g'`
touch "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
chmod 777 "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
echo "INPUT(-lunwind)" > "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a"
yarn build --target aarch64-linux-android
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip polars/*.node
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip polars/*.node

- host: ubuntu-latest
architecture: x64
Expand Down
16 changes: 8 additions & 8 deletions __tests__/dataframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("dataframe", () => {
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -152,11 +152,11 @@ describe("dataframe", () => {
ham: ["0", "a", "b"],
});
expect(actual).toFrameEqual(expected);
});
}
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder:single subset", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -171,11 +171,11 @@ describe("dataframe", () => {
ham: ["0", "a", "b"],
});
expect(actual).toFrameEqual(expected);
});
}
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder:multi subset", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -190,7 +190,7 @@ describe("dataframe", () => {
ham: ["0", "a", "b", "c"],
});
expect(actual).toFrameEqual(expected);
});
}
});
test("unnest", () => {
const expected = pl.DataFrame({
Expand Down Expand Up @@ -427,9 +427,9 @@ describe("dataframe", () => {
pl.Series("foo", [1, 2, 3]),
pl.Series("ham", ["a", "b", "c"]),
];
actual.forEach((a, idx) => {
for (const [idx, a] of actual.entries()) {
expect(a).toSeriesEqual(expected[idx]);
});
}
});
test("groupBy", () => {
const actual = pl
Expand Down
4 changes: 3 additions & 1 deletion __tests__/expr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,9 @@ describe("expr.str", () => {
.toFrame();

const actual = df.select(
col("a").str.extract(/candidate=(\w+)/, 1).as("candidate"),
col("a")
.str.extract(/candidate=(\w+)/, 1)
.as("candidate"),
);
expect(actual).toFrameEqual(expected);
expect(seriesActual).toFrameEqual(expected);
Expand Down
12 changes: 6 additions & 6 deletions __tests__/lazyframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("lazyframe", () => {
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -135,11 +135,11 @@ describe("lazyframe", () => {
ham: ["0", "a", "b"],
});
expect(actual).toFrameEqual(expected);
});
}
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder:single subset", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -155,11 +155,11 @@ describe("lazyframe", () => {
ham: ["0", "a", "b"],
});
expect(actual).toFrameEqual(expected);
});
}
});
// run this test 100 times to make sure it is deterministic.
test("unique:maintainOrder:multi subset", () => {
Array.from({ length: 100 }).forEach(() => {
for (const x of Array.from({ length: 100 })) {
const actual = pl
.DataFrame({
foo: [0, 1, 2, 2, 2],
Expand All @@ -175,7 +175,7 @@ describe("lazyframe", () => {
ham: ["0", "a", "b", "c"],
});
expect(actual).toFrameEqual(expected);
});
}
});
test("dropNulls", () => {
const actual = pl
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]
},
"formatter": {
"indentSize": 2,
"indentWidth": 2,
"indentStyle": "space",
"ignore": [
"polars/native-polars.js",
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@
"precommit": "yarn lint && yarn test"
},
"devDependencies": {
"@biomejs/biome": "^1.1.2",
"@biomejs/biome": "^1.3.1",
"@napi-rs/cli": "^2.16.3",
"@types/chance": "^1.1.4",
"@types/jest": "^29.5.4",
"@types/node": "^20.6.0",
"@types/chance": "^1.1.5",
"@types/jest": "^29.5.6",
"@types/node": "^20.8.9",
"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.1",
"typedoc": "^0.25.2",
"typescript": "5.2.2"
},
"packageManager": "[email protected]",
Expand Down
25 changes: 10 additions & 15 deletions polars/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1868,13 +1868,10 @@ export const _DataFrame = (_df: any): DataFrame => {
if (!Array.isArray(names[0]) && names.length === 1) {
return wrap("drop", names[0]);
}

const df: any = this.clone();

names.flat(2).forEach((name) => {
for (const name of names.flat(2)) {
df.inner().dropInPlace(name);
});

}
return df;
},
dropNulls(...subset) {
Expand Down Expand Up @@ -2125,10 +2122,9 @@ export const _DataFrame = (_df: any): DataFrame => {
},
rename(mapping) {
const df = this.clone();
Object.entries(mapping).forEach(([column, new_col]) => {
for (const [column, new_col] of Object.entries(mapping)) {
(df as any).inner().rename(column, new_col);
});

}
return df;
},
replaceAtIdx(index, newColumn) {
Expand Down Expand Up @@ -2255,20 +2251,19 @@ export const _DataFrame = (_df: any): DataFrame => {

// Add table headers
htmlTable += "<thead><tr>";
this.getColumns().forEach((field) => {
for (const field of this.getColumns()) {
htmlTable += `<th>${escapeHTML(field.name)}</th>`;
});
}
htmlTable += "</tr></thead>";

// Add table data
htmlTable += "<tbody>";
this.toRecords().forEach((row) => {
for (const row of this.toRecords()) {
htmlTable += "<tr>";
this.getColumns().forEach((field) => {
for (const field of this.getColumns()) {
htmlTable += `<td>${escapeHTML(String(row[field.name]))}</td>`;
});
}
htmlTable += "</tr>";
});
}
htmlTable += "</tbody></table>";

return htmlTable;
Expand Down
12 changes: 5 additions & 7 deletions polars/internals/construction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ export function arrayToJsDataFrame(data: any[], options?): any {
dataSeries = [];
} else if (data[0]?._s) {
dataSeries = [];

data.forEach((series: any, idx) => {
for (const [idx, series] of data.entries()) {
if (!series.name) {
series.rename(`column_${idx}`, true);
}
dataSeries.push(series._s);
});
}
} else if (data[0].constructor.name === "Object") {
const df = pli.fromRows(data, schema, inferSchemaLength);

Expand Down Expand Up @@ -233,10 +232,9 @@ function handleColumnsArg(data: any[], columns?: string[]) {
if (!data) {
return columns.map((c) => (Series.from(c, []) as any)._s);
} else if (data.length === columns.length) {
columns.forEach((name, i) => {
data[i].rename(name);
});

for (const [idx, name] of columns.entries()) {
data[idx].rename(name);
}
return data;
}
}
Expand Down
4 changes: 2 additions & 2 deletions polars/lazy/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ export interface LazyDataFrame extends Serialize, GroupByOps<LazyGroupBy> {
const prepareGroupbyInputs = (by) => {
if (Array.isArray(by)) {
const newBy: any = [];
by.forEach((e) => {
for (let e of by) {
if (typeof e === "string") {
e = pli.col(e);
}
newBy.push(e);
});
}

return newBy;
} else if (typeof by === "string") {
Expand Down
12 changes: 8 additions & 4 deletions polars/series/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,11 @@ export interface Series
* false
* ```
*/
seriesEqual<U>(other: Series, nullEqual?: boolean, strict?: boolean): boolean;
seriesEqual<U1>(
other: Series,
nullEqual?: boolean,
strict?: boolean,
): boolean;
/**
* __Set masked values__
* @param filter Boolean mask
Expand Down Expand Up @@ -1788,13 +1792,13 @@ export interface SeriesConstructor extends Deserialize<Series> {
* Creates an array from an array-like object.
* @param arrayLike — An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): Series;
from<T>(name: string, arrayLike: ArrayLike<T>): Series;
from<T1>(arrayLike: ArrayLike<T1>): Series;
from<T2>(name: string, arrayLike: ArrayLike<T2>): Series;
/**
* Returns a new Series from a set of elements.
* @param items — A set of elements to include in the new Series object.
*/
of<T>(...items: T[]): Series;
of<T3>(...items: T3[]): Series;
isSeries(arg: any): arg is Series;
/**
* @param binary used to serialize/deserialize series. This will only work with the output from series.toBinary().
Expand Down
2 changes: 1 addition & 1 deletion polars/shared_traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export interface Sample<T> {

export interface Bincode<T> {
(bincode: Uint8Array): T;
getState(T): Uint8Array;
getState(T2): Uint8Array;
}

/**
Expand Down
Loading