Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate read_csv args into read_egg_csv #794

Merged
merged 1 commit into from
Jun 17, 2016

Conversation

talumbau
Copy link
Member

No description provided.

@talumbau
Copy link
Member Author

This PR changes _read_egg_csv so that it can take additional keyword arguments for the Pandas read_csv function. In particular, we need to pass through the index_col="YEAR" argument when reading the blowup factors.

Discovered this issue when doing integrating testing with the webapp and dropq.

@codecov-io
Copy link

codecov-io commented Jun 17, 2016

Current coverage is 97.73%

Merging #794 into master will not change coverage

@@             master       #794   diff @@
==========================================
  Files            12         12          
  Lines          1763       1763          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           1723       1723          
  Misses           40         40          
  Partials          0          0          

Powered by Codecov. Last updated by d7cff8d...8cc219f

@martinholmer
Copy link
Collaborator

I don't understand these changes.
In particular, I don't understand the vague and mysterious use of **kwargs? Why not just make the following change in the Records._read_egg_csv method?

-            vname_dict = pd.read_csv(vname_fname)
+            vname_dict = pd.read_csv(vname_fname, index_col='YEAR')

Won't that do what you want?

@talumbau
Copy link
Member Author

_read_egg_csv is used in two places. In the call at this line:

https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/records.py#L514

we need to read a CSV file with pandas.read_csv and not pass in the index_col="YEAR" keyword argument. In the call at this line:

https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/records.py#L491

we do need the call. This occurred when you did refactoring with this commit:

86c5b6c

I think the refactoring was nice. Essentially, we had two very similar chunks of code, so you created one function out of it with two calls. As you can see in the commit 86c5b6c
, the calls to pd.read_csv were not identical. So, this PR changes _read_egg_csv to allow "pass-through" arguments to the pandas function. That way, the caller of _read_egg_csv determines what arguments to give to pandas read_csv instead of it being hard-coded in the function.

@talumbau
Copy link
Member Author

So to be explicit:

Why not just make the following change in the Records._read_egg_csv method?

  •        vname_dict = pd.read_csv(vname_fname)
    
  •        vname_dict = pd.read_csv(vname_fname, index_col='YEAR')
    
    Won't that do what you want?

No, it won't because of the two calls to _read_egg_csv.

@martinholmer
Copy link
Collaborator

T.J. (@talumbau), Thanks for the gentle and thorough explanation of my mistake in commit 86c5b6c.

@martinholmer
Copy link
Collaborator

@talumbau, Thanks for fixing my mistake.

@martinholmer martinholmer merged commit ba07d6a into PSLmodels:master Jun 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants