Skip to content

Commit

Permalink
Merge pull request #431 from nschloe/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
nschloe committed Jul 24, 2020
2 parents ddf7ae3 + 83e474b commit 32a3bb9
Show file tree
Hide file tree
Showing 59 changed files with 66 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- uses: actions/checkout@v2
Expand All @@ -25,7 +25,7 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/setup-python@v1
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v2
Expand Down
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ default:
tag:
# Make sure we're on the master branch
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
# @echo "Tagging v$(VERSION)..."
# git tag v$(VERSION)
# git push --tags
curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "v$(VERSION)"}' https://api.github.com/repos/nschloe/tikzplotlib/releases

upload:
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
rm -f dist/*
# python3 setup.py sdist bdist_wheel
# https://stackoverflow.com/a/58756491/353337
python3 -m pep517.build --source --binary .
twine upload dist/*
Expand All @@ -26,10 +22,7 @@ clean:
@rm -rf *.egg-info/ build/ dist/ MANIFEST

format:
isort -rc .
black .

black:
isort .
black .

lint:
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def assert_equality(
this_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(this_dir, filename), encoding="utf-8") as f:
reference = f.read()
assert reference == code, _unidiff_output(code, reference)
assert reference == code, _unidiff_output(reference, code)

if assert_compilation:
plot()
Expand Down
2 changes: 0 additions & 2 deletions test/test_annotate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down Expand Up @@ -38,7 +37,6 @@ def plot():

def test():
assert_equality(plot, __file__[:-3] + "_reference.tex")
return


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion test/test_axvline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_barchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_barchart_errorbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
2 changes: 0 additions & 2 deletions test/test_barchart_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand All @@ -34,7 +33,6 @@ def plot():

def test():
assert_equality(plot, "test_barchart_legend_reference.tex")
return


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion test/test_basic_sin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
See: https://github.com/nschloe/tikzplotlib/pull/134
"""
import matplotlib.pyplot as plt

from helpers import assert_equality


Expand Down
6 changes: 3 additions & 3 deletions test/test_cleanfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_wireframe3D(self):

def test_surface3D(self):
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from matplotlib.ticker import FormatStrFormatter, LinearLocator

# Make data.
X = np.arange(-5, 5, 0.25)
Expand Down Expand Up @@ -265,8 +265,8 @@ def test_trisurface3D(self):
plt.close("all")

def test_contour3D(self):
from mpl_toolkits.mplot3d import axes3d
from matplotlib import cm
from mpl_toolkits.mplot3d import axes3d

with plt.rc_context(rc=RC_PARAMS):
fig = plt.figure()
Expand All @@ -279,8 +279,8 @@ def test_contour3D(self):
plt.close("all")

def test_polygon3D(self):
from matplotlib.collections import PolyCollection
from matplotlib import colors as mcolors
from matplotlib.collections import PolyCollection

with plt.rc_context(rc=RC_PARAMS):
fig = plt.figure()
Expand Down
1 change: 0 additions & 1 deletion test/test_colorbars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib as mpl
import matplotlib.pyplot as plt

from helpers import assert_equality


Expand Down
6 changes: 3 additions & 3 deletions test/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


def plot():
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np

x, y = np.meshgrid(np.linspace(0, 1), np.linspace(0, 1))
z = x ** 2 - y ** 2

fig = plt.figure()
plt.pcolormesh(x, y, z, cmap=cm.viridis)
plt.pcolormesh(x, y, z, cmap=cm.viridis, shading="gouraud")

return fig

Expand Down
1 change: 0 additions & 1 deletion test/test_contourf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_custom_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
3 changes: 1 addition & 2 deletions test/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import datetime as date

import matplotlib.pyplot as plt
from matplotlib import dates

from helpers import assert_equality
from matplotlib import dates


def plot():
Expand Down
3 changes: 1 addition & 2 deletions test/test_datetime_paths.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import datetime as date

import matplotlib.pyplot as plt
from matplotlib import dates

from helpers import assert_equality
from matplotlib import dates


def plot():
Expand Down
1 change: 0 additions & 1 deletion test/test_dual_axis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_errorband.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_errorbar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib.pyplot as plt

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_escape_chars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# https://github.com/nschloe/tikzplotlib/issues/332
import matplotlib.pyplot as plt

from helpers import assert_equality


Expand Down
2 changes: 1 addition & 1 deletion test/test_externalize_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure()
with plt.style.context("ggplot"):
Expand Down
1 change: 0 additions & 1 deletion test/test_fancy_colorbar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
3 changes: 1 addition & 2 deletions test/test_fancybox.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Taken from http://matplotlib.org/examples/pylab_examples/fancybox_demo.html
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
from matplotlib.patches import FancyBboxPatch

from helpers import assert_equality
from matplotlib.patches import FancyBboxPatch

# Bbox object around which the fancy box will be drawn.
bb = mtransforms.Bbox([[0.3, 0.4], [0.7, 0.6]])
Expand Down
1 change: 0 additions & 1 deletion test/test_fillstyle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_heat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
1 change: 0 additions & 1 deletion test/test_histogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
6 changes: 3 additions & 3 deletions test/test_image_plot_lower.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import matplotlib.pyplot as plt

from helpers import assert_equality

# the picture 'lena.png' with origin='lower' is flipped upside-down.
# So it has to be upside-down in the pdf-file as well.


def plot():
from matplotlib import rcParams
import matplotlib.image as mpimg
import os

import matplotlib.image as mpimg
from matplotlib import rcParams

this_dir = os.path.dirname(os.path.realpath(__file__))
img = mpimg.imread(os.path.join(this_dir, "lena.png"))

Expand Down
5 changes: 3 additions & 2 deletions test/test_image_plot_upper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@


def plot():
from matplotlib import rcParams
import matplotlib.image as mpimg
import os

import matplotlib.image as mpimg
from matplotlib import rcParams

this_dir = os.path.dirname(os.path.realpath(__file__))
img = mpimg.imread(os.path.join(this_dir, "lena.png"))

Expand Down
1 change: 0 additions & 1 deletion test/test_legend_best_location.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
2 changes: 1 addition & 1 deletion test/test_legend_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
import numpy as np
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(figsize=(17, 6))
ax.plot(np.array([1, 5]), label="Test 1")
Expand Down
2 changes: 1 addition & 1 deletion test/test_legend_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure()

Expand Down
1 change: 0 additions & 1 deletion test/test_legend_line_scatter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import matplotlib.pyplot as plt
import numpy as np

from helpers import assert_equality


Expand Down
2 changes: 1 addition & 1 deletion test/test_legends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure()

Expand Down
2 changes: 1 addition & 1 deletion test/test_legends2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

fig, ax = plt.subplots(3, 3, sharex="col", sharey="row")
axes = [ax[i][j] for i in range(len(ax)) for j in range(len(ax[i]))]
Expand Down
2 changes: 1 addition & 1 deletion test/test_line_color_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def plot():
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

fig = plt.figure()
with plt.style.context("ggplot"):
Expand Down
1 change: 0 additions & 1 deletion test/test_line_dashes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib.pyplot as plt

from helpers import assert_equality


Expand Down

0 comments on commit 32a3bb9

Please sign in to comment.