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 to 1.8.3 #241

Merged
merged 2 commits into from
Jul 16, 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
10 changes: 2 additions & 8 deletions __tests__/lazy_functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,8 @@ describe("lazy functions", () => {
});
test.each`
start | end | expected
${"a"} | ${"b"} | ${pl.Series("a", [
[1, 2],
[2, 3],
])}
${-1} | ${"a"} | ${pl.Series("literal", [
[-1, 0],
[-1, 0, 1],
])}
${"a"} | ${"b"} | ${pl.Series("a", [[1, 2], [2, 3]])}
${-1} | ${"a"} | ${pl.Series("literal", [[-1, 0], [-1, 0, 1]])}
${"b"} | ${4} | ${pl.Series("b", [[3], []])}
`("$# cumMax", ({ start, end, expected }) => {
const df = pl.DataFrame({ a: [1, 2], b: [3, 4] });
Expand Down
228 changes: 108 additions & 120 deletions __tests__/series.test.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"build:ts": " rm -rf bin; tsc -p tsconfig.build.json",
"cp:bin": "cp ./polars/*.node bin/",
"format:rs": "cargo fmt",
"lint:ts:fix": "biome check --apply-unsafe {polars,__tests__} && biome format --write {polars,__tests__}",
"lint:ts:fix": "biome check --write --unsafe {polars,__tests__} && biome format --write {polars,__tests__}",
"lint:ts": "biome check {polars,__tests__} && biome format {polars,__tests__}",
"lint": "yarn lint:ts && yarn format:rs",
"prepublishOnly": "napi prepublish -t npm",
Expand All @@ -54,15 +54,15 @@
"precommit": "yarn lint && yarn test"
},
"devDependencies": {
"@biomejs/biome": "=1.7.3",
"@biomejs/biome": "=1.8.3",
"@napi-rs/cli": "^2.18.4",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.9",
"chance": "^1.1.11",
"@types/node": "^20.14.10",
"chance": "^1.1.12",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.5",
"ts-jest": "^29.2.0",
"ts-node": "^10.9.2",
"typedoc": "^0.26.3",
"typescript": "5.5.3"
Expand Down
19 changes: 7 additions & 12 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ pub fn read_json_lines(
path_or_buffer: Either<String, Buffer>,
options: ReadJsonOptions,
) -> napi::Result<JsDataFrame> {
let infer_schema_length = NonZeroUsize::new(options.infer_schema_length.unwrap_or(100) as usize);
let infer_schema_length =
NonZeroUsize::new(options.infer_schema_length.unwrap_or(100) as usize);
let batch_size = options
.batch_size
.map(|b| NonZeroUsize::try_from(b as usize).unwrap());
Expand Down Expand Up @@ -216,7 +217,8 @@ pub fn read_json(
path_or_buffer: Either<String, Buffer>,
options: ReadJsonOptions,
) -> napi::Result<JsDataFrame> {
let infer_schema_length = NonZeroUsize::new(options.infer_schema_length.unwrap_or(100) as usize);
let infer_schema_length =
NonZeroUsize::new(options.infer_schema_length.unwrap_or(100) as usize);
let batch_size = options.batch_size.unwrap_or(10000) as usize;
let batch_size = NonZeroUsize::new(batch_size).unwrap();
let format: JsonFormat = options
Expand Down Expand Up @@ -1113,17 +1115,10 @@ impl JsDataFrame {
stable: bool,
) -> napi::Result<JsDataFrame> {
let out = if stable {
self.df.upsample_stable(
by,
&index_column,
Duration::parse(&every)
)
self.df
.upsample_stable(by, &index_column, Duration::parse(&every))
} else {
self.df.upsample(
by,
&index_column,
Duration::parse(&every)
)
self.df.upsample(by, &index_column, Duration::parse(&every))
};
let out = out.map_err(JsPolarsErr::from)?;
Ok(out.into())
Expand Down
2 changes: 1 addition & 1 deletion src/lazy/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl JsLazyFrame {
index_column: "".into(),
period: Duration::parse(&period),
offset: Duration::parse(&offset),
closed_window
closed_window,
},
);

Expand Down
29 changes: 17 additions & 12 deletions src/lazy/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ impl JsExpr {
}

#[napi(catch_unwind)]
pub fn value_counts(&self, sort: bool, parallel: bool, name: String, normalize: bool) -> JsExpr {
pub fn value_counts(
&self,
sort: bool,
parallel: bool,
name: String,
normalize: bool,
) -> JsExpr {
self.inner
.clone()
.value_counts(sort, parallel, name, normalize)
Expand Down Expand Up @@ -330,7 +336,10 @@ impl JsExpr {
}
#[napi(catch_unwind)]
pub fn gather(&self, idx: &JsExpr) -> JsExpr {
self.clone().inner.gather(idx.inner.clone().cast(DataType::Int64)).into()
self.clone()
.inner
.gather(idx.inner.clone().cast(DataType::Int64))
.into()
}
#[napi(catch_unwind)]
pub fn sort_by(&self, by: Vec<&JsExpr>, reverse: Vec<bool>) -> JsExpr {
Expand Down Expand Up @@ -462,7 +471,10 @@ impl JsExpr {
pub fn slice(&self, offset: &JsExpr, length: &JsExpr) -> JsExpr {
self.inner
.clone()
.slice(offset.inner.clone().cast(DataType::Int64), length.inner.clone().cast(DataType::Int64))
.slice(
offset.inner.clone().cast(DataType::Int64),
length.inner.clone().cast(DataType::Int64),
)
.into()
}
#[napi(catch_unwind)]
Expand Down Expand Up @@ -955,17 +967,10 @@ impl JsExpr {
.into()
}
#[napi(catch_unwind)]
pub fn replace(
&self,
old: &JsExpr,
new: &JsExpr
) -> JsExpr {
pub fn replace(&self, old: &JsExpr, new: &JsExpr) -> JsExpr {
self.inner
.clone()
.replace(
old.inner.clone(),
new.inner.clone()
)
.replace(old.inner.clone(), new.inner.clone())
.into()
}
#[napi(catch_unwind)]
Expand Down
16 changes: 11 additions & 5 deletions src/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,22 +482,22 @@ impl JsSeries {
Ok(JsSeries { series })
}
#[napi(catch_unwind)]
pub fn sub(&self, other: &JsSeries) -> napi::Result<JsSeries> {
pub fn sub(&self, other: &JsSeries) -> napi::Result<JsSeries> {
let series = (&self.series - &other.series).map_err(JsPolarsErr::from)?;
Ok(JsSeries { series })
}
#[napi(catch_unwind)]
pub fn mul(&self, other: &JsSeries) -> napi::Result<JsSeries> {
pub fn mul(&self, other: &JsSeries) -> napi::Result<JsSeries> {
let series = (&self.series * &other.series).map_err(JsPolarsErr::from)?;
Ok(JsSeries { series })
}
#[napi(catch_unwind)]
pub fn div(&self, other: &JsSeries) -> napi::Result<JsSeries> {
pub fn div(&self, other: &JsSeries) -> napi::Result<JsSeries> {
let series = (&self.series / &other.series).map_err(JsPolarsErr::from)?;
Ok(JsSeries { series })
}
#[napi(catch_unwind)]
pub fn rem(&self, other: &JsSeries) -> napi::Result<JsSeries> {
pub fn rem(&self, other: &JsSeries) -> napi::Result<JsSeries> {
let series = (&self.series % &other.series).map_err(JsPolarsErr::from)?;
Ok(JsSeries { series })
}
Expand Down Expand Up @@ -552,7 +552,13 @@ impl JsSeries {
Ok(unique.into())
}
#[napi(catch_unwind)]
pub fn value_counts(&self, sort: bool, parallel: bool, name: String, normalize: bool) -> napi::Result<JsDataFrame> {
pub fn value_counts(
&self,
sort: bool,
parallel: bool,
name: String,
normalize: bool,
) -> napi::Result<JsDataFrame> {
let df = self
.series
.value_counts(sort, parallel, name, normalize)
Expand Down
Loading