<s> from __future__ import absolute_import , division , print_function <EOL> from datashape import dshape <EOL> from odo . chunks import * <EOL> from toolz import first <EOL> CL = chunks ( list ) <EOL> def test_chunks_basics ( ) : <EOL> assert isinstance ( CL , type ) <EOL> assert issubclass ( CL , Chunks ) <EOL> def test_chunks_isnt_consumable ( ) : <EOL> cl = CL ( [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] ] ) <EOL> assert next ( iter ( cl ) ) == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> assert next ( iter ( cl ) ) == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> def test_chunks_is_memoized ( ) : <EOL> assert chunks ( list ) is chunks ( list ) <EOL> def test_callables ( ) : <EOL> cl = CL ( lambda : ( list ( range ( <NUM_LIT:3> ) ) for i in range ( <NUM_LIT:3> ) ) ) <EOL> assert first ( cl ) == [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> assert first ( cl ) == [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> def test_discover ( ) : <EOL> cl = CL ( [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] ] ) <EOL> assert discover ( cl ) . measure == discover ( <NUM_LIT:1> ) . measure <EOL> def test_discover_no_consume ( ) : <EOL> cl = CL ( iter ( ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) ) ) <EOL> assert discover ( cl ) == discover ( cl ) == dshape ( '<STR_LIT>' ) <EOL> assert tuple ( cl ) == ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> assert tuple ( cl ) == ( ) </s>
