mahmoodlab / CLAM

Data-efficient and weakly supervised computational pathology on whole slide images - Nature Biomedical Engineering
http://clam.mahmoodlab.org
GNU General Public License v3.0
1.02k stars 340 forks source link

Please do not use star imports #187

Closed research-police closed 1 year ago

research-police commented 1 year ago

We patrolled your repo and found the following:

https://github.com/mahmoodlab/CLAM/blob/9482cbc72df522087cfbaa3e6b52da5207a7980a/utils/core_utils.py#L3

As the official Python documentation states:

Note that in general the practice of importing * from a module or package is frowned upon, since it often causes poorly readable code. However, it is okay to use it to save typing in interactive sessions.

In your case, device is star imported and used without any hint of origin: https://github.com/mahmoodlab/CLAM/blob/9482cbc72df522087cfbaa3e6b52da5207a7980a/utils/core_utils.py#L118

In other cases, device is overwritten in some of the functions: https://github.com/mahmoodlab/CLAM/blob/9482cbc72df522087cfbaa3e6b52da5207a7980a/utils/core_utils.py#L222

fedshyvana commented 1 year ago

Hey thanks for noting - for any suggestions regarding code refactoring/organization, please feel free to open a PR. Any contribution to improving the code base is always welcome : )