Skip to content

Commit

Permalink
fix tests and coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-saigre committed Jul 17, 2024
1 parent 508fd2b commit 832a7f6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 197 deletions.
11 changes: 10 additions & 1 deletion tests/test_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def plot_4():

return fig

def plot_5():
fig = px.imshow([[1, 20, 30],
[20, 1, 60],
[30, 60, 1]])
fig.data[0].z = None
return fig

def test_1():
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"), img_name="/tmp/tikzplotly/fig1.png")
Expand All @@ -62,4 +68,7 @@ def test_3():
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"), img_name="/tmp/tikzplotly/fig3.png")

def test_4():
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png")
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png")

def test_5():
assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex"))
9 changes: 9 additions & 0 deletions tests/test_heatmap/test_heatmap_5_reference.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\begin{tikzpicture}


\begin{axis}[
y dir=reverse
]
\addplot coordinates {};
\end{axis}
\end{tikzpicture}
25 changes: 6 additions & 19 deletions tests/test_markers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import plotly.express as px
import plotly.graph_objects as go
import pytest
import numpy as np
import os
from .helpers import assert_equality
Expand All @@ -8,30 +9,18 @@
this_dir = pathlib.Path(__file__).resolve().parent
test_name = "test_markers"

def plot_1():
def plot_1(symbol):

df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")

fig.update_traces(marker=dict(size=12,
symbol = symbol,
line=dict(width=2,
color='DarkSlateGrey')),
selector=dict(mode='markers'))
return fig

def plot_1_bis():

df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")

fig.update_traces(marker=dict(size=12,
symbol = "1",
line=dict(width=2,
color='DarkSlateGrey')),
selector=dict(mode='markers'))
return fig


def plot_2():
np.random.seed(1)
x = np.random.uniform(low=3, high=6, size=(500,))
Expand Down Expand Up @@ -92,11 +81,9 @@ def plot_3():

return fig

def test_1():
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))

def test_1_bis():
assert_equality(plot_1_bis(), os.path.join(this_dir, test_name, test_name + "_1_bis_reference.tex"))
@pytest.mark.parametrize("symbol", ["circle", 0, "0"])
def test_1(symbol):
assert_equality(plot_1(symbol), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))

def test_2():
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
Expand Down
176 changes: 0 additions & 176 deletions tests/test_markers/test_markers_1_bis_reference.tex

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_tikzplotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

def test_tikzplotly():
fig = px.scatter(x=[1, 2, 3], y=[1, 2, 3])
tikzplotly.save("/tmp/test_tikzplotly.tex", fig)
tikzplotly.save("/tmp/tikzplotly/test_tikzplotly.tex", fig)

0 comments on commit 832a7f6

Please sign in to comment.