コード例 #1
0
def exercise():
  g = graphics_utils.make_rainbow_gradient(nbins=21)
  assert approx_equal(g[0], (0.0, 0.0, 1.0))
  assert approx_equal(g[10], (0.0, 1.0, 0.0))
  assert approx_equal(g[-1], (1.0, 0.0, 0.0))
  sel = flex.bool([True] * 10)
  sel[5] = False
  r = graphics_utils.color_rainbow(
    selection=sel,
    color_all=False)
  assert approx_equal(r[0], (0.0,0.0,1.0))
  assert approx_equal(r[-1], (1.0,0.0,0.0))
  assert approx_equal(r[4], (0.0,1.0,0.0))
  r2 = graphics_utils.color_rainbow(
    selection=sel,
    color_all=True)
  assert approx_equal(r2[0], (0.0,0.0,1.0))
  assert approx_equal(r2[-1], (1.0,0.0,0.0))
  assert approx_equal(r2[6], (2/3.,1.0,0.0))
  b = flex.double([4.0,5.2,1.7,6.9,9.5,24.3])
  c = graphics_utils.color_by_property(
    properties=b,
    selection=flex.bool(b.size(), True))
  assert approx_equal(c[2], (0.0,0.0,1.0))
  c2 = graphics_utils.scale_selected_colors(
    input_colors=c,
    selection=flex.bool(c.size(), True),
    scale=0.9)
  assert approx_equal(c2[2], (0.0,0.0,0.9))
  c3 = graphics_utils.grayscale_by_property(
    properties=b,
    selection=flex.bool(b.size(), True))
  assert approx_equal(c3[2], (0.95,0.95,0.95))
コード例 #2
0
ファイル: tst.py プロジェクト: cctbx/cctbx-playground
def exercise () :
  g = graphics_utils.make_rainbow_gradient(nbins=21)
  assert approx_equal(g[0], (0.0, 0.0, 1.0))
  assert approx_equal(g[10], (0.0, 1.0, 0.0))
  assert approx_equal(g[-1], (1.0, 0.0, 0.0))
  sel = flex.bool([True] * 10)
  sel[5] = False
  r = graphics_utils.color_rainbow(
    selection=sel,
    color_all=False)
  assert approx_equal(r[0], (0.0,0.0,1.0))
  assert approx_equal(r[-1], (1.0,0.0,0.0))
  assert approx_equal(r[4], (0.0,1.0,0.0))
  r2 = graphics_utils.color_rainbow(
    selection=sel,
    color_all=True)
  assert approx_equal(r2[0], (0.0,0.0,1.0))
  assert approx_equal(r2[-1], (1.0,0.0,0.0))
  assert approx_equal(r2[6], (2/3.,1.0,0.0))
  b = flex.double([4.0,5.2,1.7,6.9,9.5,24.3])
  c = graphics_utils.color_by_property(
    properties=b,
    selection=flex.bool(b.size(), True))
  assert approx_equal(c[2], (0.0,0.0,1.0))
  c2 = graphics_utils.scale_selected_colors(
    input_colors=c,
    selection=flex.bool(c.size(), True),
    scale=0.9)
  assert approx_equal(c2[2], (0.0,0.0,0.9))
  c3 = graphics_utils.grayscale_by_property(
    properties=b,
    selection=flex.bool(b.size(), True))
  assert approx_equal(c3[2], (0.95,0.95,0.95))
コード例 #3
0
 def highlight_atoms (self, selection_string) :
   if selection_string is None :
     self.is_changed = True
     if self._cached_colors is not None :
       self.atom_colors = self._cached_colors
     else :
       self.set_color_mode(self.color_mode)
   else :
     atom_selection = self.get_atom_selection(selection_string)
     if atom_selection is not None and atom_selection.count(True) != 0 :
       self._cached_colors = self.atom_colors
       #self.set_color_mode(self.color_mode)
       self.is_changed = True
       self.atom_colors = graphics_utils.scale_selected_colors(
         input_colors=self.atom_colors,
         selection=~atom_selection,
         scale=0.5)
コード例 #4
0
 def highlight_atoms(self, selection_string):
     if selection_string is None:
         self.is_changed = True
         if self._cached_colors is not None:
             self.atom_colors = self._cached_colors
         else:
             self.set_color_mode(self.color_mode)
     else:
         atom_selection = self.get_atom_selection(selection_string)
         if atom_selection is not None and atom_selection.count(True) != 0:
             self._cached_colors = self.atom_colors
             #self.set_color_mode(self.color_mode)
             self.is_changed = True
             self.atom_colors = graphics_utils.scale_selected_colors(
                 input_colors=self.atom_colors,
                 selection=~atom_selection,
                 scale=0.5)