Skip to content

add global float_precision config - #1470

Merged
rcap107 merged 3 commits into
skrub-data:mainfrom
georgescutelnicu:float_precision_global_config
Jul 8, 2025
Merged

rcap107 merged 3 commits into
skrub-data:mainfrom
georgescutelnicu:float_precision_global_config

Conversation

@georgescutelnicu

@georgescutelnicu georgescutelnicu commented Jun 26, 2025 •

Copy link
Copy Markdown
Contributor

Related to #1410

This is a follow up to #1463 pr. The earlier approach handled float_precision directly in TableReport. Im opening this new pr to keep the history clean and focused on the new approach.

In the test i used the target y = fetch_employee_salaries().y instead of X because we needed a float column to check float_precision against.

@Vincent-Maladiere Vincent-Maladiere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @georgescutelnicu, the PR is already in good shape! Some feedback

Comment thread skrub/_config.py
local_config["enable_subsampling"] = enable_subsampling

if float_precision is not None:
if not isinstance(float_precision, numbers.Integral) or float_precision <= 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of a nitpick: should we allow float_precision = 0? This would display integer values like 1.24 -> 1

@georgescutelnicu georgescutelnicu Jun 26, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't setting it to 0 giving the same output as setting it to 1 since the formatting uses significant digits rather than fixed decimal places?

From python docs (string — Common string operations): 'g' General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in either fixed-point format or in scientific notation, depending on its magnitude. A precision of 0 is treated as equivalent to a precision of 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my understanding was slightly off, but the question remains. If 0 is equivalent to 1, should we keep it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought it might confuse users into thinking 0 behaved differently, but since its treated the same as 1, we could keep it allowing for flexibility i guess, since it doesnt seem to cause any harm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I don't have a strong preference

Comment thread skrub/_reporting/_utils.py
Comment thread skrub/_reporting/_utils.py

@Vincent-Maladiere Vincent-Maladiere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @georgescutelnicu

@rcap107 rcap107 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks a lot @georgescutelnicu

@rcap107
rcap107 merged commit 7b5eb86 into skrub-data:main Jul 8, 2025
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.

4 participants