Esempio n. 1
0
Example code demonstrating simple semantic containers 'grouping' operation.

"""
from ncobj.cdl import cdl

import ncobj.examples.simple_semantic_containers as egs


g = egs.eg_simple_flat()
g_cdl = cdl(g)

print
print '----------------'
print 'Original flat version:'
print '----------------'
print g_cdl
print '----------------'

g_grouped = egs.group_flat_containers(g)
g_grouped_cdl = cdl(g_grouped)
print
print '----------------'
print 'Result, grouped from flat form:'
print '----------------'
print g_grouped_cdl
print '----------------'

g_grouped_eg = egs.eg_simple_grouped()
print
print 'Result matches grouped-form reference : ', g_grouped == g_grouped_eg
 def test_f2g(self):
     g_f = eg_simple_flat()
     g_g = eg_simple_grouped()
     g_f2g = group_flat_containers(g_f)
     self.assertEqual(g_f2g, g_g)
 def test_roundtrip_g2f_f2g(self):
     g = self.g_simple_grouped_explicit
     g = group_flat_containers(flatten_grouped_containers(g))
     self.assertEqual(g, self.g_simple_grouped_explicit)
 def test_roundtrip_f2g_g2f(self):
     g = self.g_simple_flat
     g = flatten_grouped_containers(group_flat_containers(g))
     self.assertEqual(g, self.g_simple_flat)
 def test_simple_f2g(self):
     g = self.g_simple_flat
     g_grouped = group_flat_containers(g)
     self.assertEqual(g_grouped, self.g_simple_grouped_explicit)