Skip to content

Fixes issue 160 #162

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

Merged
merged 3 commits into from
Mar 5, 2018
Merged

Fixes issue 160 #162

merged 3 commits into from
Mar 5, 2018

Conversation

freddyC
Copy link
Contributor

@freddyC freddyC commented Mar 5, 2018

  • Verified changes
  • Tests, coverage, ran, checked

A GIF or MEME to give some spice of the internet

Description

Because Infinity is not valid json it gets serialized as null. We didn't catch this anywhere because we were

  1. Using specific values in the json tests (not the default Infinity)
  2. Not actually serializing the json object, just using it as a javascript object.

I updated the Neural Network class to handle this when deserializing.

I also updated the tests to both check defaults and serialize the value.

Motivation and Context

issue

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Author's Checklist:

  • My code focuses on the main motivation and avoids scope creep.
  • My code passes current tests and adds new tests where possible.
  • My code is SOLID and DRY.
  • [] I have updated the documentation as needed.

Reviewer's Checklist:

  • I kept my comments to the author positive, specific, and productive.
  • I tested the code and didn't find any new problems.
  • I think the motivation is good for the project.
  • I think the code works to satisfies the motivation.

 - [x] Verified changes
 - [x] Tests, coverage, ran, checked
@@ -830,6 +830,9 @@ export default class NeuralNetwork {
}
}
if (json.hasOwnProperty('trainOpts')) {
if (!json.trainOpts.timeout) {
json.trainOpts.timeout = Infinity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the approach is that it modifies the object being sent into brain. This is where I would have went as well, but it may be more advantagoes to do something like this, so as to ensure we aren't changing any values:

if (json.hasOwnProperty('trainOpts')) {
  this._updateTrainingOptions({
    ...json.trainOpts,
    timeout: json.trainOpts.timeout === null ? Infinity : json.trainOpts.timeout
  });
}

This allows us to handle the exact situation where timeout is parsed to null, and treated as infinity, but has no side effects of altering the object the is sent to us.

 - [x] Verified changes
 - [x] Tests, coverage, ran, checked
@robertleeplummerjr
Copy link
Contributor

🚀 it

@freddyC freddyC merged commit 6900d93 into develop Mar 5, 2018
@freddyC freddyC deleted the 160-infinity-json-fix branch March 5, 2018 18:18
@perkyguy perkyguy removed the review label Mar 5, 2018
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.

4 participants