MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_serialization_gzip

Method test_serialization_gzip

test/test_serialization.py:230–241  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

228 self.assertEqual(torch.load(f), t)
229
230 def test_serialization_gzip(self):
231 # Test serialization with gzip file
232 b = self._test_serialization_data()
233 f1 = tempfile.NamedTemporaryFile(delete=False)
234 f2 = tempfile.NamedTemporaryFile(delete=False)
235 torch.save(b, f1)
236 with open(f1.name, 'rb') as f_in, gzip.open(f2.name, 'wb') as f_out:
237 shutil.copyfileobj(f_in, f_out)
238
239 with gzip.open(f2.name, 'rb') as f:
240 c = torch.load(f)
241 self._test_serialization_assert(b, c)
242
243 @unittest.skipIf(
244 not TEST_DILL or HAS_DILL_AT_LEAST_0_3_1,

Callers

nothing calls this directly

Calls 5

saveMethod · 0.45
openMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected