Changeset 295 for trunk/src/stgen.py

Show
Ignore:
Timestamp:
11/06/08 11:32:13 (4 years ago)
Author:
pierre
Message:

Attempt to set up a common framework for the dependencies. Since NeuroTools will be a lot of heterogeneous subparts, a lots of import will be done. I think, as proposed by Eilif, that we should try to gather as much as possible of those import and check in the init file. Then warning messages will be automatically displayed according to what you're loading. So the idea is that you add non-specific import in the init dependencies dictionnary. Then, in your code, you just have to import the function check_dependency() from NeuroTools.init. By doing check_dependency(.. your package name ...), you'll know if this is present or not, and if not a message is sent to the user automatically. Hope all the packages are working

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/stgen.py

    r192 r295  
    44# TODO make it generate spiketrains? 
    55 
    6 try: 
     6from NeuroTools.__init__ import check_dependency 
     7 
     8have_gsl = check_dependency('pygsl') 
     9if have_gsl: 
    710    import pygsl 
    8     have_gsl = True 
    9 except ImportError: 
    10     print "Warning: pygsl not available" 
    11     have_gsl = False 
    12 from numpy import array, log 
    13 import numpy 
    14  
     11 
     12if check_dependency('numpy'): 
     13    from numpy import array, log 
     14    import numpy 
    1515 
    1616