コード例 #1
0
ファイル: baseline.py プロジェクト: berquist/rxnlvl
 def __init__(self, energy, colour=0x0, mode='dashed', opacity=0.5):
     try:
         assert energy.__class__.__name__ == 'energy',\
         'baseline is not of class \'energy\''
     except AssertionError as e:
         sys.stderr.write(str(e))
     self.energy=energy
     # Ensure colour is a 24 bit hex colour.
     if validateColour(colour):
         self.colour = colour
     else:
         sys.stderr.write('{0} has invalid colour: {1}\n'.format(
         self.describeLevel(name),
         colour
         ))
         sys.exit(1)
     try:
         assert opacity >= 0.0 and opacity <= 1.0, 'Invalid opacity on edge {0} to {1}: {2}\n'.format(
         self.start,
         self.end,
         '{0}%'.format(opacity*100.0) if type(opacity) in [int, float] else opacity
         )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.opacity = opacity
     self.mode    = mode
コード例 #2
0
ファイル: level.py プロジェクト: yychuang/rxnlvl
 def __init__(self, energy, location, name=None, colour=0x0):
     # Validation of energy is done inside energy class
     self.energy = energy
     # Validate location. Locations must be positive nonzero integers. Locations should start at 1 and be contiguous.
     try:
         assert type(
             location
         ) == int, '{0} does not have an integer location.\n'.format(
             self.describeLevel(name))
     except AssertionError as e:
         sys.stderr.write(e)
         sys.exit(1)
     try:
         assert location > 0, 'supplied location ({0}) of {1} must be greater than 0.\n'.format(
             str(self.location), self.describeLevel(name))
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.location = location
     # Locations don't require names but not supplying one makes it really hard to connect.
     self.name = name
     # Ensure colour is a 24 bit hex colour.
     if validateColour(colour):
         self.colour = colour
     else:
         sys.stderr.write('{0} has invalid colour: {1}\n'.format(
             self.describeLevel(name), colour))
         sys.exit(1)
コード例 #3
0
ファイル: level.py プロジェクト: berquist/rxnlvl
 def __init__(self, energy, location, name=None, colour=0x0):
     # Validation of energy is done inside energy class
     self.energy = energy
     # Validate location. Locations must be positive nonzero integers. Locations should start at 1 and be contiguous.
     try:
         assert type(location) == int, '{0} does not have an integer location.\n'.format(
         self.describeLevel(name)
         )
     except AssertionError as e:
         sys.stderr.write(e)
         sys.exit(1)
     try:
         assert location > 0, 'supplied location ({0}) of {1} must be greater than 0.\n'.format(
         str(self.location),
         self.describeLevel(name)
         )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.location = location
     # Locations don't require names but not supplying one makes it really hard to connect.
     self.name     = name
     # Ensure colour is a 24 bit hex colour.
     if validateColour(colour):
         self.colour = colour
     else:
         sys.stderr.write('{0} has invalid colour: {1}\n'.format(
         self.describeLevel(name),
         colour
         ))
         sys.exit(1)
コード例 #4
0
ファイル: __init__.py プロジェクト: naporin0624/rxnlvl
 def __init__(self,
              dimensions,
              bgcolour=None,
              vbuf=10.0,
              hbuf=10.0,
              qualified=True):
     self.nodes = []
     self.edges = []
     self.bgcolour = None
     self.baseline = None
     try:
         assert len(dimensions) == 2, 'plot dimensions not equal to 2\n'
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     try:
         for elem in dimensions:
             assert type(elem) in [int,float] and elem > 1,\
             'Malformed dimension element: {0}\n'.format(
             str(elem)
             )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.dimensions = dimensions
     if validateColour(bgcolour):
         self.bgcolour = bgcolour
     else:
         sys.stderr.write('INFO: Plot background colour is not set ' +
                          'or invalid - plot background will be ' +
                          'transparent\n')
     try:
         assert type(qualified) in [bool, str],\
         ('Could not interpret qualification ({0}) as '.format(qualified) +
          'boolean or string.\n'
         )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.qualified = qualified
     try:
         assert vbuf > 0 and hbuf > 0,\
         ('vertical and horizontal buffers must be ' +
          'positive rational numbers\n'
         )
     except AssertionError:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.vbuf = float(vbuf)
     self.hbuf = float(hbuf)
コード例 #5
0
ファイル: __init__.py プロジェクト: berquist/rxnlvl
 def __init__(self, dimensions, bgcolour=None, vbuf=10.0, hbuf=10.0,
              qualified=True):
     self.nodes = []
     self.edges = []
     self.bgcolour = None
     self.baseline = None
     try:
         assert len(dimensions) == 2, 'plot dimensions not equal to 2\n'
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     try:
         for elem in dimensions:
             assert type(elem) in [int,float] and elem > 1,\
             'Malformed dimension element: {0}\n'.format(
             str(elem)
             )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.dimensions = dimensions
     if validateColour(bgcolour):
         self.bgcolour = bgcolour
     else:
         sys.stderr.write('INFO: Plot background colour is not set ' +
                          'or invalid - plot background will be ' +
                          'transparent\n'
                         )
     try:
         assert type(qualified) in [bool, str],\
         ('Could not interpret qualification ({0}) as '.format(qualified) +
          'boolean or string.\n'
         )
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.qualified = qualified
     try:
         assert vbuf > 0 and hbuf > 0,\
         ('vertical and horizontal buffers must be ' +
          'positive rational numbers\n'
         )
     except AssertionError:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.vbuf = float(vbuf)
     self.hbuf = float(hbuf)
コード例 #6
0
ファイル: baseline.py プロジェクト: yychuang/rxnlvl
 def __init__(self, energy, colour=0x0, mode='dashed', opacity=0.5):
     try:
         assert energy.__class__.__name__ == 'energy',\
         'baseline is not of class \'energy\''
     except AssertionError as e:
         sys.stderr.write(str(e))
     self.energy = energy
     # Ensure colour is a 24 bit hex colour.
     if validateColour(colour):
         self.colour = colour
     else:
         sys.stderr.write('{0} has invalid colour: {1}\n'.format(
             self.describeLevel(name), colour))
         sys.exit(1)
     try:
         assert opacity >= 0.0 and opacity <= 1.0, 'Invalid opacity on edge {0} to {1}: {2}\n'.format(
             self.start, self.end, '{0}%'.format(opacity * 100.0)
             if type(opacity) in [int, float] else opacity)
     except AssertionError as e:
         sys.stderr.write(str(e))
         sys.exit(1)
     self.opacity = opacity
     self.mode = mode