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

Add flake8 checking on travis #2340

Merged
merged 4 commits into from
Feb 14, 2018
Merged
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION scipy=1.0.0 numpy freetype nose pandas=0.22.0 jupyter ipython=4.2.0 param matplotlib=2.1.2 xarray
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION flake8 scipy=1.0.0 numpy freetype nose pandas=0.22.0 jupyter ipython=4.2.0 param matplotlib=2.1.2 xarray
- source activate test-environment
- conda install -c conda-forge iris plotly flexx --quiet
- conda install -c bokeh datashader dask=0.16.1 bokeh=0.12.14 selenium
Expand Down Expand Up @@ -68,6 +68,7 @@ before-script:
script:
- export HOLOVIEWSRC=`pwd`'/holoviews.rc'
- echo 'import holoviews as hv;hv.config(style_17=True);hv.config.warn_options_call=True' > holoviews.rc
- flake8 --ignore=E,W,F999,F405 holoviews tests
- nosetests --with-doctest --with-coverage --cover-package=holoviews -v
- cd doc/nbpublisher; chmod +x test_notebooks.py; QT_QPA_PLATFORM='offscreen' BOKEH_DEV=True ./test_notebooks.py
- chmod +x concat_html.py; ./concat_html.py ../test_data ../test_html
Expand Down
1 change: 0 additions & 1 deletion holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ def sort(cls, dataset, by=[], reverse=False):
@classmethod
def select(cls, dataset, selection_mask=None, **selection):
validated = {}
irregular = False
for k, v in selection.items():
dim = dataset.get_dimension(k, strict=True)
if cls.irregular(dataset, dim):
Expand Down
4 changes: 2 additions & 2 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def run(self):
self.counter += 1
try:
self.callback(self.counter)
except Exception as e:
except Exception:
self.stop()

if self.timeout is not None:
Expand Down Expand Up @@ -219,7 +219,7 @@ def deephash(obj):
basestring = basestring
unicode = unicode
from itertools import izip
generator_types = (izip, xrange, types.GeneratorType)
generator_types = (izip, xrange, types.GeneratorType) # noqa



Expand Down
4 changes: 2 additions & 2 deletions holoviews/element/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ def from_networkx(cls, G, layout_function, nodes=None, **kwargs):
edges = [(src, tgt) for (src, tgt) in edges if src in indices and tgt in indices]
nodes = nodes.select(**{idx_dim: [eid for e in edges for eid in e]}).sort()
nodes = nodes.add_dimension('x', 0, xs)
nodes = nodes.add_dimension('y', 1, ys).clone(new_type=self.node_type)
nodes = nodes.add_dimension('y', 1, ys).clone(new_type=cls.node_type)
else:
nodes = self.node_type([tuple(pos)+(idx,) for idx, pos in sorted(positions.items())])
nodes = cls.node_type([tuple(pos)+(idx,) for idx, pos in sorted(positions.items())])
return cls((edges, nodes))


Expand Down
1 change: 0 additions & 1 deletion holoviews/element/raster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from operator import itemgetter

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion holoviews/element/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def connect_edges_pd(graph):
df = df.sort_values('graph_edge_index').drop(['graph_edge_index'], axis=1)

edge_segments = []
N = len(nodes)
for i, edge in df.iterrows():
start = edge['src_x'], edge['src_y']
end = edge['dst_x'], edge['dst_y']
Expand Down
4 changes: 1 addition & 3 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import, division

from collections import Callable, Iterable
from functools import partial
from distutils.version import LooseVersion
import warnings

Expand All @@ -27,8 +26,7 @@
from ..core.data import PandasInterface, XArrayInterface
from ..core.sheetcoords import BoundingBox
from ..core.util import get_param_values, basestring, datetime_types, dt_to_int
from ..element import (Image, Path, Curve, RGB, Graph, TriMesh, Points,
Scatter, Dataset, QuadMesh)
from ..element import (Image, Path, Curve, RGB, Graph, TriMesh, QuadMesh)
from ..streams import RangeXY, PlotSize


Expand Down
6 changes: 1 addition & 5 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from collections import defaultdict

import param
import numpy as np
from bokeh.models import (CustomJS, FactorRange, DatetimeAxis, ColumnDataSource)

from ...core import OrderedDict
Expand All @@ -12,7 +11,6 @@
PointDraw, PolyDraw, PolyEdit, CDSStream)
from ...streams import PositionX, PositionY, PositionXY, Bounds # Deprecated: remove in 2.0
from ..comms import JupyterCommJS, Comm
from .path import PolygonPlot
from .util import convert_timestamp


Expand Down Expand Up @@ -880,7 +878,7 @@ class PointDrawCallback(CDSCallback):
def initialize(self):
try:
from bokeh.models import PointDrawTool
except Exception as e:
except Exception:
param.main.warning('PointDraw requires bokeh >= 0.12.14')
return
renderers = [self.plot.handles['glyph_renderer']]
Expand All @@ -900,7 +898,6 @@ def initialize(self):
param.main.warning('PolyDraw requires bokeh >= 0.12.14')
return
plot = self.plot
source = plot.handles['source']
poly_tool = PolyDrawTool(drag=all(s.drag for s in self.streams),
empty_value=self.streams[0].empty_value,
renderers=[plot.handles['glyph_renderer']])
Expand Down Expand Up @@ -956,7 +953,6 @@ def initialize(self):

def _process_msg(self, msg):
data = super(BoxEditCallback, self)._process_msg(msg)['data']
element = self.plot.current_frame
x0s, x1s, y0s, y1s = [], [], [], []
for x, y, w, h in zip(data['x'], data['y'], data['width'], data['height']):
x0s.append(x-w/2.)
Expand Down
11 changes: 4 additions & 7 deletions holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
import numpy as np
import param
from bokeh.models import (CategoricalColorMapper, CustomJS, HoverTool,
FactorRange, Whisker, Band, Range1d, Circle,
VBar, HBar)
Whisker, Range1d)
from bokeh.models.tools import BoxSelectTool
from bokeh.transform import jitter

from ...core import Dataset, OrderedDict
from ...core.dimension import Dimension
from ...core.util import (max_range, basestring, dimension_sanitizer,
wrap_tuple, unique_iterator)
from ...core.util import max_range, basestring, dimension_sanitizer
from ...element import Bars
from ...operation import interpolate_curve
from ..util import compute_sizes, get_min_distance, dim_axis_label
from .element import (ElementPlot, ColorbarPlot, LegendPlot, CompositeElementPlot,
line_properties, fill_properties)
from .element import (ElementPlot, ColorbarPlot, LegendPlot, line_properties,
fill_properties)
from .util import expand_batched_style, categorize_array, rgb2hex, mpl_to_bokeh


Expand Down
3 changes: 1 addition & 2 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from itertools import groupby
import warnings

import param
Expand All @@ -21,7 +20,7 @@
from ...core import DynamicMap, CompositeOverlay, Element, Dimension
from ...core.options import abbreviated_exception, SkipRendering
from ...core import util
from ...streams import Stream, Buffer
from ...streams import Buffer
from ..plot import GenericElementPlot, GenericOverlayPlot
from ..util import dynamic_update, process_cmap
from .plot import BokehPlot, TOOLS
Expand Down
6 changes: 2 additions & 4 deletions holoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
from bokeh.models import (ColumnDataSource, Column, Row, Div)
from bokeh.models.widgets import Panel, Tabs

from ...core import (OrderedDict, Store, GridMatrix, AdjointLayout,
NdLayout, Empty, GridSpace, HoloMap, Element,
DynamicMap)
from ...core import (OrderedDict, Store, AdjointLayout, NdLayout,
Empty, GridSpace, HoloMap, Element, DynamicMap)
from ...core.util import basestring, wrap_tuple, unique_iterator
from ...element import Histogram
from ...streams import Stream
from ..plot import (DimensionedPlot, GenericCompositePlot, GenericLayoutPlot,
GenericElementPlot, GenericOverlayPlot)
Expand Down
1 change: 0 additions & 1 deletion holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from bokeh.models import HoverTool
from ...core.util import cartesian_product, is_nan, dimension_sanitizer
from ...element import Raster
from ..renderer import SkipRendering
from .element import ElementPlot, ColorbarPlot, line_properties, fill_properties
from .util import mpl_to_bokeh, colormesh

