<s> import numpy <EOL> from numpy . testing import assert_raises , assert_equal , assert_allclose <EOL> from fuel import config <EOL> from fuel . datasets import MNIST <EOL> from fuel . streams import DataStream <EOL> from fuel . schemes import SequentialScheme <EOL> from tests import skip_if_not_available <EOL> def test_mnist_train ( ) : <EOL> skip_if_not_available ( datasets = [ '<STR_LIT>' ] ) <EOL> dataset = MNIST ( ( '<STR_LIT:train>' , ) , load_in_memory = False ) <EOL> handle = dataset . open ( ) <EOL> data , labels = dataset . get_data ( handle , slice ( <NUM_LIT:0> , <NUM_LIT:10> ) ) <EOL> assert data . dtype == '<STR_LIT>' <EOL> assert data . shape == ( <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert labels . shape == ( <NUM_LIT:10> , <NUM_LIT:1> ) <EOL> known = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:64> , <NUM_LIT:0> , <EOL> <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> assert_allclose ( data [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:6> ] , known ) <EOL> assert labels [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:5> <EOL> assert dataset . num_examples == <NUM_LIT> <EOL> dataset . close ( handle ) <EOL> stream = DataStream . default_stream ( <EOL> dataset , iteration_scheme = SequentialScheme ( <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> data = next ( stream . get_epoch_iterator ( ) ) [ <NUM_LIT:0> ] <EOL> assert data . min ( ) >= <NUM_LIT:0.0> and data . max ( ) <= <NUM_LIT:1.0> <EOL> assert data . dtype == config . floatX <EOL> def test_mnist_test ( ) : <EOL> skip_if_not_available ( datasets = [ '<STR_LIT>' ] ) <EOL> dataset = MNIST ( ( '<STR_LIT:test>' , ) , load_in_memory = False ) <EOL> handle = dataset . open ( ) <EOL> data , labels = dataset . get_data ( handle , slice ( <NUM_LIT:0> , <NUM_LIT:10> ) ) <EOL> assert data . dtype == '<STR_LIT>' <EOL> assert data . shape == ( <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) <EOL> assert labels . shape == ( <NUM_LIT:10> , <NUM_LIT:1> ) <EOL> known = numpy . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <EOL> <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> assert_allclose ( data [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:7> ] , known ) <EOL> assert labels [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:7> <EOL> assert dataset . num_examples == <NUM_LIT> <EOL> dataset . close ( handle ) <EOL> stream = DataStream . default_stream ( <EOL> dataset , iteration_scheme = SequentialScheme ( <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> data = next ( stream . get_epoch_iterator ( ) ) [ <NUM_LIT:0> ] <EOL> assert data . min ( ) >= <NUM_LIT:0.0> and data . max ( ) <= <NUM_LIT:1.0> <EOL> assert data . dtype == config . floatX <EOL> def test_mnist_axes ( ) : <EOL> skip_if_not_available ( datasets = [ '<STR_LIT>' ] ) <EOL> dataset = MNIST ( ( '<STR_LIT:train>' , ) , load_in_memory = False ) <EOL> assert_equal ( dataset . axis_labels [ '<STR_LIT>' ] , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:width>' ) ) <EOL> def test_mnist_invalid_split ( ) : <EOL> skip_if_not_available ( datasets = [ '<STR_LIT>' ] ) <EOL> assert_raises ( ValueError , MNIST , ( '<STR_LIT>' , ) ) </s>
