Skip to content

Commit

Permalink
Fix same min/max values
Browse files Browse the repository at this point in the history
  • Loading branch information
cheziyi committed Aug 30, 2024
1 parent 49d4b96 commit 55cfd84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "synnax-shared"
version = "1.7.2"
version = "1.7.3"
description = "Synnax shared Python pacakges"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
10 changes: 8 additions & 2 deletions src/synnax_shared/data_processing/scaler/min_max_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ def __init__(self, min: float | None = None, max: float | None = None):
self.max = max

def fit_transform(self, ndarray: NDArray) -> NDArray:
if self.min is not None or self.max is not None:
raise ValueError("MinMaxScaler is already fitted")
float_ndarray = ndarray.astype(float)
self.min = numpy.nanmin(float_ndarray)
self.max = numpy.nanmax(float_ndarray)
min = numpy.nanmin(float_ndarray)
max = numpy.nanmax(float_ndarray)
if min == max:
min = max - 1
self.min = min
self.max = max
return self.transform(float_ndarray)

def transform(self, ndarray: NDArray) -> NDArray:
Expand Down

0 comments on commit 55cfd84

Please sign in to comment.