Skip to content

Commit

Permalink
Remove spurious print
Browse files Browse the repository at this point in the history
Don't warn about IMP.isd2 being missing at import time;
instead raise an exception if the user tries to instantiate
a class which requires IMP.isd2 (SAXSISDRestraint).
  • Loading branch information
benmwebb committed Aug 10, 2020
1 parent 52410d6 commit 8fac143
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pyext/src/restraints/saxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import IMP.pmi.tools
import IMP.pmi.restraints
import IMP.saxs
import IMP.isd
try:
import IMP.isd2
except ImportError:
pass
import warnings

class SAXSRestraint(IMP.pmi.restraints.RestraintBase):
Expand Down Expand Up @@ -97,15 +102,13 @@ class SAXSISDRestraint(IMP.pmi.restraints.RestraintBase):

"""Basic SAXS restraint using ISD."""

import IMP.isd
try:
import IMP.isd2
except:
print("Module isd2 not installed. Cannot use SAXSISDRestraint")

def __init__(self, representation, profile, resolution=0, weight=1,
ff_type=IMP.saxs.HEAVY_ATOMS, label=None):

if not hasattr(IMP, 'isd2'):
raise ImportError("Module isd2 not installed. "
"Cannot use SAXSISDRestraint")

model = representation.prot.get_model()
super(SAXSISDRestraint, self).__init__(model, label=label,
weight=weight)
Expand Down

0 comments on commit 8fac143

Please sign in to comment.