Skip to content
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

Fix devdeps CI #98

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions glue_plotly/common/base_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ def axis(viewer_state, ax):
title = getattr(viewer_state, f'{ax}_att').label
range = [getattr(viewer_state, f'{ax}_min'), getattr(viewer_state, f'{ax}_max')]
return dict(
title=title,
titlefont=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
title=dict(
text=title,
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
backgroundcolor=settings.BACKGROUND_COLOR,
showspikes=False,
Expand Down
12 changes: 7 additions & 5 deletions glue_plotly/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ def base_rectilinear_axis(viewer_state, axis):
range = [getattr(viewer_state, f'{axis}_min'), getattr(viewer_state, f'{axis}_max')]
log = getattr(viewer_state, f'{axis}_log')
axis_dict = dict(
title=title,
titlefont=dict(
family=DEFAULT_FONT,
size=2 * axislabel_size,
color=settings.FOREGROUND_COLOR
title=dict(
text=title,
font=dict(
family=DEFAULT_FONT,
size=2 * axislabel_size,
color=settings.FOREGROUND_COLOR
)
),
showspikes=False,
linecolor=settings.FOREGROUND_COLOR,
Expand Down
24 changes: 14 additions & 10 deletions glue_plotly/common/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,25 @@ def axes_data_from_mpl(viewer):

if axis == 'b':
axis_info.update(
title=viewer.axes.get_xlabel(),
titlefont=dict(
family=DEFAULT_FONT,
size=2 * axes.xaxis.get_label().get_size(),
color=settings.FOREGROUND_COLOR
title=dict(
text=viewer.axes.get_xlabel(),
font=dict(
family=DEFAULT_FONT,
size=2 * axes.xaxis.get_label().get_size(),
color=settings.FOREGROUND_COLOR
)
)
)
axes_data['xaxis'] = axis_info
elif axis == 'l':
axis_info.update(
title=viewer.axes.get_ylabel(),
titlefont=dict(
family=DEFAULT_FONT,
size=2 * axes.yaxis.get_label().get_size(),
color=settings.FOREGROUND_COLOR
title=dict(
text=viewer.axes.get_ylabel(),
font=dict(
family=DEFAULT_FONT,
size=2 * axes.yaxis.get_label().get_size(),
color=settings.FOREGROUND_COLOR
)
)
)
axes_data['yaxis'] = axis_info
Expand Down
8 changes: 4 additions & 4 deletions glue_plotly/common/tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def test_axes(self, log_x, log_y):
assert common_items.items() <= x_axis.items()
assert common_items.items() <= y_axis.items()

assert x_axis['title'] == 'X Axis'
assert y_axis['title'] == 'Y Axis'
assert x_axis['title']['text'] == 'X Axis'
assert y_axis['title']['text'] == 'Y Axis'
assert x_axis['type'] == 'log' if log_x else 'linear'
assert y_axis['type'] == 'log' if log_y else 'linear'

Expand All @@ -82,8 +82,8 @@ def test_axes(self, log_x, log_y):
assert y_axis['range'] == expected_y_range

base_font_dict = dict(family=DEFAULT_FONT, color=settings.FOREGROUND_COLOR)
assert x_axis['titlefont'] == dict(**base_font_dict, size=28)
assert y_axis['titlefont'] == dict(**base_font_dict, size=16)
assert x_axis['title']['font'] == dict(**base_font_dict, size=28)
assert y_axis['title']['font'] == dict(**base_font_dict, size=16)
assert x_axis['tickfont'] == dict(**base_font_dict, size=27)
assert y_axis['tickfont'] == dict(**base_font_dict, size=30)

Expand Down
8 changes: 4 additions & 4 deletions glue_plotly/common/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test_axes(self, log_x, log_y):
assert common_items.items() <= x_axis.items()
assert common_items.items() <= y_axis.items()

assert x_axis['title'] == 'X Axis'
assert y_axis['title'] == 'Y Axis'
assert x_axis['title']['text'] == 'X Axis'
assert y_axis['title']['text'] == 'Y Axis'
assert x_axis['type'] == 'log' if log_x else 'linear'
assert y_axis['type'] == 'log' if log_y else 'linear'

Expand All @@ -86,8 +86,8 @@ def test_axes(self, log_x, log_y):
assert y_axis['range'] == expected_y_range

base_font_dict = dict(family=DEFAULT_FONT, color=settings.FOREGROUND_COLOR)
assert x_axis['titlefont'] == dict(**base_font_dict, size=30)
assert y_axis['titlefont'] == dict(**base_font_dict, size=20)
assert x_axis['title']['font'] == dict(**base_font_dict, size=30)
assert y_axis['title']['font'] == dict(**base_font_dict, size=20)
assert x_axis['tickfont'] == dict(**base_font_dict, size=9)
assert y_axis['tickfont'] == dict(**base_font_dict, size=18)

Expand Down
8 changes: 4 additions & 4 deletions glue_plotly/common/tests/test_scatter2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def test_axes(self, log_x, log_y):
assert common_items.items() <= x_axis.items()
assert common_items.items() <= y_axis.items()

assert x_axis['title'] == 'X Axis'
assert y_axis['title'] == 'Y Axis'
assert x_axis['title']['text'] == 'X Axis'
assert y_axis['title']['text'] == 'Y Axis'
assert x_axis['type'] == 'log' if log_x else 'linear'
assert y_axis['type'] == 'log' if log_y else 'linear'

Expand All @@ -105,8 +105,8 @@ def test_axes(self, log_x, log_y):
assert y_axis['range'] == expected_y_range

base_font_dict = dict(family=DEFAULT_FONT, color=settings.FOREGROUND_COLOR)
assert x_axis['titlefont'] == dict(**base_font_dict, size=24)
assert y_axis['titlefont'] == dict(**base_font_dict, size=16)
assert x_axis['title']['font'] == dict(**base_font_dict, size=24)
assert y_axis['title']['font'] == dict(**base_font_dict, size=16)
assert x_axis['tickfont'] == dict(**base_font_dict, size=9)
assert y_axis['tickfont'] == dict(**base_font_dict, size=18)

Expand Down
93 changes: 78 additions & 15 deletions glue_plotly/web/qt/tests/test_plotly.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import absolute_import, division, print_function
from glue_qt.app.application import get_icon

import pytest
import numpy as np

from glue.config import settings
from glue.core import Data, DataCollection

from glue_plotly.common.common import DEFAULT_FONT

pytest.importorskip('qtpy')

from glue_qt.app import GlueApplication # noqa: E402
Expand All @@ -16,8 +18,6 @@
from ...export_plotly import build_plotly_call # noqa: E402
from ....common.tests.utils import SimpleCoordinates # noqa: E402

get_icon


class TestPlotly(object):

Expand Down Expand Up @@ -98,12 +98,35 @@ def test_axes(self):
viewer.state.y_max = 4
viewer.state.y_att = self.data.id['y']

viewer.state.x_axislabel_size = 10
viewer.state.y_axislabel_size = 15

args, kwargs = build_plotly_call(self.app)

xaxis = dict(type='log', rangemode='normal',
range=[1, 2], title=viewer.state.x_axislabel, zeroline=False)
yaxis = dict(type='linear', rangemode='normal',
range=[2, 4], title=viewer.state.y_axislabel, zeroline=False)
xaxis = dict(type='log',
rangemode='normal',
range=[1, 2],
title=dict(
text=viewer.state.x_axislabel,
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
yaxis = dict(type='linear',
rangemode='normal',
range=[2, 4],
title=dict(
text=viewer.state.y_axislabel,
font=dict(
family=DEFAULT_FONT,
size=30,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
layout = args[0]['layout']
for k, v in layout['xaxis'].items():
assert xaxis.get(k, v) == v
Expand Down Expand Up @@ -186,10 +209,30 @@ def test_scatter_categorical(self):

args, kwargs = build_plotly_call(self.app)

xaxis = dict(type='linear', rangemode='normal',
range=[0.92, 3.08], title='x', zeroline=False)
yaxis = dict(type='linear', rangemode='normal',
range=[-0.62, 2.62], title='z', zeroline=False)
xaxis = dict(type='linear',
rangemode='normal',
range=[0.92, 3.08],
title=dict(
text='x',
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
yaxis = dict(type='linear',
rangemode='normal',
range=[-0.62, 2.62],
title=dict(
text='z',
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
layout = args[0]['layout']
for k, v in layout['xaxis'].items():
assert xaxis.get(k, v) == v
Expand All @@ -206,10 +249,30 @@ def test_histogram_categorical(self):

args, kwargs = build_plotly_call(self.app)

xaxis = dict(type='linear', rangemode='normal',
range=[-0.5, 2.5], title=viewer.state.x_axislabel, zeroline=False)
yaxis = dict(type='linear', rangemode='normal',
range=[0, 1.2], title=viewer.state.y_axislabel, zeroline=False)
xaxis = dict(type='linear',
rangemode='normal',
range=[-0.5, 2.5],
title=dict(
text=viewer.state.x_axislabel,
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
yaxis = dict(type='linear',
rangemode='normal',
range=[0, 1.2],
title=dict(
text=viewer.state.y_axislabel,
font=dict(
family=DEFAULT_FONT,
size=20,
color=settings.FOREGROUND_COLOR
)
),
zeroline=False)
layout = args[0]['layout']
for k, v in layout['xaxis'].items():
assert xaxis.get(k, v) == v
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ deps =
devdeps: git+https://github.com/glue-viz/glue-jupyter
devdeps: git+https://github.com/glue-viz/glue-vispy-viewers
devdeps: git+https://github.com/plotly/plotly.py/\#subdirectory=packages/python/plotly
devdeps: anywidget # Should be temporary

[testenv:codestyle]
deps = flake8
Expand Down
Loading