BhallaLab / moose

MOOSE simulator.
http://moose.ncbs.res.in
GNU General Public License v3.0
25 stars 19 forks source link

pylab import in rdesigneur affects the rest of the python script #199

Closed iampritishpatil closed 7 years ago

iampritishpatil commented 8 years ago

Line 23 has import pylab in rdesignuer.py that implicitly imports matplotlib.

In case where matplotlib needs to be imported explicitly using a different backend, to do for example,

import matplotlib as mpl
mpl.use('agg') #sets agg as the backend

but rdesigneur is imported before, the rdesigneur matplotlib dominates and thus the backend is not set. This is particularly relevant when running files on the cluster when the backend of matplotlib should be non-gui.

Importing a matplolotlib before importing rdesigneur might be a temporary fix, but maybe there is a better way around this where the rdesigneur internals don't affect the rest of the python code.

#########################################################################
## rdesigneur0_5.py ---
## This program is part of 'MOOSE', the
## Messaging Object Oriented Simulation Environment.
##           Copyright (C) 2014 Upinder S. Bhalla. and NCBS
## It is made available under the terms of the
## GNU General Public License version 2 or later.
## See the file COPYING.LIB for the full notice.
#########################################################################

##########################################################################
## This class builds models of
## Reaction-Diffusion and Electrical SIGnaling in NEURons.
## It loads in neuronal and chemical signaling models and embeds the
## latter in the former, including mapping entities like calcium and
## channel conductances, between them.
##########################################################################
from __future__ import print_function
import imp
import os
import moose
import numpy as np
import pylab
import math
import rmoogli
#import rdesigneurProtos
from rdesigneurProtos import *
from moose.neuroml.NeuroML import NeuroML
from moose.neuroml.ChannelML import ChannelML
import lxml
from lxml import etree
import h5py as h5
import csv
dilawar commented 8 years ago

User can also set his backend using matplotlibrc file.

In any case, importing moose does not import rdesigneur module.

On Fri 26 Aug, 2016 3:12 pm iampritishpatil, notifications@github.com wrote:

Line 23 has import pylab in rdesignuer.py that implicitly imports matplotlib.

In case where matplotlib needs to be imported explicitly using a different backend, to do for example,

import matplotlib as mpl mpl.use('agg') #sets agg as the backend

but rdesigneur is imported before, the rdesigneur matplotlib dominates and thus the backend is not set. This is particularly relevant when running files on the cluster when the backend of matplotlib should be non-gui.

Importing a matplolotlib before importing rdesigneur might be a temporary fix, but maybe there is a better way around this where the rdesigneur internals don't affect the rest of the python code.

#########################################################################

rdesigneur0_5.py ---

This program is part of 'MOOSE', the

Messaging Object Oriented Simulation Environment.

Copyright (C) 2014 Upinder S. Bhalla. and NCBS

It is made available under the terms of the

GNU General Public License version 2 or later.

See the file COPYING.LIB for the full notice.

#########################################################################

##########################################################################

This class builds models of

Reaction-Diffusion and Electrical SIGnaling in NEURons.

It loads in neuronal and chemical signaling models and embeds the

latter in the former, including mapping entities like calcium and

channel conductances, between them.

########################################################################## from future import print_function import imp import os import moose import numpy as np import pylab import math import rmoogli

import rdesigneurProtos

from rdesigneurProtos import * from moose.neuroml.NeuroML import NeuroML from moose.neuroml.ChannelML import ChannelML import lxml from lxml import etree import h5py as h5 import csv

It should either be added to dependencies or there should be:

from moose.neuroml.ChannelML import ChannelML try: from lxml import etree except: from xml import etree import h5py as h5

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BhallaLab/moose/issues/199, or mute the thread https://github.com/notifications/unsubscribe-auth/AA2qwXeEjKFcPzVAYylON9KXYEzAdUHjks5qjrT8gaJpZM4Jt6UP .

dilawar commented 7 years ago

This may cause problem over ssh without -X.