Skip to content

Commit 3a891bb

Browse files
committed
Minor bugfix
1 parent 38bcc05 commit 3a891bb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

02-testing-assertions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ <h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></spa
114114
AssertionError:</code></pre>
115115
<p>Since this an issue that one has to deal with all the time in testing numerical code, <code>numpy</code> provides a few helpful functions in the <code>numpy.testing.utils</code> package that check for equality up to a certain precision:</p>
116116
<pre class="sourceCode python"><code class="sourceCode python">values = numpy.array([<span class="fl">0.3</span>, <span class="dv">3</span>*<span class="fl">0.1</span>, <span class="fl">0.1+0.1+0.1</span>, <span class="fl">0.6</span>/<span class="dv">2</span>])
117-
<span class="dt">print</span>(values == <span class="fl">0.1</span>)</code></pre>
117+
<span class="dt">print</span>(values == <span class="fl">0.3</span>)</code></pre>
118118
<pre class="output"><code>[ True False False True]</code></pre>
119119
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">from</span> numpy.testing.utils <span class="ch">import</span> assert_allclose
120-
assert_allclose(values, <span class="fl">0.1</span>, rtol=<span class="fl">1e-12</span>)
120+
assert_allclose(values, <span class="fl">0.3</span>, rtol=<span class="fl">1e-12</span>)
121121
<span class="dt">print</span>(<span class="st">&#39;no assertion raised&#39;</span>)</code></pre>
122122
<pre class="output"><code>no assertion raised</code></pre>
123123
<p>There are more helpful <code>assert_…</code> functions in that package, we’ll use them later in the lesson.</p>

02-testing-assertions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ Since this an issue that one has to deal with all the time in testing numerical
135135

136136
~~~ {.python}
137137
values = numpy.array([0.3, 3*0.1, 0.1+0.1+0.1, 0.6/2])
138-
print(values == 0.1)
138+
print(values == 0.3)
139139
~~~
140140
~~~ {.output}
141141
[ True False False True]
142142
~~~
143143
~~~ {.python}
144144
from numpy.testing.utils import assert_allclose
145-
assert_allclose(values, 0.1, rtol=1e-12)
145+
assert_allclose(values, 0.3, rtol=1e-12)
146146
print('no assertion raised')
147147
~~~
148148
~~~ {.output}

0 commit comments

Comments
 (0)