-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Complete encoder docstrings #3579
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Nice doc. I have a couple of minor comments, mostly about RST styling.
.. autoclass:: nupic.encoders.sdrcategory.SDRCategoryEncoder | ||
:show-inheritance: | ||
|
||
Scalar Encoders | ||
^^^^^^^^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Add missing ^
. The RST linter complains ¯_(ツ)_/¯
src/nupic/encoders/base.py
Outdated
implemented by leaf encoders. Returns :class:`nupic.data.fieldmeta.FieldMetaType`.XXXXX | ||
(e.g., :class:`nupic.data.fieldmeta.FieldMetaType`.float) | ||
implemented by leaf encoders. Returns :class:`~nupic.data.field_meta.FieldMetaType`.XXXXX | ||
(e.g., :class:`~nupic.data.field_meta.FieldMetaType`.float) | ||
- :func:`~nupic.encoders.base.Encoder.getWidth` - returns the output width, in | ||
bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a backslash to indicate that the line continues. It escapes the newline character instead of breaking the block in the HTML rendering. Examples:
Edits in nupic/encoders/base.py
to fix the newline issue (I just added trailing \
's where needed):
class Encoder(object):
"""
An encoder converts a value to a sparse distributed representation.
This is the base class for encoders that are compatible with the OPF. The OPF
requires that values can be represented as a scalar value for use in places
like the SDR Classifier.
.. note:: The Encoder superclass implements:
- :func:`~nupic.encoders.base.Encoder.encode` - returns a numpy array \
encoding the input; syntactic sugar on top of encodeIntoArray. If pprint, \
prints the encoding to the terminal.
- :func:`~nupic.encoders.base.Encoder.pprintHeader` - prints a header \
describing the encoding to the terminal.
- :func:`~nupic.encoders.base.Encoder.pprint` - prints an encoding to the \
terminal.
.. warning:: The following methods and properties must be implemented by \
subclasses:
- :func:`~nupic.encoders.base.Encoder.getDecoderOutputFieldTypes` - must be \
implemented by leaf encoders. \
Returns :class:`~nupic.data.field_meta.FieldMetaType`.XXXXX \
(e.g., :class:`~nupic.data.field_meta.FieldMetaType`.float)
- :func:`~nupic.encoders.base.Encoder.getWidth` - returns the output width, \
in bits.
- :func:`~nupic.encoders.base.Encoder.encodeIntoArray` - encodes input and \
puts the encoded value into the numpy output array, which is a 1-D array \
of length returned by :func:`~nupic.encoders.base.Encoder.getWidth`.
- :func:`~nupic.encoders.base.Encoder.getDescription` - returns a list of \
(name, offset) pairs describing the encoded output.
"""
Ref of a similar issue for another block type: http://stackoverflow.com/a/28328736
|
||
TODO: when we switch to Python 2.7 or 3.x, use OrderedDict | ||
TODO: when we switch to Python 2.7 or 3.x, use OrderedDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a TODO extension that you might be interested in.
Ref 1: https://thomas-cokelaer.info/tutorials/sphinx/rest_syntax.html#todo-extension
Ref 2: http://www.sphinx-doc.org/en/1.0.8/ext/todo.html
src/nupic/encoders/base.py
Outdated
""" | ||
raise NotImplementedError() | ||
|
||
|
||
def encodeIntoArray(self, inputData, output): | ||
""" | ||
Encodes inputData and puts the encoded value into the numpy output array, | ||
which is a 1-D array of length returned by getWidth(). | ||
which is a 1-D array of length returned by :meth:`.getWidth`. | ||
|
||
Note: The numpy output array is reused, so clear it before updating it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using .. note::
of the arrays, and we should start our counting from 1 rather than 0 | ||
Copy one array to another, inserting blanks between fields (for display). | ||
If ``leftpad`` is one, then there is a dummy value at element 0 | ||
of the arrays, and we should start our counting from 1 rather than 0. | ||
|
||
:param inarray: TODO: document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep the TODO: document
that remain here and there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've asked @scottpurdy for help with this.
src/nupic/encoders/base.py
Outdated
of the inputData with the scalar value returned from topDownCompute() on a | ||
top-down representation to evaluate prediction accuracy, for example. | ||
of the inputData with the scalar value returned from :meth:`.topDownCompute` | ||
on a top-down representation to evaluate prediction accuracy, for example. | ||
|
||
:param inputData: The data from the source. This is typically a object with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: This is typically an
object
Thanks @marionleborgne I will fix these up and merge. |
Complete
Fixes #3552