SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
59 stars 29 forks source link

Avoid using `import *` in Python MR and PET demo scripts #1215

Closed evgueni-ovtchinnikov closed 11 months ago

evgueni-ovtchinnikov commented 11 months ago

Changes in this pull request

Currently, we use

exec('from sirf.' + args['--engine'] + ' import *')

to import reconstruction modules (engines) for MR (Gadgetron) and PET (STIR). This practice is not recommended, and raises Codacy complaints.

This PR suggests using importlib function instead, e.g. for MR:

import importlib
mr = importlib.import_module('sirf.' + args['--engine'])
acq_data = mr.AcquisitionData()

Testing performed

The demo scripts run ok on my VM.

Related issues

Checklist before requesting a review

Contribution Notes

Please read and adhere to the contribution guidelines.

Please tick the following:

KrisThielemans commented 11 months ago

great idea.