Skip to content
This repository
Browse code

improved known_bugs_and_pitfalls file

  • Loading branch information...
commit 5081a593781edb2b580265dd5ca8c678b077c943 1 parent 313bec4
Sebastian F. Walter authored

Showing 1 changed file with 29 additions and 0 deletions. Show diff stats Hide diff stats

  1. +29 0 KNOWN_BUGS_AND_PITFALLS.rst
29 KNOWN_BUGS_AND_PITFALLS.rst
Source Rendered
@@ -10,6 +10,31 @@ Pitfalls
10 10
11 11 One has to be caerful with the operations `+=` , `*=`, ... of numpy arrays.
12 12 The problem is best explained at an example::
  13 +
  14 + In [1]: import numpy
  15 +
  16 + In [2]: import adolc
  17 +
  18 + In [3]: x = adolc.adouble(numpy.array([1,2,3],dtype=float))
  19 +
  20 + In [4]: y = numpy.array([4,5,6],dtype=float)
  21 +
  22 + In [5]: x
  23 + Out[5]: array([1(a), 2(a), 3(a)], dtype=object)
  24 +
  25 + In [6]: y
  26 + Out[6]: array([ 4., 5., 6.])
  27 +
  28 + In [7]: x * y
  29 + Out[7]: array([4(a), 10(a), 18(a)], dtype=object)
  30 +
  31 + In [8]: y *= x
  32 +
  33 + In [9]: y
  34 +
  35 + Out[9]: array([ 4., 5., 6.])
  36 +
  37 + This is not a bug of PYADOLC but the way `*=` is implemented in numpy. One can see similar behaviour for the dtype int and float::
13 38
14 39 In [1]: import numpy
15 40
@@ -31,6 +56,10 @@ Pitfalls
31 56 Out[8]: dtype('int32')
32 57
33 58 that means that the inplace operation `x *= y ` is *not* the same as `x = x * y`.
  59 + This also means that::
  60 +
  61 + x = adouble(numpy.array([1,2,3],dtype=float))
  62 +
34 63 It is inconsistent to the Python behaviour and therefore a little surprising::
35 64
36 65 In [9]: a = 1

0 comments on commit 5081a59

Please sign in to comment.
Something went wrong with that request. Please try again.