PSLmodels / OG-UK

An overlapping generations model to simulate fiscal policy the United Kingdom.
https://pslmodels.github.io/OG-UK
Other
6 stars 7 forks source link

Changes to work with OG-Core #23

Closed jdebacker closed 3 years ago

jdebacker commented 3 years ago

This PR updates the OG-UK package to work with the lates API changes to OG-Core from PR #725.

CI tests will not pass on GH Actions until OG-Core PR #725 is merged into master.

jdebacker commented 3 years ago

This branch runs through the full run_oguk.py script on my machine when using the branch of OG-USA from PR #725.

cc @rickecon

jdebacker commented 3 years ago

@nikhilwoodruff Can you comment on the following test failure:

================================== FAILURES ===================================
16
___________________________________ test_frs ___________________________________
17

18
    def test_frs():
19
        """
20
        Check that setting `data` to 'frs' uses cps data
21
        """
22
        baseline = False
23
        start_year = 2016
24

25
        # create a parametric reform
26
        def lower_pa(parameters):
27
            parameters.tax.income_tax.allowances.personal_allowance.amount.update(
28
                period="2020", value=10000
29
            )
30
            return parameters
31

32
        class lower_personal_tax_allowance(Reform):
33
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/pep8.py:110: FutureWarning: Possible nested set at position 1
34
  EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
35
            def apply(self):
36
                self.modify_parameters(modifier_function=lower_pa)
37

38
        reform = lower_personal_tax_allowance
39

40
>       calc_out = get_micro_data.get_calculator_output(
41
            baseline, start_year, reform=reform, data="frs"
42
        )
43

44
oguk/tests/test_get_micro_data.py:46: 
45
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
46
oguk/get_micro_data.py:46: in get_calculator_output
47
    sim = Microsimulation(*(reform,), year=year)
48
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/openfisca_uk/tools/simulation.py:226: in __init__
49
    self.load_dataset(dataset, self.year)
50
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/openfisca_uk/tools/simulation.py:329: in load_dataset
51
    data = dataset.load(year)
52
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/openfisca_uk_data/utils.py:61: in load
53
    return h5py.File(file)
54
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/h5py/_hl/files.py:444: in __init__
55
    fid = make_fid(name, mode, userblock_size,
56
/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/h5py/_hl/files.py:199: in make_fid
57
    fid = h5f.open(name, flags, fapl=fapl)
58
h5py/_objects.pyx:54: in h5py._objects.with_phil.wrapper
59
    ???
60
h5py/_objects.pyx:55: in h5py._objects.with_phil.wrapper
61
    ???
62
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
63

64
>   ???
65
E   FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '/usr/share/miniconda/envs/oguk-calibrate-dev/lib/python3.8/site-packages/openfisca_uk_data/microdata/openfisca_uk/frs_2016.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
66

67
h5py/h5f.pyx:100: FileNotFoundError

I've removed the frs package as a dependency because I thought the data were included in OpenFisca-UK, but something's not right...

nikhilwoodruff commented 3 years ago

@jdebacker looks like it's because of the start year - can we move it forward to 2018? (Assuming it's OK for me to change this just to see if the test passes)

nikhilwoodruff commented 3 years ago

Now seems to be getting hung up on a taxcalc dependency...

jdebacker commented 3 years ago

Thanks @nikhilwoodruff . Lets let this PR site until OG-USA PR #733 is done -- that removes the taxcalc dependency from OG-Core.

codecov[bot] commented 3 years ago

Codecov Report

Merging #23 (5cec986) into main (8e3f40f) will increase coverage by 2.22%. The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   52.15%   54.38%   +2.22%     
==========================================
  Files           6        4       -2     
  Lines         765      114     -651     
==========================================
- Hits          399       62     -337     
+ Misses        366       52     -314     
Flag Coverage Δ
unittests 54.38% <61.53%> (+2.22%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
setup.py 0.00% <ø> (ø)
oguk/tests/test_run_example.py 33.33% <37.50%> (ø)
oguk/get_micro_data.py 58.13% <100.00%> (ø)
oguk/tests/test_get_micro_data.py 84.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 36a34f3...5cec986. Read the comment docs.