Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

from chemreac.util.pyutil import set_dict_defaults_inplace, monotonic 

 

 

def test_set_dict_defaults_inplace(): 

    d1 = {} 

    set_dict_defaults_inplace(d1, {}, {}) 

    assert d1 == {} 

 

    d2 = {} 

    set_dict_defaults_inplace(d2, {1: 2}, {1: 4, 2: 8}) 

    assert d2 == {1: 4, 2: 8} 

 

    d3 = {} 

    set_dict_defaults_inplace(d3, {1: 2}) 

    assert d3 == {1: 2} 

 

    d4 = {1: 1, 2: 4} 

    set_dict_defaults_inplace( 

        d4, {2: 8, 3: 27}, {3: 81, 4: 256}) 

    assert d4 == {1: 1, 2: 4, 3: 81, 4: 256} 

 

 

def test_monotonic(): 

    assert monotonic([0, 1, 2]) 

    assert monotonic([0, -1, -2]) 

    assert not monotonic([0, -1, -2, 3]) 

    assert monotonic([0, -1, -2, -3], strict=True) 

    assert not monotonic([0, 1, 2, 3, 3], strict=True) 

    assert not monotonic([0, -1, -2], 1) 

    assert monotonic([0, -1, -2, -3], -1)