Skip to content

Commit

Permalink
Adjfloat block variables to print saved values.
Browse files Browse the repository at this point in the history
  • Loading branch information
dham committed Jan 5, 2024
1 parent f194553 commit 829c49c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pyadjoint/adjfloat.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def _ad_to_list(value):
def _ad_copy(self):
return self

@property
def _ad_str(self):
"""Return the string of the taped value of this variable."""
return str(self.block_variable.saved_output)

_min = min
_max = max
Expand Down
2 changes: 1 addition & 1 deletion pyadjoint/block_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def will_add_as_output(self):
self.save_output(overwrite=overwrite)

def __str__(self):
return str(self.output)
return str(self.output._ad_str)

@property
def checkpoint(self):
Expand Down
12 changes: 12 additions & 0 deletions pyadjoint/overloaded_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ def _ad_dim(self):
"""
raise NotImplementedError

def _ad_str(self):
"""Return the string representation of the block variable.
For simple scalar types this might be the string representation of the
stored value. For more complex objects it is likely to be based on a
name attached to this instance.
Returns:
str: A human readable serialisation of this variable.
"""
return str(self)


class FloatingType(OverloadedType):
def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 829c49c

Please sign in to comment.