From bc118a986bed352c46ce02589985615eef376ecb Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 10:26:58 -0500 Subject: [PATCH 1/8] Added test_hist --- lib/matplotlib/tests/test_datetime.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 53958229f174..e792a41d8ecb 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -170,11 +170,20 @@ def test_hexbin(self): fig, ax = plt.subplots() ax.hexbin(...) - @pytest.mark.xfail(reason="Test for hist not written yet") + # Benjamin + # @pytest.mark.xfail(reason="Test for hist not written yet") @mpl.style.context("default") def test_hist(self): - fig, ax = plt.subplots() - ax.hist(...) + mpl.rcParams["date.converter"] = "concise" + N = 10 + fig, (ax1, ax2, ax3) = plt.subplots( + 3, 1, layout="constrained", figsize=(6, 10) + ) + + x = np.array([datetime.datetime(2023, 9, n) for n in range(1, N)]) + ax1.hist(x, range(1, N)) + ax2.hist(range(1, N), x) + ax3.hist(x, x) @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") From 1dd3dddb0e813714dba73238f564bb30392513ab Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 10:34:41 -0500 Subject: [PATCH 2/8] reset --- lib/matplotlib/tests/test_datetime.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index e792a41d8ecb..53958229f174 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -170,20 +170,11 @@ def test_hexbin(self): fig, ax = plt.subplots() ax.hexbin(...) - # Benjamin - # @pytest.mark.xfail(reason="Test for hist not written yet") + @pytest.mark.xfail(reason="Test for hist not written yet") @mpl.style.context("default") def test_hist(self): - mpl.rcParams["date.converter"] = "concise" - N = 10 - fig, (ax1, ax2, ax3) = plt.subplots( - 3, 1, layout="constrained", figsize=(6, 10) - ) - - x = np.array([datetime.datetime(2023, 9, n) for n in range(1, N)]) - ax1.hist(x, range(1, N)) - ax2.hist(range(1, N), x) - ax3.hist(x, x) + fig, ax = plt.subplots() + ax.hist(...) @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") From b8a378f602abca9b131f418737d139bd74d8bc34 Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 10:36:40 -0500 Subject: [PATCH 3/8] remove comment --- lib/matplotlib/tests/test_datetime.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index e792a41d8ecb..d4d8d76e3a83 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -170,8 +170,6 @@ def test_hexbin(self): fig, ax = plt.subplots() ax.hexbin(...) - # Benjamin - # @pytest.mark.xfail(reason="Test for hist not written yet") @mpl.style.context("default") def test_hist(self): mpl.rcParams["date.converter"] = "concise" From b8b693aa89c58dbbf781637b814d596028fb9296 Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 10:45:25 -0500 Subject: [PATCH 4/8] Added test_hist --- lib/matplotlib/tests/test_datetime.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 53958229f174..d4d8d76e3a83 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -170,11 +170,18 @@ def test_hexbin(self): fig, ax = plt.subplots() ax.hexbin(...) - @pytest.mark.xfail(reason="Test for hist not written yet") @mpl.style.context("default") def test_hist(self): - fig, ax = plt.subplots() - ax.hist(...) + mpl.rcParams["date.converter"] = "concise" + N = 10 + fig, (ax1, ax2, ax3) = plt.subplots( + 3, 1, layout="constrained", figsize=(6, 10) + ) + + x = np.array([datetime.datetime(2023, 9, n) for n in range(1, N)]) + ax1.hist(x, range(1, N)) + ax2.hist(range(1, N), x) + ax3.hist(x, x) @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") From 8ae4b436a59cfa994e858b40a91f062f4650f7ca Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 11:39:11 -0500 Subject: [PATCH 5/8] added test_hist.py to test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index d4d8d76e3a83..f735eb8c7876 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -172,16 +172,19 @@ def test_hexbin(self): @mpl.style.context("default") def test_hist(self): - mpl.rcParams["date.converter"] = "concise" - N = 10 - fig, (ax1, ax2, ax3) = plt.subplots( - 3, 1, layout="constrained", figsize=(6, 10) - ) + mpl.rcParams["date.converter"] = 'concise' + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 12), constrained_layout=True) - x = np.array([datetime.datetime(2023, 9, n) for n in range(1, N)]) - ax1.hist(x, range(1, N)) - ax2.hist(range(1, N), x) - ax3.hist(x, x) + start_date = datetime.datetime(2023, 10, 1) + time_delta = datetime.timedelta(days=1) + + values1 = np.random.randint(1, 10, 30) + values2 = np.random.randint(1, 10, 30) + values3 = np.random.randint(1, 10, 30) + + ax1.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values1) + ax2.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values2) + ax3.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values3) @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") From c51bebe21ce68469c1cc29b551e2570fde9d5d47 Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Sat, 7 Oct 2023 14:35:54 -0500 Subject: [PATCH 6/8] comply with PEP8 --- lib/matplotlib/tests/test_datetime.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index f735eb8c7876..8c5b48ba2445 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -173,7 +173,7 @@ def test_hexbin(self): @mpl.style.context("default") def test_hist(self): mpl.rcParams["date.converter"] = 'concise' - fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(8, 12), constrained_layout=True) + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) start_date = datetime.datetime(2023, 10, 1) time_delta = datetime.timedelta(days=1) @@ -182,9 +182,21 @@ def test_hist(self): values2 = np.random.randint(1, 10, 30) values3 = np.random.randint(1, 10, 30) - ax1.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values1) - ax2.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values2) - ax3.hist([start_date + i * time_delta for i in range(30)],bins=10,weights=values3) + ax1.hist( + [start_date + i * time_delta for i in range(30)], + bins=10, + weights=values1 + ) + ax2.hist( + [start_date + i * time_delta for i in range(30)], + bins=10, + weights=values2 + ) + ax3.hist( + [start_date + i * time_delta for i in range(30)], + bins=10, + weights=values3 + ) @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") From a8ba1e985d1fb970fc07331e0147c29474a44ffa Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Mon, 9 Oct 2023 19:46:00 -0500 Subject: [PATCH 7/8] datetime as bins --- lib/matplotlib/tests/test_datetime.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 8c5b48ba2445..26ee2eb2f106 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -173,7 +173,6 @@ def test_hexbin(self): @mpl.style.context("default") def test_hist(self): mpl.rcParams["date.converter"] = 'concise' - fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) start_date = datetime.datetime(2023, 10, 1) time_delta = datetime.timedelta(days=1) @@ -182,6 +181,9 @@ def test_hist(self): values2 = np.random.randint(1, 10, 30) values3 = np.random.randint(1, 10, 30) + bin_edges = [start_date + i * time_delta for i in range(31)] + + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.hist( [start_date + i * time_delta for i in range(30)], bins=10, @@ -198,6 +200,24 @@ def test_hist(self): weights=values3 ) + fig, (ax4, ax5, ax6) = plt.subplots(3, 1, constrained_layout=True) + ax4.hist( + [start_date + i * time_delta for i in range(30)], + bins=bin_edges, + weights=values1 + ) + ax5.hist( + [start_date + i * time_delta for i in range(30)], + bins=bin_edges, + weights=values2 + ) + ax6.hist( + [start_date + i * time_delta for i in range(30)], + bins=bin_edges, + edgecolor='black', + weights=values3 + ) + @pytest.mark.xfail(reason="Test for hist2d not written yet") @mpl.style.context("default") def test_hist2d(self): From c278a1f42111138534918eeeacc6a93ca18255a4 Mon Sep 17 00:00:00 2001 From: yangyangdotcom Date: Mon, 9 Oct 2023 19:46:13 -0500 Subject: [PATCH 8/8] datetime as bins --- lib/matplotlib/tests/test_datetime.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 26ee2eb2f106..8fa8b1f4a83b 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -214,7 +214,6 @@ def test_hist(self): ax6.hist( [start_date + i * time_delta for i in range(30)], bins=bin_edges, - edgecolor='black', weights=values3 )