Expand Down
1 change: 0 additions & 1 deletion holoviews/plotting/bokeh/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import bokeh.core
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
from bokeh.document import Document
from bokeh.io import curdoc, show as bkshow
from bokeh.models import Model
from bokeh.resources import CDN, INLINE
Expand Down
24 changes: 9 additions & 15 deletions holoviews/plotting/bokeh/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
import param
import numpy as np

from bokeh.models import (DataRange1d, FactorRange, HoverTool,
Circle, VBar, HBar)
from bokeh.models import FactorRange, HoverTool, Circle, VBar, HBar

from ...core.dimension import Dimension
from ...core.util import basestring, dimension_sanitizer, wrap_tuple
from ...core.util import (basestring, dimension_sanitizer, wrap_tuple,
unique_iterator)
from ...operation.stats import univariate_kde
from .chart import AreaPlot
from .element import (CompositeElementPlot, ColorbarPlot, LegendPlot,
fill_properties, line_properties)
from .path import PolygonPlot
from .util import rgb2hex


class DistributionPlot(AreaPlot):
Expand Down Expand Up @@ -167,12 +168,13 @@ def get_data(self, element, ranges, style):
# Compute statistics
vals = g.dimension_values(g.vdims[0])
if len(vals):
qmin, q1, q2, q3, qmax = (np.percentile(vals, q=q) for q in range(0,125,25))
q1, q2, q3 = (np.percentile(vals, q=q)
for q in range(25, 100, 25))
iqr = q3 - q1
upper = min(q3 + 1.5*iqr, vals.max())
lower = max(q1 - 1.5*iqr, vals.min())
else:
qmin, q1, q2, q3, qmax = 0, 0, 0, 0, 0
q1, q2, q3 = 0, 0, 0
lower, upper = 0, 0
outliers = vals[(vals>upper) | (vals<lower)]
# Add to CDS data
Expand Down Expand Up @@ -337,8 +339,8 @@ def _kde_data(self, el, key, **kwargs):
segments['y1'].append(sy)
elif self.inner == 'box':
xpos = key+(0,)
qmin, q1, q2, q3, qmax = (np.percentile(values, q=q)
for q in range(0,125,25))
q1, q2, q3 = (np.percentile(values, q=q)
for q in range(25, 100, 25))
iqr = q3 - q1
upper = min(q3 + 1.5*iqr, np.nanmax(values))
lower = max(q1 - 1.5*iqr, np.nanmin(values))
Expand Down Expand Up @@ -381,17 +383,9 @@ def get_data(self, element, ranges, style):
scatter_map = {'x': 'x', 'y': 'y'}
bar_glyph = 'vbar'

# Get color values
if self.color_index is not None:
cdim = element.get_dimension(self.color_index)
cidx = element.get_dimension_index(self.color_index)
else:
cdim, cidx = None, None

elstyle = self.lookup_options(element, 'style')
kwargs = {'bandwidth': self.bandwidth, 'cut': self.cut}

factors = []
data, mapping = {}, {}
seg_data, bar_data, scatter_data = (defaultdict(list) for i in range(3))
for i, (key, g) in enumerate(groups.items()):
Expand Down
11 changes: 1 addition & 10 deletions tests/plotting/bokeh/testcallbacks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from unittest import SkipTest

from holoviews.core.spaces import DynamicMap
from holoviews.core.options import Store
from holoviews.element import Points, Polygons, Path, Box
from holoviews.element import Points, Polygons, Box
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import PointDraw, PolyDraw, PolyEdit, BoxEdit

Expand Down Expand Up @@ -47,7 +46,6 @@ def test_point_draw_callback_initialize(self):
point_draw = PointDraw(source=points)
plot = bokeh_renderer.get_plot(points)
self.assertIsInstance(plot.callbacks[0], PointDrawCallback)
data = {'x': [0], 'y': [1]}
self.assertEqual(point_draw.element, points)

