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

NUP-2506: Add test to all Serializable subclasses and fix related issues #3826

Merged
merged 5 commits into from
Apr 11, 2018

Conversation

lscheinkman
Copy link
Contributor

@rhyolight Please review.
It should fix #3820, #3721, numenta/nupic.core-legacy#1065

Note: This PR depends on numenta/nupic.core-legacy#1417

return anomalyRegion


def write(self, proto):
proto.prevPredictedColumns = self.prevPredictedColumns.tolist()
proto.prevPredictedColumns = self.prevPredictedColumns.ravel().tolist()
Copy link
Member

Choose a reason for hiding this comment

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

🤦‍♂️

Copy link
Member

@rhyolight rhyolight left a comment

Choose a reason for hiding this comment

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

I had a couple comments but no blockers.

if self.currentOutput is not None:
proto.currentOutput = self.currentOutput.tolist()
if self.currentOutput is None:
proto.currentOutput.none = None
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this. Is it a workaround to allow a proto to contain a null value? I see this pattern in several other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a way to handle 'None' in pycapnp. You first create a union with a 'Void' element representing 'None' and then initialize it with 'None'
see https://jparyani.github.io/pycapnp/quickstart.html#unions

@@ -126,7 +126,7 @@ def __init__(self,
# If set to False, Cells4 will *not* be treated as an ephemeral member
# and full BacktrackingTMCPP pickling is possible. This is useful for testing
# pickle/unpickle without saving Cells4 to an external file
self.makeCells4Ephemeral = True
self.makeCells4Ephemeral = False
Copy link
Member

Choose a reason for hiding this comment

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

🤦‍♂️

actual = _getAttributes(serialized)

# Make sure all fields were initialized
self.assertEquals(actual, expected, klass.__name__)
Copy link
Member

Choose a reason for hiding this comment

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

This is a great test.

encoder._prevAbsolute = proto.prevAbsolute
encoder._prevDelta = proto.prevDelta
encoder._prevAbsolute = None if proto.prevAbsolute == 0 else proto.prevAbsolute
encoder._prevDelta = None if proto.prevDelta == 0 else proto.prevDelta
Copy link
Member

Choose a reason for hiding this comment

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

I personally don't think this is a bad change, but I'm curious if it will pass pylint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pylint did not complain about this style

@rhyolight
Copy link
Member

👍 Merge it and I'll release.

@rhyolight rhyolight merged commit 682fd2e into numenta:master Apr 11, 2018
@lscheinkman lscheinkman deleted the NUP-2506 branch April 11, 2018 16:10
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.

Saving and loading a model repeatedly causes it to break
2 participants