Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat binwidth as approximate to avoid dropping outermost datapoints #3489

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Sep 24, 2023

This PR changes the interpretation of the binwidth parameter in histplot and objects.Hist.

With the previous implementation, floating point errors could cause the largest datapoint(s) to be silently dropped. The solution here is to always honor the bin range (either the explicit as specified through binrange or implicit as computed from the data range) and to make the actual bin width only approximately equal to the binwidth parameter when binwidth does not evenly divide it.

I could not think of a simple + robust solution to detect and handle floating point issues while also reliably honoring expected bin ranges, and I think that the expected violation of expectations will be smaller this way, although it is a minor API change. In most cases it should not be noticeable.

Fixes #3220

@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Merging #3489 (ba0f186) into master (c01e103) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3489      +/-   ##
==========================================
- Coverage   98.33%   98.33%   -0.01%     
==========================================
  Files          75       75              
  Lines       24570    24569       -1     
==========================================
- Hits        24162    24161       -1     
  Misses        408      408              
Files Changed Coverage Δ
seaborn/_stats/counting.py 100.00% <100.00%> (ø)
tests/test_distributions.py 99.80% <100.00%> (ø)

@mwaskom mwaskom merged commit 65d8692 into master Sep 25, 2023
12 checks passed
@mwaskom mwaskom deleted the api/hist_binwidth branch September 25, 2023 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

histplot dropping data unexpectedly
1 participant