-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
feat: Added pctChange()
to DataFrame and divNoNan()
to $MathOps
in DataFrame
#418
Conversation
Diff port into working branch for pct_change
Floating points are weird in JS. Will likely need refactor to make tests pass since _functionally_ they work.
pctChange()
to DataFrame and divNoNan()
to $MathOps
in DataFrame
@risenW I can't quite seem to get the TensorFlow functions |
Wonkiness of slight difference in calculation (`0.80000000001234` instead of `0.8` for example) is due to JavaScript. Functionally the tests worked, so I chose divisions that JavaScript does reliably.
Worked around JavaScript's wonkiness in the tests by using divisions that perform more reliably. |
Added unit tests for |
@NeonSpork I just merged the diff PR, and there's a minor conflict here. Can you fix it, or do you want me to? |
Yea the merge conflicts are likely due to me adding the tests in the same spot in the test! I'll go through it and check right away |
Conflicts resolved and checks passed! 👍 |
Structure is similar to
diff()
function, attempted to emulate the functionality frompct_change()
function from pandas.Chose to use camelcase naming here, thusly naming it
pctChange()
.Added function to DataFrame interface.
Added
divNoNan()
from the tensorflow.js math operators to$MathOps
. This was necessary to emulate the functionality from pandas, such that dividing by zero resulted in 0 notInfinity
. Felt that this was a good addition regardless, seeing as it is one of the baseline math operators provided by tensorflow.js itself. As such it was trivial to add. Tensorflow docs here: tf.divNoNan()Added testing. Tests technically work since they return the correct values, but the tests fail since JS is a little bit strange about floating point division.
A possible workaround is to choose calculations that will pass tests, since functionally
pctChange()
is working as expected.