def test_aliases(self):
     """Test that aliases can be used and resolve"""
     fh= RMF.create_rmf_file(self.get_tmp_file_name("alias.rmf"))
     rh= fh.get_root_node()
     nh= rh.add_child("hi", RMF.REPRESENTATION)
     RMF.add_child_alias(nh, rh)
     ch= RMF.get_children_resolving_aliases(nh)
     self.assertEqual(len(ch), 1)
     self.assertEqual(ch[0], rh)
Exemple #2
0
 def test_aliases(self):
     """Test that aliases can be used and resolve"""
     for suffix in RMF.suffixes:
         path=RMF._get_temporary_file_path("alias."+suffix)
         print path
         fh= RMF.create_rmf_file(path)
         af= RMF.AliasFactory(fh)
         rh= fh.get_root_node()
         nh= rh.add_child("hi", RMF.REPRESENTATION)
         RMF.add_child_alias(af, nh, rh)
         ch= nh.get_children()
         self.assertEqual(len(ch), 1)
         print ch
         self.assertEqual(af.get(ch[0]).get_aliased(), rh)
Exemple #3
0
    for j in range(0,10):
        curh= curph.add_child("atom"+str(j), RMF.REPRESENTATION)
        p= pf.get(curh)
        p.set_coordinates([3*i,3*j,0])
        p.set_mass(1)
        p.set_radius(1)
        c= cf.get(curh)
        if j%3==0:
            c.set_rgb_color([1,0,0])
            red.append(curh)
        elif j%3==1:
            c.set_rgb_color([0,1,0])
            green.append(curh)
        else:
            c.set_rgb_color([0,0,1])
            blue.append(curh)

# add a second organization scheme by color
crh= rh.add_child("colors", RMF.REPRESENTATION)

redh= crh.add_child("red", RMF.REPRESENTATION)
greenh= crh.add_child("green", RMF.REPRESENTATION)
blueh= crh.add_child("blue", RMF.REPRESENTATION)

for r in red:
    RMF.add_child_alias(redh, r)
for g in green:
    RMF.add_child_alias(greenh, g)
for b in blue:
    RMF.add_child_alias(blueh, b)
Exemple #4
0
        curh= curph.add_child("atom"+str(j), RMF.REPRESENTATION)
        p= pf.get(curh)
        p.set_coordinates([3*i,3*j,0])
        p.set_mass(1)
        p.set_radius(1)
        c= cf.get(curh)
        if j%3==0:
            c.set_rgb_color([1,0,0])
            red.append(curh)
        elif j%3==1:
            c.set_rgb_color([0,1,0])
            green.append(curh)
        else:
            c.set_rgb_color([0,0,1])
            blue.append(curh)

# add a second organization scheme by color
crh= rh.add_child("colors", RMF.REPRESENTATION)

redh= crh.add_child("red", RMF.REPRESENTATION)
greenh= crh.add_child("green", RMF.REPRESENTATION)
blueh= crh.add_child("blue", RMF.REPRESENTATION)

af= RMF.AliasFactory(fh)
for r in red:
    RMF.add_child_alias(af, redh,  r)
for g in green:
    RMF.add_child_alias(af, greenh, g)
for b in blue:
    RMF.add_child_alias(af, blueh, b)