code: def test_flatten_unflatten():
      # build three sets (x,y,z)
      sx = set([point(1.0, 1.0), point(2.0, 1.0), point(3.0, 2.0)])
      sy = set([point(0.0, 1.0), point(3.0, 2.0)])
      sz = set([point(1.0, 1.0), point(2.0, 3.0)])
  
      # build a collection
      c = collection([sx, sy, sz])
  
      # flatten and unflatten
      from mystic.math.discrete import flatten, unflatten
  
      d = unflatten(flatten(c), c.pts)
  
      # check if the same
      assert c.npts == d.npts
      assert c.weights == d.weights
      assert c.positions == d.positions
  
      # flatten() and load(...)
      e = collection().load(c.flatten(), c.pts)
  
      # check if the same
      assert c.npts == e.npts
      assert c.weights == e.weights
      assert c.positions == e.positions
  
      # decompose and compose
      from mystic.math.discrete import decompose, compose
  
      b = compose(*decompose(c))
  
      # check if the same
      assert c.npts == b.npts
      assert c.weights == b.weights
      assert c.positions == b.positions
      return
  
file_path: mystic/mystic/tests/test_dirac_measure.py
imports: from mystic.math.discrete import point_mass
  from mystic.math.discrete import measure
  from mystic.math.discrete import product_measure
  from mystic.math.samples import random_samples
  from mystic.math.grid import samplepts
  from mystic.math import almostEqual
  from mystic.math.measures import *
  from mystic.math.measures import _pack, _unpack
label_desc: Use image node_id 5 for calling a global function with example usage: test_flatten_unflatten() without return types