Skip to content

Fix: use math.log for Python float bounds in hyperparameter_sampling#29

Open
jasherb wants to merge 1 commit into
SamuelGabriel:mainfrom
jasherb:fix/hyperparam-sampling-scalar-math-log
Open

Fix: use math.log for Python float bounds in hyperparameter_sampling#29
jasherb wants to merge 1 commit into
SamuelGabriel:mainfrom
jasherb:fix/hyperparam-sampling-scalar-math-log

Conversation

@jasherb
Copy link
Copy Markdown

@jasherb jasherb commented May 26, 2026

Problem

test_distribution_normalizers has been failing since f04d3ca ("sync"):

TypeError: log(): argument 'input' (position 1) must be Tensor, not float

In pfns/priors/hyperparameter_sampling.py, self.lower and self.upper
are Python float attributes of the dataclass, but f04d3ca changed
math.log(...) to torch.log(...) for both, in three methods.
torch.log doesn't accept Python scalars, so it raises immediately on
any call into normalize() (or the new unnormalize()) with log=True.

Fix

Revert the scalar-side calls to math.log in:

  • UniformFloatDistConfig.normalize
  • UniformFloatDistConfig.unnormalize
  • PowerUniformFloatDistConfig.unnormalize

The tensor-side torch.log(value) calls stay as they were.

Verification

Before:
1 failed (test_distribution_normalizers), 30 passed

After:
pytest tests/ -ra --ignore=tests/priors/test_convert_prior_to_x_only_format.py
31 passed

(The ignored file has separate pre-existing failures also introduced in
f04d3ca — happy to file a follow-up PR if useful.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant