Closed ingo-m closed 7 years ago
Thanks for spotting this and suggesting the solutions. I decided to go with: try: import tensorflow as tf except ImportError: pass
If someone in the future comes up with a better/more stylish solution, we can go for that.
Very nice to see that the GPU pRF finding functionality has been put into the main branch with commit a11134c.
There is one issue that I don't know how to solve in an 'elegant' way: In
pRF_main.py
, the GPU function is imported:from pRF_funcFindPrfGpu import funcFindPrfGpu
. In that function, tensorflow is imported:import tensorflow as tf
. Now this will throw an error if tensorflow is not available (which may be the case for most users). An easy way would be anif
condition, likeif cfg.strVersion == 'gpu': from pRF_funcFindPrfGpu import funcFindPrfGpu
. But I have some doubts whether that would be in accordance with PEP8.Some people say conditional imports are fine: https://stackoverflow.com/a/12861052 https://stackoverflow.com/a/21298234
Others suggest using
try
https://stackoverflow.com/a/40974488So it's a matter of style.