Skip to content

Commit f6cb5ff

Browse files
Junpeng LaoColCarroll
authored andcommitted
fix typo (#2883)
`lenght` --> `length`
1 parent be532de commit f6cb5ff

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

pymc3/backends/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def add_values(self, vals):
370370
vals : dict (str: array-like)
371371
The keys should be the names of the new variables. The values are
372372
expected to be array-like object.
373-
For traces with more than one chain the lenght of each value
373+
For traces with more than one chain the length of each value
374374
should match the number of total samples already in the trace
375375
(chains * iterations), otherwise a warning is raised.
376376
"""
@@ -384,7 +384,7 @@ def add_values(self, vals):
384384
l_samples = len(self) * len(self.chains)
385385
l_v = len(v)
386386
if l_v != l_samples:
387-
warnings.warn("The lenght of the values you are trying to "
387+
warnings.warn("The length of the values you are trying to "
388388
"add ({}) does not match the number ({}) of "
389389
"total samples in the trace "
390390
"(chains * iterations)".format(l_v, l_samples))

pymc3/plots/densityplot.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,23 @@ def densityplot(trace, models=None, varnames=None, alpha=0.05, point_estimate='m
7070
if not isinstance(trace, (list, tuple)):
7171
trace = [trace]
7272

73-
lenght_trace = len(trace)
73+
length_trace = len(trace)
7474

7575
if models is None:
76-
if lenght_trace > 1:
77-
models = ['m_{}'.format(i) for i in range(lenght_trace)]
76+
if length_trace > 1:
77+
models = ['m_{}'.format(i) for i in range(length_trace)]
7878
else:
7979
models = ['']
80-
elif len(models) != lenght_trace:
80+
elif len(models) != length_trace:
8181
raise ValueError(
8282
"The number of names for the models does not match the number of models")
8383

84-
lenght_models = len(models)
84+
length_models = len(models)
8585

8686
if colors == 'cycle':
87-
colors = ['C{}'.format(i % 10) for i in range(lenght_models)]
87+
colors = ['C{}'.format(i % 10) for i in range(length_models)]
8888
elif isinstance(colors, str):
89-
colors = [colors for i in range(lenght_models)]
89+
colors = [colors for i in range(length_models)]
9090

9191
if varnames is None:
9292
varnames = []
@@ -117,7 +117,7 @@ def densityplot(trace, models=None, varnames=None, alpha=0.05, point_estimate='m
117117
_d_helper(vec, vname, colors[t_idx], bw, alpha, point_estimate,
118118
hpd_markers, outline, shade, dplot[v_idx])
119119

120-
if lenght_trace > 1:
120+
if length_trace > 1:
121121
for m_idx, m in enumerate(models):
122122
dplot[0].plot([], label=m, c=colors[m_idx])
123123
dplot[0].legend(fontsize=textsize)

pymc3/sampling.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,8 @@ def sample_ppc_w(traces, samples=None, models=None, weights=None,
11261126
if len(models) != len(weights):
11271127
raise ValueError('The number of models and weights should be the same')
11281128

1129-
lenght_morv = len(models[0].observed_RVs)
1130-
if not all(len(i.observed_RVs) == lenght_morv for i in models):
1129+
length_morv = len(models[0].observed_RVs)
1130+
if not all(len(i.observed_RVs) == length_morv for i in models):
11311131
raise ValueError(
11321132
'The number of observed RVs should be the same for all models')
11331133

@@ -1161,17 +1161,16 @@ def sample_ppc_w(traces, samples=None, models=None, weights=None,
11611161
obs = [x for m in models for x in m.observed_RVs]
11621162
variables = np.repeat(obs, n)
11631163

1164-
lengths = [np.atleast_1d(observed).shape for observed in obs]
1165-
lenghts = list(set(lengths))
1164+
lengths = list(set([np.atleast_1d(observed).shape for observed in obs]))
11661165

1167-
if len(lenghts) == 1:
1166+
if len(lengths) == 1:
11681167
size = [None for i in variables]
1169-
elif len(lenghts) > 2:
1168+
elif len(lengths) > 2:
11701169
raise ValueError('Observed variables could not be broadcast together')
11711170
else:
11721171
size = []
1173-
x = np.zeros(shape=lenghts[0])
1174-
y = np.zeros(shape=lenghts[1])
1172+
x = np.zeros(shape=lengths[0])
1173+
y = np.zeros(shape=lengths[1])
11751174
b = np.broadcast(x, y)
11761175
for var in variables:
11771176
shape = np.shape(np.atleast_1d(var.distribution.default()))

0 commit comments

Comments
 (0)