forked from skrub-data/skrub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clip the range of histograms when there are outliers (skrub-data#1157)
- Loading branch information
1 parent
d929329
commit a7abe4b
Showing
6 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from skrub._reporting import _plotting | ||
|
||
|
||
def test_histogram(): | ||
rng = np.random.default_rng(0) | ||
x = rng.normal(size=200) | ||
o = rng.uniform(-100, 100, size=10) | ||
|
||
data = pd.Series(np.concatenate([x, o])) | ||
_, n_low, n_high = _plotting.histogram(data) | ||
assert (n_low, n_high) == (5, 4) | ||
|
||
data = pd.Series(np.concatenate([x, o - 1000])) | ||
_, n_low, n_high = _plotting.histogram(data) | ||
assert (n_low, n_high) == (10, 0) | ||
|
||
data = pd.Series(np.concatenate([x, o + 1000])) | ||
_, n_low, n_high = _plotting.histogram(data) | ||
assert (n_low, n_high) == (0, 10) | ||
|
||
data = pd.Series(x) | ||
_, n_low, n_high = _plotting.histogram(data) | ||
assert (n_low, n_high) == (0, 0) | ||
|
||
data = pd.Series([0.0]) | ||
_, n_low, n_high = _plotting.histogram(data) | ||
assert (n_low, n_high) == (0, 0) |