dolfin-adjoint / pyadjoint

The algorithmic differentation tool pyadjoint and add-ons.
GNU Lesser General Public License v3.0
91 stars 37 forks source link

ReducedFunctional.derivative_cb_pre and ReducedFunctional.derivative_cb_post are overwritten if derivative_components is passed #168

Open miguelcoolchips opened 2 months ago

miguelcoolchips commented 2 months ago

I was looking at this part of the code in ReducedFunctional

https://github.com/dolfin-adjoint/pyadjoint/blob/master/pyadjoint/reduced_functional.py#L91-L97

and I saw that if the user passes a derivative_cb_post and a derivative_components to the constructor, the former gets overwritten. Is this the intended behavior?

dham commented 2 months ago

I think @colinjcotter may have been slightly careless when he wrote that. I would have thought that any callback functions passed in to the constructor should be composed with the functions added on those lines.