def test_11_empty_input(self):
     """Autochunked redimension of empty array should not fail (SDB-5109)"""
     out = iquery('-aq', 'create temp array empty<val:double>[k=0:39,20,4]')
     assert noerr(out), out
     self._array_cleanups.append("empty")
     out = iquery('-otsv+', '-aq',
                  'redimension(empty, <val:double>[k=0:39,*,3])')
     assert noerr(out), out
     assert not out, "Redim of empty array is not empty: '%s'" % out
 def tearDownClass(self):
     print "Teardown ...",
     sys.stdout.flush()
     if not _args.keep_arrays:
         if os.system("rm -rf {0}".format(_tmpdir)):
             raise AppError("Trouble cleaning up %s" % _tmpdir)
         for a in self._array_cleanups:
             iquery('-naq', "remove(%s)" % a)
     print "done"
 def test_06_coll_2d_counts_and_sums(self):
     """Compare 2-D array counts and sums"""
     out1 = iquery('-otsv', '-aq', 'aggregate(coll_2d_ac,count(*),sum(v))')
     assert noerr(out1), out1
     out2 = iquery('-otsv', '-aq', 'aggregate(coll_2d,count(*),sum(v))')
     assert noerr(out2), out2
     c1, s1 = map(int, out1.split())
     c2, s2 = map(int, out2.split())
     assert c1 == c2, "counts differ"
     assert s1 == s2, "sums differ"
 def test_09_nocoll_3d_overlap_counts_and_sums(self):
     """Compare 3-D array counts and sums (overlap)"""
     out1 = iquery('-otsv', '-aq',
                   'aggregate(nocoll_3d_ac_ol,count(*),sum(v))')
     assert noerr(out1), out1
     out2 = iquery('-otsv', '-aq', 'aggregate(nocoll_3d,count(*),sum(v))')
     assert noerr(out2), out2
     c1, s1 = map(int, out1.split())
     c2, s2 = map(int, out2.split())
     assert c1 == c2, "counts differ"
     assert s1 == s2, "sums differ"
 def test_03_nocoll_3d_check_values(self):
     """Cell-by-cell value comparison for 3-D arrays"""
     out = iquery('-otsv+', '-aq', """
         filter(join(nocoll_3d,nocoll_3d_ac), nocoll_3d.v <> nocoll_3d_ac.v)
         """)
     assert noerr(out), out
     assert out == '', "Cell values differ:\n\t{0}".format(out)
 def test_00_load_3d_ac(self):
     """Load 3-D no-collision data using autochunking"""
     dims = "x,y,z"          # Autochunked!
     query = """
         store(
           redimension(
             input(<v:int64,x:int64,y:int64,z:int64>[dummy], '{0}',
                   -2, '(int64,int64,int64,int64)'),
             <v:int64>[{1}]),
           {2}) """.format(self._files['nocoll_3d'], dims, "nocoll_3d_ac")
     out = iquery('-naq', query)
     assert noerr(out), out
     self._array_cleanups.append("nocoll_3d_ac")
 def test_05_load_2d_concrete_w_collisions(self):
     """Load 2-D data containing collisions with specified chunks"""
     dims = "x=0:*,100,0,y=0:*,100,0,synth=0:9,10,0"
     query = """
         store(
           redimension(
             input(<v:int64,x:int64,y:int64>[dummy], '{0}',
                   -2, '(int64,int64,int64)'),
             <v:int64>[{1}]),
           {2}) """.format(self._files['coll_2d'], dims, "coll_2d")
     out = iquery('-naq', query)
     assert noerr(out), out
     self._array_cleanups.append("coll_2d")
 def test_04_load_2d_ac_w_collisions(self):
     """Load 2-D data containing collisions using autochunking"""
     dims = "x=0:*,*,0,y=0:*,*,0,synth=0:*,*,0"
     query = """
         store(
           redimension(
             input(<v:int64,x:int64,y:int64>[dummy], '{0}',
                   -2, '(int64,int64,int64)'),
             <v:int64>[{1}]),
           {2}) """.format(self._files['coll_2d'], dims, "coll_2d_ac")
     out = iquery('-naq', query)
     assert noerr(out), out
     self._array_cleanups.append("coll_2d_ac")
 def test_01_load_3d_concrete(self):
     """Load 3-D no-collisions data with specified chunks"""
     dims = "x=0:*,10,0,y=0:*,100,0,z=0:*,100,0"
     query = """
         store(
           redimension(
             input(<v:int64,x:int64,y:int64,z:int64>[dummy], '{0}',
                   -2, '(int64,int64,int64,int64)'),
             <v:int64>[{1}]),
           {2}) """.format(self._files['nocoll_3d'], dims, "nocoll_3d")
     out = iquery('-naq', query)
     assert noerr(out), out
     self._array_cleanups.append("nocoll_3d")
 def test_12_one_input_cell(self):
     """Autochunked redimension of 1-cell array should not fail"""
     out = iquery('-aq', 'create temp array ONE<val:double>[k=0:39,20,4]')
     assert noerr(out), out
     self._array_cleanups.append("ONE")
     # Insert one cell at k == 25.
     out = iquery('-otsv+:l', '-naq', """
         insert(
           redimension(
             apply(build(<val:double>[i=0:0,1,0], 3.14), k, 25),
             ONE),
         ONE)""")
     assert noerr(out), out
     out = iquery ('-otsv+', '-aq',
                   'redimension(ONE, <val:double>[k=0:39,*,3])')
     assert noerr(out), out
     try:
         numbers = map(float, out.split())
     except ValueError:
         assert False, "Unexpected non-number in '%s'" % out
     assert len(numbers) == 2
     assert numbers[0] == 25
     assert numbers[1] == 3.14