-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Line plots aligned from start #57594 #57713
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
Changes from all commits
d499f52
5f8ad5e
f3ce3dc
63b1f9f
d6eb450
e7e73e9
19d794e
b3d4ff1
6e22a86
6a20930
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,16 @@ class TestPeriodRange: | |
@pytest.mark.parametrize( | ||
"freq_offset, freq_period", | ||
[ | ||
("h", "h"), | ||
("7h", "7h"), | ||
("D", "D"), | ||
("W", "W"), | ||
("QE", "Q"), | ||
("15D", "15D"), | ||
("ME", "M"), | ||
("3ME", "3M"), | ||
("YE", "Y"), | ||
("8YE", "8Y"), | ||
("20s", "20s"), | ||
("2QE", "2Q"), | ||
], | ||
) | ||
def test_construction_from_string(self, freq_offset, freq_period): | ||
|
@@ -113,34 +119,6 @@ def test_construction_from_string(self, freq_offset, freq_period): | |
result = period_range(start=end, end=start, freq=freq_period, name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_construction_from_string_monthly(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for noticing code duplication in |
||
# non-empty | ||
expected = date_range( | ||
start="2017-01-01", periods=5, freq="ME", name="foo" | ||
).to_period() | ||
start, end = str(expected[0]), str(expected[-1]) | ||
|
||
result = period_range(start=start, end=end, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
result = period_range(start=start, periods=5, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
result = period_range(end=end, periods=5, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
# empty | ||
expected = PeriodIndex([], freq="M", name="foo") | ||
|
||
result = period_range(start=start, periods=0, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
result = period_range(end=end, periods=0, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
result = period_range(start=end, end=start, freq="M", name="foo") | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_construction_from_period(self): | ||
# upsampling | ||
start, end = Period("2017Q1", freq="Q"), Period("2018Q1", freq="Q") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
) | ||
from pandas.core.indexes.timedeltas import timedelta_range | ||
from pandas.tests.plotting.common import _check_ticks_props | ||
from pandas.tests.plotting.common import _check_inputdata_equals_outputdata | ||
|
||
from pandas.tseries.offsets import WeekOfMonth | ||
|
||
|
@@ -69,6 +70,31 @@ def test_fontsize_set_correctly(self): | |
for label in ax.get_xticklabels() + ax.get_yticklabels(): | ||
assert label.get_fontsize() == 2 | ||
|
||
@pytest.mark.parametrize("freq", ["20s","3s","60min","5min","7h","4D","8W","11M","2Q","Y", "3Y", "10Y"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
def test_period_range_content(self, freq): | ||
# Setup your DataFrame as in your scenario | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of the comments, e.g. |
||
idx = period_range("2000-01-01", freq=freq, periods=4) | ||
df = DataFrame( | ||
np.array([0, 1, 0, 1]), | ||
index=idx, | ||
columns=["A"], | ||
) | ||
|
||
ax = df.plot() | ||
_check_inputdata_equals_outputdata(idx=idx, ax=ax) | ||
|
||
@pytest.mark.parametrize("freq", ["20s","3s","60min","5min","7h","4D","8W","11ME","2QE","YE", "3YE", "10YE"]) | ||
def test_date_range_content(self, freq): | ||
# Setup your DataFrame as in your scenario | ||
idx = date_range("2000/01/01", freq=freq, periods=4) | ||
df = DataFrame( | ||
np.array([0, 1, 0, 1]), | ||
index=idx, | ||
columns=["A"], | ||
) | ||
ax = df.plot() | ||
_check_inputdata_equals_outputdata(idx=idx, ax=ax) | ||
|
||
def test_frame_inferred(self): | ||
# inferred freq | ||
idx = date_range("1/1/1987", freq="MS", periods=100) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please check
ruff
,ruff-format
andcodespell
errors online 313
?If you try the following command:
pre-commit run --all-file
, it should help fix these errors.