Skip to content

Commit

Permalink
pep8ed and flake8ed
Browse files Browse the repository at this point in the history
  • Loading branch information
doutriaux1 committed Jul 28, 2016
1 parent 7b37eb8 commit 63ba8e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Packages/vcs/vcs/Plegend.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Pls(object):
"_offset",
"arrow",
"_arrow",
]
]

def __init__(self, member):
# def __init__(self, template, member=None):
Expand Down
5 changes: 5 additions & 0 deletions Packages/vcs/vcs/VCS_validation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,24 +1750,29 @@ def arrow(self):
"""length of extension arrows"""
return self._arrow


@arrow.setter
def arrow(self, value):
self._arrow = checkNumber(self, "arrow", value, 0., None)


@property
def offset(self):
"""offset position in % of page (can be negative)"""
return self._offset


@offset.setter
def offset(self, value):
self._offset = checkNumber(self, "offset", value, -1., 1.)


@property
def x1(self):
"""x1 position in % of page"""
return self._x1


@x1.setter
def x1(self, value):
self._x1 = checkNumber(self, "x1", value, 0., 1.)
Expand Down
61 changes: 30 additions & 31 deletions Packages/vcs/vcs/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,63 +1738,63 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n',
startLength = min(self.legend.y1, self.legend.y2)
startThick = min(self.legend.x1, self.legend.x2)
# initialize the fillarea coordinates
L = [] # length
T = [] # thickness
L = [] # length
T = [] # thickness
# computes the fillarea coordinates
iext = 0 # To know if we changed the dims
if (ext_1 == 'y' or ext_2 == 'y'): # and boxLength < self.legend.arrow * length:
if (ext_1 == 'y' or ext_2 == 'y'): # and boxLength < self.legend.arrow * length:
iext = 1 # one mins changed ext_1
arrowLength = self.legend.arrow*length
arrowLength = self.legend.arrow * length
if ext_1 == 'y' and ext_2 == 'y':
boxLength = (length - 2. * arrowLength) / (nbox - 2.)
iext = 3 # changed both side
else:
boxLength = (length - arrowLength) / (nbox - 1.)
boxLength = (length - arrowLength) / (nbox - 1.)
if ext_2 == 'y':
iext = 2

# Loops thru the boxes (i.e colors NOT actual boxes drawn)
adjust=0
adjust = 0
for i in range(nbox):
if ext_1 == 'y' and i == 0:
# Draws the little arrow at the begining
# Make sure the triangle goes back to first point
# Because used to close the extension
L.append( [
L.append([
startLength + arrowLength,
startLength,
startLength,
startLength + arrowLength,
])
])
T.append(
[
startThick,
startThick,
startThick + thick / 2.,
startThick + thick,
])
startThick + thick,
])
# Now readjust startLength if necessary
if iext == 1 or iext == 3:
startLength = startLength + arrowLength
adjust = -1
elif ext_2 == 'y' and i == nbox - 1:
# Draws the little arrow at the end
L.append([
startLength + boxLength * (i+adjust),
startLength + boxLength * (i+adjust) + arrowLength,
startLength + boxLength * (i+adjust),
])
startLength + boxLength * (i + adjust),
startLength + boxLength * (i + adjust) + arrowLength,
startLength + boxLength * (i + adjust),
])
T.append(
[
startThick,
startThick + thick / 2.,
startThick + thick,
])
])
else:
# Draws a normal box
# print i,boxLength,thick,startLength,startThick
L.append([startLength + boxLength * (i+adjust),
startLength + boxLength * (i+adjust + 1),
startLength + boxLength * (i+adjust + 1),
startLength + boxLength * (i+adjust)])
L.append([startLength + boxLength * (i + adjust),
startLength + boxLength * (i + adjust + 1),
startLength + boxLength * (i + adjust + 1),
startLength + boxLength * (i + adjust)])
T.append([startThick,
startThick,
startThick + thick,
Expand All @@ -1804,7 +1804,7 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n',
fa.color = colors
fa.style = style
fa.index = index
fa.priority=self.legend.priority
fa.priority = self.legend.priority
# Boxfill default comes in here with [] we need to fix this
if opacity == []:
opacity = [None, ] * len(colors)
Expand All @@ -1823,14 +1823,13 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n',
del(vcs.elements["fillarea"][fa.name])
# Now draws the box around the legend
# First of all make sure we draw the arrows
Tl = [] # Thickness labels location
Ll = [] # Length labels location
Tt = [] # Thickness ticks location
Lt = [] # Length ticks location
St = [] # String location
Tl = [] # Thickness labels location
Ll = [] # Length labels location
Tt = [] # Thickness ticks location
Lt = [] # Length ticks location
St = [] # String location
levelsLength = length # length of the levels area
if ext_1 == 'y':
#startLength = startLength + boxLength
Tl.append(T[0])
Ll.append(L[0])
levels.pop(0)
Expand Down Expand Up @@ -1891,9 +1890,9 @@ def in_bounds(x):

boxLength = levelsLength / (len(levels) - 1.)

for il,l in enumerate(sorted(legend.keys())):
for il, l in enumerate(sorted(legend.keys())):
if in_bounds(l):
for i in range(len(levels)- 1):
for i in range(len(levels) - 1):
# if legend key is (inclusive) between levels[i] and levels[i+1]
if comparison(levels[i], l) and comparison(l, levels[i + 1]):
# first let's figure out where to put the legend label
Expand All @@ -1902,7 +1901,7 @@ def in_bounds(x):
location += (l - levels[i]) / (levels[i + 1] - levels[i]) * boxLength
location += startLength # Figures out the beginning

if not (numpy.allclose(l,levels[0]) or numpy.allclose(l,levels[-1])):
if not (numpy.allclose(l, levels[0]) or numpy.allclose(l, levels[-1])):
Ll.append([location, location])
Tl.append([startThick, startThick + thick])
Lt.append(location)
Expand Down

0 comments on commit 63ba8e8

Please sign in to comment.