def test_hstack_vstack():
 def make_block(dtype):
  return theano.sparse.csr_matrix(name=('%s block' % dtype), dtype=dtype)
 def get_expected_dtype(blocks, to_dtype):
  if (to_dtype is None):
   block_dtypes = tuple((b.dtype for b in blocks))
   return theano.scalar.upcast(*block_dtypes)
  else:
   return to_dtype
 dtypes = ('complex128', theano.config.floatX)
 blocks = [make_block(dtype) for dtype in dtypes]
 for (stack_dimension, stack_function) in enumerate((theano.sparse.vstack, theano.sparse.hstack)):
  for to_dtype in ((None,) + dtypes):
   stacked_blocks = stack_function(blocks, dtype=to_dtype)
   expected_dtype = get_expected_dtype(blocks, to_dtype)
   assert (stacked_blocks.dtype == expected_dtype)

def test_hstack_vstack ( ) : def make_block ( dtype ) : return theano . sparse . csr_matrix ( name = ( '%s block' % dtype ) , dtype = dtype ) def get_expected_dtype ( blocks , to_dtype ) : if ( to_dtype is None ) : block_dtypes = tuple ( ( b . dtype for b in blocks ) ) return theano . scalar . upcast ( * block_dtypes ) else : return to_dtype dtypes = ( 'complex128' , theano . config . floatX ) blocks = [ make_block ( dtype ) for dtype in dtypes ] for ( stack_dimension , stack_function ) in enumerate ( ( theano . sparse . vstack , theano . sparse . hstack ) ) : for to_dtype in ( ( None , ) + dtypes ) : stacked_blocks = stack_function ( blocks , dtype = to_dtype ) expected_dtype = get_expected_dtype ( blocks , to_dtype ) assert ( stacked_blocks . dtype == expected_dtype )
tests sparse .