@@ -58,12 +58,14 @@ def _set_range_vars(self):
5858 return self
5959
6060 def fit (self , X : nwt .IntoDataFrameT , columns : Optional [str | Iterable [str ]] = None ):
61- """_summary_
61+ """Computes the min(s) and max(es) to be used for scaling.
6262
6363 Parameters
6464 ----------
6565 X : nwt.IntoDataFrameT
66- _description_
66+ columns : Optional[str | Iterable[str]], optional
67+ The columns to apply scaling to. If None, all columns are scaled, by default
68+ None
6769
6870 Attributes
6971 ----------
@@ -73,15 +75,14 @@ def fit(self, X: nwt.IntoDataFrameT, columns: Optional[str | Iterable[str]] = No
7375
7476 Returns
7577 -------
76- self
77- Fitted MinMaxScaler
78+ Self
7879 """
7980 X = nw .from_native (X , eager_only = True )
8081
8182 self .feature_names_in_ = _resolve_columns (X , columns )
8283 data_min = X .select (nw .col (self .feature_names_in_ ).min ())
8384 data_max = X .select (nw .col (self .feature_names_in_ ).max ())
84- data_range : nwt .DataFrameT = data_max .select (
85+ data_range : nwt .DataFrame = data_max .select (
8586 nw .col (c ).__sub__ (data_min [c ]) for c in self .feature_names_in_
8687 )
8788
@@ -148,9 +149,10 @@ def save(self, path: PathLike):
148149 Added in version 0.2.0
149150 ----------------------
150151 """
151- with zipfile .ZipFile (
152- path , "w"
153- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
152+ with (
153+ zipfile .ZipFile (path , "w" ) as archive ,
154+ tempfile .TemporaryDirectory () as tmpdir ,
155+ ):
154156 tmpdir = Path (tmpdir )
155157
156158 self .min_ .write_parquet (tmpdir / "min_.parquet" )
@@ -185,9 +187,10 @@ def load(self, path: PathLike):
185187 Added in version 0.2.0
186188 ----------------------
187189 """
188- with zipfile .ZipFile (
189- path , "r"
190- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
190+ with (
191+ zipfile .ZipFile (path , "r" ) as archive ,
192+ tempfile .TemporaryDirectory () as tmpdir ,
193+ ):
191194 archive .extractall (tmpdir )
192195
193196 self .min_ = nw .read_parquet (f"{ tmpdir } /min_.parquet" , native_namespace = pl )
@@ -260,9 +263,10 @@ def run(
260263 return X .with_columns (self ._run_one (c ) for c in _resolve_columns (X , columns ))
261264
262265 def save (self , path : PathLike ):
263- with zipfile .ZipFile (
264- path , "w"
265- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
266+ with (
267+ zipfile .ZipFile (path , "w" ) as archive ,
268+ tempfile .TemporaryDirectory () as tmpdir ,
269+ ):
266270 tmpdir = Path (tmpdir )
267271
268272 self .mean_ .write_parquet (tmpdir / "mean_.parquet" )
@@ -282,9 +286,10 @@ def save(self, path: PathLike):
282286 return self
283287
284288 def load (self , path : PathLike ):
285- with zipfile .ZipFile (
286- path , "r"
287- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
289+ with (
290+ zipfile .ZipFile (path , "r" ) as archive ,
291+ tempfile .TemporaryDirectory () as tmpdir ,
292+ ):
288293 archive .extractall (tmpdir )
289294
290295 self .mean_ = nw .read_parquet (f"{ tmpdir } /mean_.parquet" , native_namespace = pl )
@@ -352,9 +357,10 @@ def run(
352357 return X .with_columns (self ._run_one (c ) for c in _resolve_columns (X , columns ))
353358
354359 def save (self , path : PathLike ):
355- with zipfile .ZipFile (
356- path , "w"
357- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
360+ with (
361+ zipfile .ZipFile (path , "w" ) as archive ,
362+ tempfile .TemporaryDirectory () as tmpdir ,
363+ ):
358364 tmpdir = Path (tmpdir )
359365
360366 self .median_ .write_parquet (tmpdir / "median_.parquet" )
@@ -374,9 +380,10 @@ def save(self, path: PathLike):
374380 return self
375381
376382 def load (self , path : PathLike ):
377- with zipfile .ZipFile (
378- path , "r"
379- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
383+ with (
384+ zipfile .ZipFile (path , "r" ) as archive ,
385+ tempfile .TemporaryDirectory () as tmpdir ,
386+ ):
380387 archive .extractall (tmpdir )
381388
382389 self .median_ = nw .read_parquet (
@@ -426,9 +433,10 @@ def fit_transform(
426433 return self .fit (X , columns = columns ).transform (X )
427434
428435 def save (self , path : PathLike ):
429- with zipfile .ZipFile (
430- path , "w"
431- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
436+ with (
437+ zipfile .ZipFile (path , "w" ) as archive ,
438+ tempfile .TemporaryDirectory () as tmpdir ,
439+ ):
432440 tmpdir = Path (tmpdir )
433441
434442 for k , v in self .categories_ .items ():
@@ -453,9 +461,10 @@ def load(self, path: PathLike):
453461 Added in version 0.2.0
454462 ----------------------
455463 """
456- with zipfile .ZipFile (
457- path , "r"
458- ) as archive , tempfile .TemporaryDirectory () as tmpdir :
464+ with (
465+ zipfile .ZipFile (path , "r" ) as archive ,
466+ tempfile .TemporaryDirectory () as tmpdir ,
467+ ):
459468 archive .extractall (tmpdir )
460469
461470 self .categories_ = {
0 commit comments