Skip to content

Commit 4c549ad

Browse files
committed
in image encoder base, dim_reduction_factore is runtime-checked (has to be greater than 0, and an integer)
1 parent 6bd9342 commit 4c549ad

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pyvisim/encoders/_base_encoder.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,12 @@ def learn(
440440
:param images: An iterable of images.
441441
:param dim_reduction_factor: If a value is provided, a new PCA model will be used to reduce the dimensionality of the feature space
442442
:raises RuntimeError: If the encoder has no clustering model configured.
443+
:raises ValueError: If dim_reduction_factor is provided but is not a positive integer.
443444
"""
445+
if dim_reduction_factor is not None and (
446+
dim_reduction_factor <= 0 or not isinstance(dim_reduction_factor, int)
447+
):
448+
raise ValueError("dim_reduction_factor must be a positive integer.")
444449
if self._clustering_model is None:
445450
raise RuntimeError(
446451
"This encoder has no clustering model to fit. "

0 commit comments

Comments
 (0)