Skip to content

Commit

Permalink
Update warning message per review request
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis committed Jul 3, 2024
1 parent 905e131 commit 2dc0cd8
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions desc/io/hdf5_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import h5py
import numpy as np
from termcolor import colored

from .core_io import IO, Reader, Writer

Expand Down Expand Up @@ -124,23 +125,24 @@ def read_obj(self, obj, where=None):
for attr in obj._io_attrs_:
if attr not in loc.keys():
warnings.warn(
f"Save attribute '{attr}' was not loaded from the input file.\n"
"This is likely because the file from which you are loading the "
f"Python object '{obj.__class__.__name__}' was created "
f"prior to the time '{attr}' "
f"became an attribute of objects of the class '{obj.__class__}'.\n"
"\n"
"Note to developers: Add 'def _set_up(self)' as a method to class "
f"{obj.__class__}\n"
"(or the superclass where this new attribute is assigned) that "
f"assigns some default value to '{attr}' for old objects.\n"
"This method will be called automatically when a file is loaded.\n"
"\n"
"This warning will continue to be raised until the file is saved "
"with an updated object, even if the _set_up method assigns "
"the missing attribute correctly.\n"
"Our testing suite will fail on warnings, so developers may want "
"to comment out this warning until the input files are updated.\n",
colored(
"\n"
f"The object attribute '{attr}' was not loaded from the input "
"file.\nThis is likely because the input file containing "
f"'{obj.__class__.__name__}' was created before '{attr}' "
f"became an attribute of objects of class '{obj.__class__}'.\n"
"The user may verify that a default value has been set.\n"
"This warning will persist until the input file is saved with "
"the new object.\n"
"\n"
"Note to developers: Add 'def _set_up(self)' as a method to "
f"class '{obj.__class__}'\n"
"(or the superclass where this new attribute is assigned) that "
f"assigns a value to '{attr}'.\n"
"This method is called automatically when a file is loaded.\n"
"Recall that the testing suite will fail on warnings.",
"blue",
),
RuntimeWarning,
)
continue
Expand Down

0 comments on commit 2dc0cd8

Please sign in to comment.