Пример #1
0
 def test_output_types(self):
     self.assertType(normalize_hounsfield(self.bnp.astype(np.float32)), np.float32)
     self.assertType(normalize_hounsfield(self.bpt, dtype=np.float32 ), np.float32)
     self.assertType(normalize_hounsfield(self.bpt.to(    torch.float32)), torch.float32)
     self.assertType(normalize_hounsfield(self.bnp, dtype=torch.float32 ), torch.float32)
Пример #2
0
 def test_shapes_match(self):
     self.assertSameShape(normalize_hounsfield(self.bnp), self.bnp)
     self.assertSameShape(normalize_hounsfield(self.bpt), self.bpt)
     self.assertSameDims(normalize_hounsfield(self.bnp),  self.bnp)
     self.assertSameDims(normalize_hounsfield(self.bpt),  self.bpt)
Пример #3
0
 def test_nans(self):
     self.assertNotAny(   np.isnan(normalize_hounsfield(self.anp)))
     self.assertNotAny(torch.isnan(normalize_hounsfield(self.apt)))
     self.assertNotAny(   np.isnan(normalize_hounsfield(self.bnp)))
     self.assertNotAny(torch.isnan(normalize_hounsfield(self.bpt)))
Пример #4
0
 def test_boundaries(self):
     self.assertAll(normalize_hounsfield(self.bnp) >= 0.0)
     self.assertAll(normalize_hounsfield(self.bnp) <= 1.0)
     self.assertAll(normalize_hounsfield(self.bpt) >= 0.0)
     self.assertAll(normalize_hounsfield(self.bpt) <= 1.0)
Пример #5
0
 def test_invalid_type_exception(self):
     with self.assertRaises(Exception): normalize_hounsfield('abcd')
     with self.assertRaises(Exception): normalize_hounsfield({'answer': 42})
Пример #6
0
 def test_values_match(self):
     self.assertSameValues(normalize_hounsfield(self.anp), self.anpr)
     self.assertSameValues(normalize_hounsfield(self.apt), self.aptr)
     self.assertCloseValues(normalize_hounsfield((1,2,3)), np.array([0.0002442, 0.0004884, 0.0007326], dtype=np.float32))
     self.assertCloseValues(normalize_hounsfield([1,2,3]), np.array([0.0002442, 0.0004884, 0.0007326], dtype=np.float32))
     self.assertAlmostEqual(normalize_hounsfield(1), 0.0002442)