Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_url(self):
url = r'https://s3.amazonaws.com/pylinac/Tlog.bin'
self.assertIsInstance(load_log(url), TrajectoryLog)
def setUpClass(cls):
cls.log = load_log(cls.get_filename())
if cls.log.treatment_type != IMAGING:
cls.log.fluence.gamma.calc_map()
def test_invalid_file(self):
invalid_file = osp.join(TEST_DIR, 'Demo subbeam 0 actual fluence.npy')
with self.assertRaises(NotALogError):
load_log(invalid_file)
def test_append(self):
# append a directory
logs = MachineLogs(self.logs_altdir)
logs.append(self.logs_altdir)
self.assertEqual(logs.num_logs, 8)
# append a file string
single_file = osp.join(self.logs_altdir, 'Anonymous_4DC Treatment_JST90_TX_20140712094246.bin')
logs.append(single_file)
# append a MachineLog
single_log = load_log(single_file)
logs.append(single_log)
# try to append something that's not a Log
log = None
with self.assertRaises(TypeError):
logs.append(log)
def test_dynalog_file(self):
dynalog = osp.join(TEST_DIR, 'dlogs', 'A_static_imrt.dlg')
self.assertIsInstance(load_log(dynalog), Dynalog)
def test_dir(self):
dlog_dir = osp.join(TEST_DIR, 'dlogs')
self.assertIsInstance(load_log(dlog_dir), MachineLogs)
def test_zip(self):
zip_file = osp.join(TEST_DIR, 'mixed_types.zip')
self.assertIsInstance(load_log(zip_file), MachineLogs)
def analyze_log():
log = log_analyzer.load_log(self.log_file.get())
name, _ = osp.splitext(self.log_file.get())
fname = name + '.pdf'
fname = utilities.file_exists(fname)
log.publish_pdf(fname)
self.log_pdf.set(fname)
utilities.open_path(fname)
def _load_log(self, log: str):
"""Load a machine log that corresponds to the picket fence delivery.
This log determines the location of the pickets. The MLC peaks are then compared to the expected log pickets,
not a simple fit of the peaks."""
# load the log fluence image
mlog = load_log(log)
fl = mlog.fluence.expected.calc_map(equal_aspect=True)
fli = image.load(fl, dpi=254) # 254 pix/in => 1 pix/0.1mm (default fluence calc)
# equate them such that they're the same size & DPI
fluence_img, self.image = image.equate_images(fli, self.image)
# get picket fits from the modified fluence image
pf = PicketFence.from_demo_image()
pf.image = fluence_img
pf.analyze()
self._log_fits = cycle([p.fit for p in pf.pickets])