@@ -1303,7 +1303,12 @@ mod tests {
13031303 f64 : AsPrimitive < Probability > ,
13041304 i32 : AsPrimitive < Probability > ,
13051305 {
1306+ #[ cfg( not( miri) ) ]
13061307 const AMT : usize = 1000 ;
1308+
1309+ #[ cfg( miri) ]
1310+ const AMT : usize = 100 ;
1311+
13071312 let mut symbols_gaussian = Vec :: with_capacity ( AMT ) ;
13081313 let mut means = Vec :: with_capacity ( AMT ) ;
13091314 let mut stds = Vec :: with_capacity ( AMT ) ;
@@ -1391,21 +1396,24 @@ mod tests {
13911396
13921397 #[ test]
13931398 fn seek ( ) {
1394- const NUM_CHUNKS : usize = 100 ;
1395- const SYMBOLS_PER_CHUNK : usize = 100 ;
1399+ #[ cfg( not( miri) ) ]
1400+ let ( num_chunks, symbols_per_chunk) = ( 100 , 100 ) ;
1401+
1402+ #[ cfg( miri) ]
1403+ let ( num_chunks, symbols_per_chunk) = ( 10 , 10 ) ;
13961404
13971405 let quantizer = DefaultLeakyQuantizer :: new ( -100 ..=100 ) ;
13981406 let model = quantizer. quantize ( Gaussian :: new ( 0.0 , 10.0 ) ) ;
13991407
14001408 let mut encoder = DefaultAnsCoder :: new ( ) ;
14011409
14021410 let mut rng = Xoshiro256StarStar :: seed_from_u64 ( 123 ) ;
1403- let mut symbols = Vec :: with_capacity ( NUM_CHUNKS ) ;
1404- let mut jump_table = Vec :: with_capacity ( NUM_CHUNKS ) ;
1411+ let mut symbols = Vec :: with_capacity ( num_chunks ) ;
1412+ let mut jump_table = Vec :: with_capacity ( num_chunks ) ;
14051413 let ( initial_pos, initial_state) = encoder. pos ( ) ;
14061414
1407- for _ in 0 ..NUM_CHUNKS {
1408- let chunk = ( 0 ..SYMBOLS_PER_CHUNK )
1415+ for _ in 0 ..num_chunks {
1416+ let chunk = ( 0 ..symbols_per_chunk )
14091417 . map ( |_| model. quantile_function ( rng. next_u32 ( ) % ( 1 << 24 ) ) . 0 )
14101418 . collect :: < Vec < _ > > ( ) ;
14111419 encoder. encode_iid_symbols_reverse ( & chunk, & model) . unwrap ( ) ;
@@ -1421,7 +1429,7 @@ mod tests {
14211429 for ( chunk, & ( pos, state) ) in symbols. iter ( ) . zip ( & jump_table) . rev ( ) {
14221430 assert_eq ! ( seekable_decoder. pos( ) , ( pos, state) ) ;
14231431 let decoded = seekable_decoder
1424- . decode_iid_symbols ( SYMBOLS_PER_CHUNK , & model)
1432+ . decode_iid_symbols ( symbols_per_chunk , & model)
14251433 . collect :: < Result < Vec < _ > , _ > > ( )
14261434 . unwrap ( ) ;
14271435 assert_eq ! ( & decoded, chunk)
@@ -1431,11 +1439,11 @@ mod tests {
14311439
14321440 // Seek to some random offsets in the jump table and decode one chunk
14331441 for _ in 0 ..100 {
1434- let chunk_index = rng. next_u32 ( ) as usize % NUM_CHUNKS ;
1442+ let chunk_index = rng. next_u32 ( ) as usize % num_chunks ;
14351443 let ( pos, state) = jump_table[ chunk_index] ;
14361444 seekable_decoder. seek ( ( pos, state) ) . unwrap ( ) ;
14371445 let decoded = seekable_decoder
1438- . decode_iid_symbols ( SYMBOLS_PER_CHUNK , & model)
1446+ . decode_iid_symbols ( symbols_per_chunk , & model)
14391447 . collect :: < Result < Vec < _ > , _ > > ( )
14401448 . unwrap ( ) ;
14411449 assert_eq ! ( & decoded, & symbols[ chunk_index] )
@@ -1458,7 +1466,7 @@ mod tests {
14581466 for ( chunk, & ( pos, state) ) in symbols. iter ( ) . zip ( & jump_table) . rev ( ) {
14591467 assert_eq ! ( seekable_decoder. pos( ) , ( pos, state) ) ;
14601468 let decoded = seekable_decoder
1461- . decode_iid_symbols ( SYMBOLS_PER_CHUNK , & model)
1469+ . decode_iid_symbols ( symbols_per_chunk , & model)
14621470 . collect :: < Result < Vec < _ > , _ > > ( )
14631471 . unwrap ( ) ;
14641472 assert_eq ! ( & decoded, chunk)
@@ -1468,11 +1476,11 @@ mod tests {
14681476
14691477 // Seek to some random offsets in the jump table and decode one chunk each time.
14701478 for _ in 0 ..100 {
1471- let chunk_index = rng. next_u32 ( ) as usize % NUM_CHUNKS ;
1479+ let chunk_index = rng. next_u32 ( ) as usize % num_chunks ;
14721480 let ( pos, state) = jump_table[ chunk_index] ;
14731481 seekable_decoder. seek ( ( pos, state) ) . unwrap ( ) ;
14741482 let decoded = seekable_decoder
1475- . decode_iid_symbols ( SYMBOLS_PER_CHUNK , & model)
1483+ . decode_iid_symbols ( symbols_per_chunk , & model)
14761484 . collect :: < Result < Vec < _ > , _ > > ( )
14771485 . unwrap ( ) ;
14781486 assert_eq ! ( & decoded, & symbols[ chunk_index] )
0 commit comments