forked from LineaLabs/lineapy
-
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.
LIN-189 Test matplotlib examples (LineaLabs#628)
* Test dash_joinstyle.py example * Test aliased.py example * Test exercice_3.py example * Test alpha.py example * Remove unnecessary file * Directly version-control scripts that were tested Original submodule (https://github.com/rougier/matplotlib-tutorial.git) relies on outdated matplotlib version, so many of its examples do not work. We may want to use materials in official matplotlib repo. In the mean time, remove this outdated submodule, but keep its scripts that could be tested (by directly version-controlling them). Co-authored-by: Yifan Wu <yifan1030@gmail.com>
- Loading branch information
Showing
16 changed files
with
395 additions
and
9 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
11 changes: 11 additions & 0 deletions
11
tests/integration/__snapshots__/test_slice/test_slice[matplotlib_aliased].py
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,11 @@ | ||
import matplotlib.pyplot as plt | ||
|
||
size = 128, 16 | ||
dpi = 72.0 | ||
figsize = size[0] / float(dpi), size[1] / float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
plt.axes([0, 0, 1, 1], frameon=False) | ||
plt.text(0.5, 0.5, "Aliased", ha="center", va="center") | ||
plt.xlim(0, 1), plt.ylim(0, 1) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig("../figures/aliased.png", dpi=dpi) |
35 changes: 35 additions & 0 deletions
35
tests/integration/__snapshots__/test_slice/test_slice[matplotlib_dash_joinstyle].py
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,35 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
size = 256, 16 | ||
dpi = 72.0 | ||
figsize = size[0] / float(dpi), size[1] / float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
plt.axes([0, 0, 1, 1], frameon=False) | ||
plt.plot( | ||
np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="miter", | ||
) | ||
plt.plot( | ||
4 + np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="bevel", | ||
) | ||
plt.plot( | ||
8 + np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="round", | ||
) | ||
plt.xlim(0, 12), plt.ylim(-1, 2) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig("../figures/dash_joinstyle.png", dpi=dpi) |
14 changes: 14 additions & 0 deletions
14
tests/integration/__snapshots__/test_slice/test_slice[matplotlib_exercise_3].py
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,14 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
plt.figure(figsize=(8, 5), dpi=80) | ||
plt.subplot(111) | ||
X = np.linspace(-np.pi, np.pi, 256, endpoint=True) | ||
C, S = np.cos(X), np.sin(X) | ||
plt.plot(X, C, color="blue", linewidth=2.5, linestyle="-") | ||
plt.plot(X, S, color="red", linewidth=2.5, linestyle="-") | ||
plt.xlim(-4.0, 4.0) | ||
plt.xticks(np.linspace(-4, 4, 9, endpoint=True)) | ||
plt.ylim(-1.0, 1.0) | ||
plt.yticks(np.linspace(-1, 1, 5, endpoint=True)) | ||
linea_artifact_value = plt.gcf() |
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,21 @@ | ||
# This is the manual slice of: | ||
# lineapy.file_system | ||
# from file: | ||
# sources/matplotlib-tutorial/scripts/aliased.py | ||
|
||
# To verify that linea produces the same slice, run: | ||
# pytest -m integration --runxfail -vv 'tests/integration/test_slice.py::test_slice[matplotlib_aliased]' | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
size = 128, 16 | ||
dpi = 72.0 | ||
figsize = size[0] / float(dpi), size[1] / float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0, 0, 1, 1], frameon=False) | ||
plt.rcParams["text.antialiased"] = False | ||
plt.text(0.5, 0.5, "Aliased", ha="center", va="center") | ||
plt.xlim(0, 1), plt.ylim(0, 1) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig("../figures/aliased.png", dpi=dpi) |
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,21 @@ | ||
# This is the manual slice of: | ||
# lineapy.file_system | ||
# from file: | ||
# sources/matplotlib-tutorial/scripts/alpha.py | ||
|
||
# To verify that linea produces the same slice, run: | ||
# pytest -m integration --runxfail -vv 'tests/integration/test_slice.py::test_slice[matplotlib_alpha]' | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
size = 256, 16 | ||
dpi = 72.0 | ||
figsize = size[0] / float(dpi), size[1] / float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0, 0.1, 1, 0.8], frameon=False) | ||
for i in range(1, 11): | ||
plt.axvline(i, linewidth=1, color="blue", alpha=0.25 + 0.75 * i / 10.0) | ||
plt.xlim(0, 11) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig("../figures/alpha.png", dpi=dpi) |
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,44 @@ | ||
# This is the manual slice of: | ||
# lineapy.file_system | ||
# from file: | ||
# sources/matplotlib-tutorial/scripts/dash_joinstyle.py | ||
|
||
# To verify that linea produces the same slice, run: | ||
# pytest -m integration --runxfail -vv 'tests/integration/test_slice.py::test_slice[matplotlib_dash_joinstyle]' | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
size = 256, 16 | ||
dpi = 72.0 | ||
figsize = size[0] / float(dpi), size[1] / float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0, 0, 1, 1], frameon=False) | ||
plt.plot( | ||
np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="miter", | ||
) | ||
plt.plot( | ||
4 + np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="bevel", | ||
) | ||
plt.plot( | ||
8 + np.arange(3), | ||
[0, 1, 0], | ||
color="blue", | ||
dashes=[12, 5], | ||
linewidth=8, | ||
dash_joinstyle="round", | ||
) | ||
plt.xlim(0, 12), plt.ylim(-1, 2) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig("../figures/dash_joinstyle.png", dpi=dpi) |
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,22 @@ | ||
# This is the manual slice of: | ||
# plt.gcf() | ||
# from file: | ||
# sources/matplotlib-tutorial/scripts/exercice_3.py | ||
|
||
# To verify that linea produces the same slice, run: | ||
# pytest -m integration --runxfail -vv 'tests/integration/test_slice.py::test_slice[matplotlib_exercise_3]' | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
plt.figure(figsize=(8, 5), dpi=80) | ||
plt.subplot(111) | ||
X = np.linspace(-np.pi, np.pi, 256, endpoint=True) | ||
C, S = np.cos(X), np.sin(X) | ||
plt.plot(X, C, color="blue", linewidth=2.5, linestyle="-") | ||
plt.plot(X, S, color="red", linewidth=2.5, linestyle="-") | ||
plt.xlim(-4.0, 4.0) | ||
plt.xticks(np.linspace(-4, 4, 9, endpoint=True)) | ||
plt.ylim(-1.0, 1.0) | ||
plt.yticks(np.linspace(-1, 1, 5, endpoint=True)) | ||
linea_artifact_value = plt.gcf() |
Empty file.
16 changes: 16 additions & 0 deletions
16
tests/integration/sources/matplotlib-tutorial/scripts/aliased.py
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,16 @@ | ||
import matplotlib.pyplot as plt | ||
|
||
size = 128,16 | ||
dpi = 72.0 | ||
figsize= size[0]/float(dpi),size[1]/float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0,0,1,1], frameon=False) | ||
|
||
plt.rcParams['text.antialiased'] = False | ||
plt.text(0.5,0.5,"Aliased",ha='center',va='center') | ||
|
||
plt.xlim(0,1),plt.ylim(0,1), | ||
plt.xticks([]),plt.yticks([]) | ||
|
||
plt.savefig('../figures/aliased.png', dpi=dpi) |
15 changes: 15 additions & 0 deletions
15
tests/integration/sources/matplotlib-tutorial/scripts/alpha.py
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,15 @@ | ||
import matplotlib.pyplot as plt | ||
|
||
size = 256,16 | ||
dpi = 72.0 | ||
figsize= size[0]/float(dpi),size[1]/float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0,0.1,1,.8], frameon=False) | ||
|
||
for i in range(1,11): | ||
plt.axvline(i, linewidth=1, color='blue',alpha=.25+.75*i/10.) | ||
|
||
plt.xlim(0,11) | ||
plt.xticks([]), plt.yticks([]) | ||
plt.savefig('../figures/alpha.png', dpi=dpi) |
19 changes: 19 additions & 0 deletions
19
tests/integration/sources/matplotlib-tutorial/scripts/dash_joinstyle.py
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,19 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
size = 256,16 | ||
dpi = 72.0 | ||
figsize= size[0]/float(dpi),size[1]/float(dpi) | ||
fig = plt.figure(figsize=figsize, dpi=dpi) | ||
fig.patch.set_alpha(0) | ||
plt.axes([0,0,1,1], frameon=False) | ||
|
||
plt.plot(np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'miter') | ||
plt.plot(4+np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'bevel') | ||
plt.plot(8+np.arange(3), [0,1,0], color="blue", dashes=[12,5], linewidth=8, dash_joinstyle = 'round') | ||
|
||
plt.xlim(0,12), plt.ylim(-1,2) | ||
plt.xticks([]), plt.yticks([]) | ||
|
||
plt.savefig('../figures/dash_joinstyle.png', dpi=dpi) | ||
#show() |
Oops, something went wrong.