Skip to content

Commit

Permalink
Merge pull request #148 from dolfin-adjoint/dolci/user_warning
Browse files Browse the repository at this point in the history
move logging warning to user warnings
  • Loading branch information
dham authored May 29, 2024
2 parents 908b636 + 5d845e6 commit a97e4d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyadjoint/control.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .overloaded_type import OverloadedType, create_overloaded_object
import logging
import warnings


class Control(object):
Expand Down Expand Up @@ -47,13 +47,13 @@ def tape_value(self):

def get_derivative(self, options={}):
if self.block_variable.adj_value is None:
logging.warning("Adjoint value is None, is the functional independent of the control variable?")
warnings.warn("Adjoint value is None, is the functional independent of the control variable?")
return self.control._ad_convert_type(0., options=options)
return self.control._ad_convert_type(self.block_variable.adj_value, options=options)

def get_hessian(self, options={}):
if self.block_variable.adj_value is None:
logging.warning("Hessian value is None, is the functional independent of the control variable?")
warnings.warn("Hessian value is None, is the functional independent of the control variable?")
return self.control._ad_convert_type(0., options=options)
return self.control._ad_convert_type(self.block_variable.hessian_value, options=options)

Expand Down

0 comments on commit a97e4d6

Please sign in to comment.