Thanks to visit codestin.com
Credit goes to github.com

Skip to content

De-randomize doc builds #5769

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

Merged
merged 7 commits into from
Jan 5, 2016
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
2 changes: 1 addition & 1 deletion doc/pyplots/whats_new_98_4_fancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def make_boxstyles(ax):
styles = mpatch.BoxStyle.get_styles()

for i, (stylename, styleclass) in enumerate(styles.items()):
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename,
ha="center",
size=fontsize,
Expand Down
5 changes: 3 additions & 2 deletions examples/api/filled_step.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
from collections import OrderedDict
from functools import partial

import numpy as np
Expand Down Expand Up @@ -174,9 +175,9 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
hatch_cycle = cycler('hatch', ['/', '*', '+', '|'])

# make some synthetic data
np.random.seed(0)
stack_data = np.random.randn(4, 12250)
dict_data = {lab: d for lab, d in zip(list(c['label'] for c in label_cycle),
stack_data)}
dict_data = OrderedDict(zip((c['label'] for c in label_cycle), stack_data))

# work with plain arrays
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True)
Expand Down
7 changes: 5 additions & 2 deletions examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
sat = [color[1] for color in hsv]
val = [color[2] for color in hsv]

# Sort by hue, saturation and value.
ind = np.lexsort((val, sat, hue))
# Get the color names by themselves.
names = [color[0] for color in colors_]

# Sort by hue, saturation, value and name.
ind = np.lexsort((names, val, sat, hue))
sorted_colors = [colors_[i] for i in ind]

n = len(sorted_colors)
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/arrow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
plt.text(x, y, label, size=label_text_size, ha='center', va='center',
color=labelcolor or fc)

for p in positions.keys():
for p in sorted(positions):
draw_arrow(p)

# test data
Expand Down
1 change: 1 addition & 0 deletions examples/pylab_examples/boxplot_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
randomDists = ['Normal(1,1)', ' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)',
'Triangular(2,9,11)']
N = 500
np.random.seed(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding a comment that the random seeding is only to make the example reproducible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many of these in the examples without any comment; add them as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many issues with the examples so I wouldn't expect to fix all of them but I would like to do this in new examples

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

norm = np.random.normal(1, 1, N)
logn = np.random.lognormal(1, 1, N)
expo = np.random.exponential(1, N)
Expand Down
12 changes: 7 additions & 5 deletions examples/pylab_examples/demo_tight_layout.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

import matplotlib.pyplot as plt
import itertools
import warnings

import random
fontsizes = [8, 16, 24, 32]

fontsizes = itertools.cycle([8, 16, 24, 32])


def example_plot(ax):
ax.plot([1, 2])
ax.set_xlabel('x-label', fontsize=random.choice(fontsizes))
ax.set_ylabel('y-label', fontsize=random.choice(fontsizes))
ax.set_title('Title', fontsize=random.choice(fontsizes))
ax.set_xlabel('x-label', fontsize=next(fontsizes))
ax.set_ylabel('y-label', fontsize=next(fontsizes))
ax.set_title('Title', fontsize=next(fontsizes))


fig, ax = plt.subplots()
example_plot(ax)
Expand Down
3 changes: 3 additions & 0 deletions examples/pylab_examples/spectrum_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import matplotlib.pyplot as plt
import numpy as np


np.random.seed(0)

dt = 0.01
Fs = 1/dt
t = np.arange(0, 10, dt)
Expand Down
20 changes: 10 additions & 10 deletions examples/pylab_examples/system_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import numpy as np


def get_memory():
def get_memory(t):
"Simulate a function that returns system memory"
return 100*(0.5 + 0.5*np.sin(0.5*np.pi*time.time()))
return 100 * (0.5 + 0.5 * np.sin(0.5 * np.pi * t))


def get_cpu():
def get_cpu(t):
"Simulate a function that returns cpu usage"
return 100*(0.5 + 0.5*np.sin(0.2*np.pi*(time.time() - 0.25)))
return 100 * (0.5 + 0.5 * np.sin(0.2 * np.pi * (t - 0.25)))


def get_net():
def get_net(t):
"Simulate a function that returns network bandwidth"
return 100*(0.5 + 0.5*np.sin(0.7*np.pi*(time.time() - 0.1)))
return 100 * (0.5 + 0.5 * np.sin(0.7 * np.pi * (t - 0.1)))


def get_stats():
return get_memory(), get_cpu(), get_net()
def get_stats(t):
return get_memory(t), get_cpu(t), get_net(t)

fig, ax = plt.subplots()
ind = np.arange(1, 4)
Expand All @@ -28,7 +28,7 @@ def get_stats():
plt.show(block=False)


pm, pc, pn = plt.bar(ind, get_stats())
pm, pc, pn = plt.bar(ind, get_stats(0))
centers = ind + 0.5*pm.get_width()
pm.set_facecolor('r')
pc.set_facecolor('g')
Expand All @@ -42,7 +42,7 @@ def get_stats():

start = time.time()
for i in range(200): # run for a little while
m, c, n = get_stats()
m, c, n = get_stats(i / 10.0)

# update the animated artists
pm.set_height(m)
Expand Down
3 changes: 3 additions & 0 deletions examples/pylab_examples/xcorr_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import matplotlib.pyplot as plt
import numpy as np


np.random.seed(0)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

x, y = np.random.randn(2, 100)
fig = plt.figure()
ax1 = fig.add_subplot(211)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ def param(func):
arg_names = []
elif len(_arg_names) > 1 and (positional_parameter_names is None):
# we got no manual parameter names but more than an 'ax' ...
if len(set(replace_names) - set(_arg_names[1:])) == 0:
if len(replace_names - set(_arg_names[1:])) == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure I understand why this is needed and if its safe if replace_names contains duplicates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace_names is already converted to a set at the beginning of the function; it's not really needed in this PR though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thats fine

# all to be replaced arguments are in the list
arg_names = _arg_names[1:]
else:
Expand Down Expand Up @@ -1838,7 +1838,7 @@ def inner(ax, *args, **kwargs):
_repl = "* All arguments with the following names: '{names}'."
if replace_all_args:
_repl += "\n* All positional arguments."
_repl = _repl.format(names="', '".join(replace_names))
_repl = _repl.format(names="', '".join(sorted(replace_names)))
inner.__doc__ = (pre_doc +
_DATA_DOC_APPENDIX.format(replaced=_repl))
if not python_has_wrapped:
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,7 @@ def aliased_name(self, s):

if s in self.aliasd:
return s + ''.join([' or %s' % x
for x
in six.iterkeys(self.aliasd[s])])
for x in sorted(self.aliasd[s])])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect performance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but there's usually only a few aliases and a whole lot more string manipulation to create the full docstrings so I'd wager not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are only called building the docs and as a failure mode in getp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and once at import time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that seems fine

else:
return s

Expand All @@ -1284,8 +1283,7 @@ def aliased_name_rest(self, s, target):

if s in self.aliasd:
aliases = ''.join([' or %s' % x
for x
in six.iterkeys(self.aliasd[s])])
for x in sorted(self.aliasd[s])])
else:
aliases = ''
return ':meth:`%s <%s>`%s' % (s, target, aliases)
Expand Down