-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Should the Tax-Calculator be 'runnable' without numba? #292
Comments
It turns out that this may be pretty simple. Looking at this section of code: There is a boolean flag
|
@martinholmer, would the enhancement outlined in this issue have made things easier in #467? |
@MattHJensen said:
Honestly, I don't know. My mistake was to assign a value to records.FLPDYR instead of incrementing the array like |
It looked to me like there might have been more useful python traceback info if numba hadn't kicked in. If you were willing to replicate the problem, you could try running things with |
On Wed, 18 Nov 2015, Martin Holmer wrote:
I hope that users of TB won't need to understand numpy to write
The large number of required arguments to functions was the reason I made dan
|
@MattHJensen said:
As I said above, I have fixed my problem (which was caused by my poor understanding of numpy array syntax) and I have moved on. I went back and put in a statement that generates the same Python error traceback as I was getting originally. With
With Here is the error traceback with
This experience left me asking the following questions: (1) Why can't the Python interpreter tell me which of the arguments doesn't have a get_item attribute? It certainly knows that information, otherwise it couldn't raise an error; and (2), Why wasn't the code in decorators.py written with the Python The stupid statement that generates both these error tracebacks is as follows:
which seemed reasonable to a numpy novice who sees statements like this in the code:
I now understand that the correct approach is to write something like this:
You can decide for yourself, but to me these results do not imply that Issue #292 should get a very high priority on scarce resources (at least not now). |
just a couple of quick comments:
which works as follows:
so it is essentially a broadcast operation.
|
@martinholmer thanks for revisiting this issue. It turns out that this discussion is no longer relevant, because I just discovered that in records.py we now have this function: https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/records.py#L609
which is decorated with the cc @MattHJensen |
T.J. said:
The @vectorize decorator was added on June 1, 2015, as part of pull request #279 by mmessick in consultation with you and others on the team. Tax-Calculator was presumably executing just fine before the addition of the @vectorize decorator in the records.py file, so it would seem that we could achieve your goal by dropping it. Is there a noticeable performance hit from removing it? |
On Tue, 12 Apr 2016, Martin Holmer wrote:
More dependencies is not a desirable change. Can't we make numba optional? dan
|
@martinholmer said:
Unfortunatetly, it's not that simple. The vectorize decorator allows one to build a "ufunc" that takes as its arguments numpy arrays, but operates on each element individually in the context of the function. So, one passes a vector quantity, but one treats the incoming arguments as scalar within the function. So if you wrote:
It is essentially the same as:
Except for numba handles type checking, bounds checking, etc., and the iteration is at the C level, not the Python level. So, we'd have to refactor that function to not use numba. With our custom decorator We could re-write the function and use something like @jit which does not suffer from this issue. With |
T.J., I'm not sure I followed every detail of what you just said in issue #292, but I'm in agreement with Dan in that we should strive for fewer hard dependencies and see if we can make the @vectorize or @jit decorator on the function in the Records class optional. Optional like you did for the @iterate_jit decorator in the functions.py file. There is an advantage to be able to debug the slower code. And, as you found in functions.py, turning off the @iterate_jit decorator exposed some things that needed to be fixed. |
This is a good development. With the merge of #754, I can now conclude my work and make |
T.J. (@talumbau) said:
Great! We look forward to a pull request that makes this possible. |
The benefits might be:
After a minute or two of searching, it seems like we could support testing this case using the
env
feature of Travis CI. We would basically just have an extra build environment without numba, so that our test matrix would be: [python 2.7, python 3.4] X [with numba, without numba]http://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix
The text was updated successfully, but these errors were encountered: