<s> from __future__ import print_function <EOL> import unittest <EOL> import numpy <EOL> import scipy . sparse <EOL> from pylearn2 . testing . skip import skip_if_no_data <EOL> import pylearn2 . datasets . utlc as utlc <EOL> def test_ule ( ) : <EOL> skip_if_no_data ( ) <EOL> train , valid , test , transfer = utlc . load_ndarray_dataset ( "<STR_LIT>" , <EOL> normalize = True , <EOL> transfer = True ) <EOL> assert train . shape [ <NUM_LIT:0> ] == transfer . shape [ <NUM_LIT:0> ] <EOL> def test_all_utlc ( ) : <EOL> skip_if_no_data ( ) <EOL> for name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> print ( "<STR_LIT>" , name ) <EOL> train , valid , test = utlc . load_ndarray_dataset ( name , normalize = True ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( train . dtype , train . max ( ) , train . min ( ) , train . mean ( ) , train . std ( ) ) <EOL> assert isinstance ( train , numpy . ndarray ) <EOL> assert isinstance ( valid , numpy . ndarray ) <EOL> assert isinstance ( test , numpy . ndarray ) <EOL> assert train . shape [ <NUM_LIT:1> ] == test . shape [ <NUM_LIT:1> ] == valid . shape [ <NUM_LIT:1> ] <EOL> def test_sparse_ule ( ) : <EOL> skip_if_no_data ( ) <EOL> train , valid , test , transfer = utlc . load_sparse_dataset ( "<STR_LIT>" , <EOL> normalize = True , <EOL> transfer = True ) <EOL> assert train . shape [ <NUM_LIT:0> ] == transfer . shape [ <NUM_LIT:0> ] <EOL> def test_all_sparse_utlc ( ) : <EOL> skip_if_no_data ( ) <EOL> for name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> print ( "<STR_LIT>" , name ) <EOL> train , valid , test = utlc . load_sparse_dataset ( name , normalize = True ) <EOL> nb_elem = numpy . prod ( train . shape ) <EOL> mi = train . data . min ( ) <EOL> ma = train . data . max ( ) <EOL> mi = min ( <NUM_LIT:0> , mi ) <EOL> ma = max ( <NUM_LIT:0> , ma ) <EOL> su = train . data . sum ( ) <EOL> mean = float ( su ) / nb_elem <EOL> print ( name , "<STR_LIT>" ) <EOL> print ( train . dtype , ma , mi , mean , train . nnz , end = '<STR_LIT>' ) <EOL> print ( nb_elem , ( nb_elem - float ( train . nnz ) ) / nb_elem ) <EOL> print ( name , "<STR_LIT>" ) <EOL> print ( train . data . max ( ) , train . data . min ( ) , end = '<STR_LIT>' ) <EOL> print ( train . data . mean ( ) , train . data . std ( ) ) <EOL> assert scipy . sparse . issparse ( train ) <EOL> assert scipy . sparse . issparse ( valid ) <EOL> assert scipy . sparse . issparse ( test ) <EOL> assert train . shape [ <NUM_LIT:1> ] == test . shape [ <NUM_LIT:1> ] == valid . shape [ <NUM_LIT:1> ] </s>