def test_point_draw_callback_with_vdims(self):
Expand Down Expand Up @@ -83,13 +81,6 @@ def test_poly_draw_callback_with_vdims(self):
{'x': [3, 4, 5], 'y': [3, 4, 5], 'A': 2}], vdims=['A'])
self.assertEqual(poly_draw.element, element)

def test_box_edit_callback(self):
boxes = Polygons([Box(0, 0, 1)])
box_edit = BoxEdit(source=boxes)
plot = bokeh_renderer.get_plot(boxes)
self.assertIsInstance(plot.callbacks[0], BoxEditCallback)
self.assertEqual(box_edit.element, boxes)

def test_box_edit_callback(self):
boxes = Polygons([Box(0, 0, 1)])
box_edit = BoxEdit(source=boxes)
Expand Down
3 changes: 0 additions & 3 deletions tests/plotting/bokeh/testplot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from unittest import SkipTest

import param
import numpy as np

from holoviews.core.element import Element
from holoviews.core.options import Store
Expand All @@ -13,7 +11,6 @@
ColumnDataSource, LinearColorMapper, LogColorMapper, HoverTool
)
from holoviews.plotting.bokeh.callbacks import Callback
from holoviews.plotting.bokeh.util import bokeh_version
bokeh_renderer = Store.renderers['bokeh']
except:
bokeh_renderer = None
Expand Down
4 changes: 3 additions & 1 deletion tests/plotting/bokeh/testserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from holoviews.core.spaces import DynamicMap
from holoviews.core.options import Store
from holoviews.element import Curve, Polygons, Path, Image, HLine
from holoviews.element import Curve, Polygons, Path, HLine
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import RangeXY, PlotReset

Expand Down Expand Up @@ -53,6 +53,7 @@ def test_set_up_linked_change_stream_on_server_doc(self):
obj = Curve([])
stream = RangeXY(source=obj)
server_doc = bokeh_renderer.server_doc(obj)
self.assertIsInstance(server_doc, Document)
self.assertEqual(len(bokeh_renderer.last_plot.callbacks), 1)
cb = bokeh_renderer.last_plot.callbacks[0]
self.assertIsInstance(cb, RangeXYCallback)
Expand All @@ -68,6 +69,7 @@ def test_set_up_linked_event_stream_on_server_doc(self):
obj = Curve([])
stream = PlotReset(source=obj)
server_doc = bokeh_renderer.server_doc(obj)
self.assertIsInstance(server_doc, Document)
cb = bokeh_renderer.last_plot.callbacks[0]
self.assertIsInstance(cb, ResetCallback)
self.assertEqual(cb.streams, [stream])
Expand Down
3 changes: 1 addition & 2 deletions tests/plotting/bokeh/testtabular.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from datetime import datetime as dt
from unittest import SkipTest

from holoviews.core.spaces import DynamicMap
from holoviews.core.options import Store
from holoviews.element import Table
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import CDSStream

try:
from bokeh.models.widgets import (
DataTable, TableColumn, NumberEditor, NumberFormatter, DateFormatter,
NumberEditor, NumberFormatter, DateFormatter,
DateEditor, StringFormatter, StringEditor, IntEditor
)
from holoviews.plotting.bokeh.callbacks import CDSCallback
Expand Down
6 changes: 1 addition & 5 deletions tests/plotting/matplotlib/testplot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from unittest import SkipTest

import param
import numpy as np

from holoviews.core.element import Element
from holoviews.core.options import Store
from holoviews.element.comparison import ComparisonTestCase
from holoviews.plotting import comms

try:
import holoviews.plotting.mpl
import holoviews.plotting.mpl # noqa
mpl_renderer = Store.renderers['matplotlib']
except:
mpl_renderer = None
Expand Down
1 change: 0 additions & 1 deletion tests/plotting/matplotlib/testviolinplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np

from holoviews.element import Violin
from holoviews.operation.stats import univariate_kde

from .testplot import TestMPLPlot, mpl_renderer

Expand Down
Loading