MCPcopy
hub / github.com/huggingface/diffusers / test_save_load

Method test_save_load

tests/others/test_config.py:146–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

144 assert config["e"] == [1, 3]
145
146 def test_save_load(self):
147 obj = SampleObject()
148 config = obj.config
149
150 assert config["a"] == 2
151 assert config["b"] == 5
152 assert config["c"] == (2, 5)
153 assert config["d"] == "for diffusion"
154 assert config["e"] == [1, 3]
155
156 with tempfile.TemporaryDirectory() as tmpdirname:
157 obj.save_config(tmpdirname)
158 new_obj = SampleObject.from_config(SampleObject.load_config(tmpdirname))
159 new_config = new_obj.config
160
161 # unfreeze configs
162 config = dict(config)
163 new_config = dict(new_config)
164
165 assert config.pop("c") == (2, 5) # instantiated as tuple
166 assert new_config.pop("c") == [2, 5] # saved & loaded as list because of json
167 config.pop("_use_default_values")
168 assert config == new_config
169
170 def test_load_ddim_from_pndm(self):
171 logger = logging.get_logger("diffusers.configuration_utils")

Callers

nothing calls this directly

Calls 5

SampleObjectClass · 0.85
save_configMethod · 0.80
load_configMethod · 0.80
from_configMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected