solevillar / scGeneFit-python

Python code for genetic marker selection using linear programming
MIT License
41 stars 13 forks source link

Exiting the context manager cleans up files in tmp #2

Open HekpoMaH opened 2 years ago

HekpoMaH commented 2 years ago

Hi!

According to https://docs.python.org/3.11/library/importlib.resources.html, "Exiting the context manager cleans up any temporary file created when the resource was extracted from e.g. a zip file.". With versions of python >3.7, this makes it impossible to return just the string of the path, as it will be sth in /tmp folder that would get deleted. Therefore loading the matlab data was moved inside the context manager. The .path paradigm is also being deprecated as of version 3.11, so I used the files/as_file approach given here https://importlib-resources.readthedocs.io/en/latest/using.html

The changes were tested with the 2 smaller scale jupyter examples. image image

It does seem to work. (And theoretically, the below PR only touches dataloading).