Skip to content

Commit

Permalink
throw TypeError when bad data is passed in to add_scalar rather than …
Browse files Browse the repository at this point in the history
…NameError due to absence of caffe2 workspace (#591)
  • Loading branch information
mgoldey committed Jun 28, 2020
1 parent 15f4537 commit eb7e8d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorboardX/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ def add_scalar(self, tag, scalar_value, global_step=None, walltime=None,
"""
if self._check_caffe2_blob(scalar_value):
scalar_value = workspace.FetchBlob(scalar_value)
if 'workspace' in globals():
scalar_value = workspace.FetchBlob(scalar_value)
else:
raise TypeError("Input value: \"{}\" is not a scalar".format(scalar_value))
self._get_file_writer().add_summary(
scalar(tag, scalar_value, display_name, summary_description), global_step, walltime)

Expand Down

0 comments on commit eb7e8d2

Please sign in to comment.