Skip to content

Commit

Permalink
updated __init__.py to include missing encoders (#3487)
Browse files Browse the repository at this point in the history
* updated __init__.py to include missing encoders

* updated tests and refactored multi.py

* fixed base encoder import

* yep

* Fixed encoder imports after name changes

* Fixed encoder import styling.
  • Loading branch information
JonnoFTW authored and rhyolight committed May 22, 2017
1 parent 6ce2f6f commit 99856ea
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 29 deletions.
4 changes: 3 additions & 1 deletion src/nupic/encoders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# ----------------------------------------------------------------------

from scalar import ScalarEncoder
from random_distributed_scalar import RandomDistributedScalarEncoder
from adaptive_scalar import AdaptiveScalarEncoder
from date import DateEncoder
from logarithm import LogEncoder
Expand All @@ -29,7 +30,8 @@
from scalar_space import ScalarSpaceEncoder
from coordinate import CoordinateEncoder
from geospatial_coordinate import GeospatialCoordinateEncoder
from nupic.encoders.pass_through import PassThroughEncoder
from pass_through import PassThroughEncoder
from sparse_pass_through import SparsePassThroughEncoder
# multiencoder must be imported last because it imports * from this module!
from multi import MultiEncoder
from utils import bitsToString
2 changes: 1 addition & 1 deletion src/nupic/encoders/geospatial_coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import numpy
from pyproj import Proj, transform
from nupic.encoders.coordinate import CoordinateEncoder
from nupic.encoders import CoordinateEncoder



Expand Down
2 changes: 1 addition & 1 deletion src/nupic/encoders/logarithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from nupic.data import SENTINEL_VALUE_FOR_MISSING_DATA
from nupic.data.field_meta import FieldMetaType
from nupic.encoders.base import Encoder, EncoderResult
from nupic.encoders.scalar import ScalarEncoder
from nupic.encoders import ScalarEncoder


class LogEncoder(Encoder):
Expand Down
34 changes: 15 additions & 19 deletions src/nupic/encoders/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,18 @@
# ----------------------------------------------------------------------

from nupic.encoders.base import Encoder
from nupic.encoders.scalar import ScalarEncoder
from nupic.encoders.adaptive_scalar import AdaptiveScalarEncoder
from nupic.encoders.date import DateEncoder
from nupic.encoders.logarithm import LogEncoder
from nupic.encoders.category import CategoryEncoder
from nupic.encoders.sdr_category import SDRCategoryEncoder
from nupic.encoders.delta import DeltaEncoder
from nupic.encoders.scalar_space import ScalarSpaceEncoder
from nupic.encoders.pass_through import PassThroughEncoder
from nupic.encoders.sparse_pass_through import SparsePassThroughEncoder
from nupic.encoders.coordinate import CoordinateEncoder
from nupic.encoders.geospatial_coordinate import GeospatialCoordinateEncoder
# multiencoder must be imported last because it imports * from this module!
from nupic.encoders.utils import bitsToString
from nupic.encoders.random_distributed_scalar import RandomDistributedScalarEncoder

from nupic.encoders import (ScalarEncoder,
AdaptiveScalarEncoder,
DateEncoder,LogEncoder,
CategoryEncoder,
SDRCategoryEncoder,
DeltaEncoder,
ScalarSpaceEncoder,
PassThroughEncoder,
SparsePassThroughEncoder,
CoordinateEncoder,
GeospatialCoordinateEncoder,
RandomDistributedScalarEncoder)


# Map class to Cap'n Proto schema union attribute
Expand All @@ -50,13 +46,13 @@
DeltaEncoder: "deltaEncoder",
PassThroughEncoder: "passThroughEncoder",
SparsePassThroughEncoder: "sparsePassThroughEncoder",
GeospatialCoordinateEncoder: "geospatialCoordinateEncoder",
ScalarSpaceEncoder: "scalarSpaceEncoder",
RandomDistributedScalarEncoder: "randomDistributedScalarEncoder"
}

# Invert for fast lookup in MultiEncoder.read()
_ATTR_CLASS_MAP = {value:key for key, value in _CLASS_ATTR_MAP.items()}


_ATTR_CLASS_MAP = {value: key for key, value in _CLASS_ATTR_MAP.items()}


class MultiEncoder(Encoder):
Expand Down
4 changes: 2 additions & 2 deletions src/nupic/encoders/scalar_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# http://numenta.org/licenses/
# ----------------------------------------------------------------------
from nupic.encoders.base import Encoder
from nupic.encoders.delta import DeltaEncoder
from nupic.encoders.adaptive_scalar import AdaptiveScalarEncoder
from nupic.encoders import (DeltaEncoder,
AdaptiveScalarEncoder)


class ScalarSpaceEncoder(Encoder):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/nupic/encoders/pass_through_encoder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import numpy

from nupic.encoders.pass_through import PassThroughEncoder
from nupic.encoders import PassThroughEncoder

try:
import capnp
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/nupic/encoders/random_distributed_scalar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
from nupic.data import SENTINEL_VALUE_FOR_MISSING_DATA
from nupic.data.field_meta import FieldMetaType
from nupic.support.unittesthelpers.algorithm_test_helpers import getSeed
from nupic.encoders.random_distributed_scalar import (
RandomDistributedScalarEncoder
)
from nupic.encoders import RandomDistributedScalarEncoder

try:
import capnp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import numpy

from nupic.encoders.sparse_pass_through import SparsePassThroughEncoder
from nupic.encoders import SparsePassThroughEncoder


try:
Expand Down

0 comments on commit 99856ea

Please sign in to comment.