Skip to content

Commit

Permalink
Make region file names snake_case (part 7) (#3640)
Browse files Browse the repository at this point in the history
* NUP-2386 Renamed RecordSensor.py to record_sensor.py, but didn't update the
builtin regions registration to demonstrate failure witnessed by Matt

* NUP-2386 Updated module name of the RecordSensor region in engine/__init__.py to match the renamed module
to demonstrate that the class name of the python region may differ from its module name, as long as it's
registered using the correct module name.

* Removed a comment

* Moved AnomalyRegion.py => anomaly_region.py

* Updated errant AnomalyLikelihoodRegion namespace in docs"

* Moved CLAClassifierRegion.py => cla_classifier_region.py

* Moved KNNAnomalyClassifierRegion.py -> knn_anomaly_classifier_region.py

* Move more regions (snake_case)

    renamed:    src/nupic/regions/KNNClassifierRegion.py ->
src/nupic/regions/knn_classifier_region.py
    renamed:    src/nupic/regions/PluggableEncoderSensor.py ->
src/nupic/regions/pluggable_encoder_sensor.py
    renamed:    src/nupic/regions/SDRClassifierRegion.py ->
src/nupic/regions/sdr_classifier_region.py

* Moved nupic.regions.Spec -> nupic.regions.spec

* Renamed sp and tm regions

    renamed:    src/nupic/regions/SPRegion.py ->
src/nupic/regions/sp_region.py
    renamed:    src/nupic/regions/TMRegion.py ->
src/nupic/regions/tm_region.py

* More region renaming

RecordSensorFilter -> record_sensor_filters
SVMClassifierNode -> svm_classifier_node
TestRegion -> test_region
UnimportableNode -> unimportable_node

* Updated docs readme with new region namespaces
  • Loading branch information
rhyolight authored May 24, 2017
1 parent b372a3c commit acd3e00
Show file tree
Hide file tree
Showing 33 changed files with 59 additions and 59 deletions.
30 changes: 15 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@ nupic
│   ├── stats.py [TODO]
│   └── topology.py [TODO]
├── regions
│   ├── AnomalyLikelihoodRegion.py [OK]
│   ├── AnomalyRegion.py [OK]
│   ├── CLAClassifierRegion.py [TODO]
│   ├── KNNAnomalyClassifierRegion.py [TODO]
│   ├── KNNClassifierRegion.py [TODO]
│   ├── PluggableEncoderSensor.py [TODO]
│   ├── RecordSensor.py [TODO]
│   ├── RecordSensorFilters
│   ├── anomaly_likelihood_region.py [OK]
│   ├── anomaly_region.py [OK]
│   ├── cla_classifier_region.py [TODO]
│   ├── knn_anomaly_classifier_region.py [TODO]
│   ├── knn_classifier_region.py [TODO]
│   ├── pluggable_encoder_sensor.py [TODO]
│   ├── record_sensor.py [TODO]
│   ├── record_sensor_filters
│   │   ├── add_noise.py [TODO]
│   │   └── modify_fields.py [TODO]
│   ├── SDRClassifierRegion.py [TODO]
│   ├── SPRegion.py [TODO]
│   ├── SVMClassifierNode.py [TODO]
│   ├── Spec.py [TODO]
│   ├── TMRegion.py [TODO]
│   ├── TestRegion.py [TODO]
│   └─── UnimportableNode.py [TODO]
│   ├── sdr_classifier_region.py [TODO]
│   ├── sp_region.py [TODO]
│   ├── svm_classifier_node.py [TODO]
│   ├── spec.py [TODO]
│   ├── tm_region.py [TODO]
│   ├── test_region.py [TODO]
│   └─── unimportable_node.py [TODO]
├── serializable.py [TODO]
├── simple_server.py [TODO]
├── support
Expand Down
16 changes: 8 additions & 8 deletions docs/source/api/network/regions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,57 @@ PyRegion
AnomalyRegion
^^^^^^^^^^^^^

.. autoclass:: nupic.regions.AnomalyRegion.AnomalyRegion
.. autoclass:: nupic.regions.anomaly_region.AnomalyRegion
:members:
:show-inheritance:

SPRegion
^^^^^^^^^^^^^

.. autoclass:: nupic.regions.SPRegion.SPRegion
.. autoclass:: nupic.regions.sp_region.SPRegion
:members:
:show-inheritance:

TMRegion
^^^^^^^^^^^^^

.. autoclass:: nupic.regions.TMRegion.TMRegion
.. autoclass:: nupic.regions.tm_region.TMRegion
:members:
:show-inheritance:

AnomalyLikelihoodRegion
^^^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.AnomalyLikelihoodRegion.AnomalyLikelihoodRegion
.. autoclass:: nupic.regions.anomaly_likelihood_region.AnomalyLikelihoodRegion
:members:
:show-inheritance:

CLAClassifierRegion
^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.CLAClassifierRegion.CLAClassifierRegion
.. autoclass:: nupic.regions.cla_classifier_region.CLAClassifierRegion
:members:
:show-inheritance:

KNNAnomalyClassifierRegion
^^^^^^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.KNNAnomalyClassifierRegion.KNNAnomalyClassifierRegion
.. autoclass:: nupic.regions.knn_anomaly_classifier_region.KNNAnomalyClassifierRegion
:members:
:show-inheritance:


KNNClassifierRegion
^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.KNNClassifierRegion.KNNClassifierRegion
.. autoclass:: nupic.regions.knn_classifier_region.KNNClassifierRegion
:members:
:show-inheritance:


SDRClassifierRegion
^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.SDRClassifierRegion.SDRClassifierRegion
.. autoclass:: nupic.regions.sdr_classifier_region.SDRClassifierRegion
:members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/api/network/sensors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Sensors
PluggableEncoderSensor
^^^^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.PluggableEncoderSensor.PluggableEncoderSensor
.. autoclass:: nupic.regions.pluggable_encoder_sensor.PluggableEncoderSensor
:members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/quick-start/network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ classifier region. In our case, we are interested in:
probabilities = classifierRegion.getOutputData("probabilities")
Refer to the documentation of :class:`~nupic.regions.SDRClassifierRegion.SDRClassifierRegion` for
Refer to the documentation of :class:`~nupic.regions.sdr_classifier_region.SDRClassifierRegion` for
more information about output values and their structure.

We'll use the helper function below to extract predictions more easily from
Expand Down
4 changes: 2 additions & 2 deletions examples/network/network_api_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from nupic.data.file_record_stream import FileRecordStream
from nupic.engine import Network
from nupic.encoders import MultiEncoder, ScalarEncoder, DateEncoder
from nupic.regions.SPRegion import SPRegion
from nupic.regions.TMRegion import TMRegion
from nupic.regions.sp_region import SPRegion
from nupic.regions.tm_region import TMRegion

_VERBOSITY = 0 # how chatty the demo should be
_SEED = 1956 # the random seed used throughout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
displaySPCoincidences,
setAttribute,
sensorOpen)
from nupic.regions.RecordSensorFilters.modify_fields import ModifyFields
from nupic.regions.record_sensor_filters.modify_fields import ModifyFields



Expand Down
2 changes: 1 addition & 1 deletion src/nupic/data/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from pkg_resources import resource_filename

from nupic.regions.RecordSensor import RecordSensor
from nupic.regions.record_sensor import RecordSensor
from nupic.data.file_record_stream import FileRecordStream


Expand Down
26 changes: 13 additions & 13 deletions src/nupic/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
pyRegions = (
("nupic.bindings.regions.TestNode", "TestNode"),
("nupic.regions.AnomalyLikelihoodRegion", "AnomalyLikelihoodRegion"),
("nupic.regions.AnomalyRegion", "AnomalyRegion"),
("nupic.regions.CLAClassifierRegion", "CLAClassifierRegion"),
("nupic.regions.KNNAnomalyClassifierRegion", "KNNAnomalyClassifierRegion"),
("nupic.regions.KNNClassifierRegion", "KNNClassifierRegion"),
("nupic.regions.PluggableEncoderSensor", "PluggableEncoderSensor"),
("nupic.regions.anomaly_region", "AnomalyRegion"),
("nupic.regions.cla_classifier_region", "CLAClassifierRegion"),
("nupic.regions.knn_anomaly_classifier_region", "KNNAnomalyClassifierRegion"),
("nupic.regions.knn_classifier_region", "KNNClassifierRegion"),
("nupic.regions.pluggable_encoder_sensor", "PluggableEncoderSensor"),
("nupic.regions.PyRegion", "PyRegion"),
("nupic.regions.RecordSensor", "RecordSensor"),
("nupic.regions.SDRClassifierRegion", "SDRClassifierRegion"),
("nupic.regions.SPRegion", "SPRegion"),
("nupic.regions.SVMClassifierNode", "SVMClassifierNode"),
("nupic.regions.TestRegion", "TestRegion"),
("nupic.regions.TMRegion", "TMRegion"),
("nupic.regions.UnimportableNode", "UnimportableNode"),
("nupic.regions.record_sensor", "RecordSensor"),
("nupic.regions.sdr_classifier_region", "SDRClassifierRegion"),
("nupic.regions.sp_region", "SPRegion"),
("nupic.regions.svm_classifier_node", "SVMClassifierNode"),
("nupic.regions.test_region", "TestRegion"),
("nupic.regions.tm_region", "TMRegion"),
("nupic.regions.unimportable_node", "UnimportableNode"),
)

registeredRegions = False
Expand Down Expand Up @@ -727,7 +727,7 @@ def save(self, *args, **kwargs):
def getRegionsByType(self, regionClass):
"""
Gets all region instances of a given class
(for example, nupic.regions.SPRegion.SPRegion).
(for example, nupic.regions.sp_region.SPRegion).
"""
regions = []

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from nupic.algorithms import anomaly
from nupic.bindings.regions.PyRegion import PyRegion
from KNNClassifierRegion import KNNClassifierRegion
from knn_classifier_region import KNNClassifierRegion
from nupic.bindings.math import Random
from nupic.frameworks.opf.exceptions import (HTMPredictionModelInvalidRangeError,
HTMPredictionModelInvalidArgument)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/integration/nupic/engine/network_checkpoint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import unittest
import numpy

from nupic.regions.SPRegion import SPRegion
from nupic.regions.RecordSensor import RecordSensor
from nupic.regions.sp_region import SPRegion
from nupic.regions.record_sensor import RecordSensor

from network_creation_common import createAndRunNetwork

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/nupic/engine/network_creation_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from nupic.data.file_record_stream import FileRecordStream
from nupic.engine import Network
from nupic.encoders import MultiEncoder, ScalarEncoder, DateEncoder
from nupic.regions.RecordSensor import RecordSensor
from nupic.regions.SPRegion import SPRegion
from nupic.regions.TMRegion import TMRegion
from nupic.regions.record_sensor import RecordSensor
from nupic.regions.sp_region import SPRegion
from nupic.regions.tm_region import TMRegion

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

from nupic.regions.TMRegion import TMRegion
from nupic.regions.tm_region import TMRegion

from network_creation_common import createAndRunNetwork

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/nupic/opf/opf_region_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
from nupic.data.file_record_stream import FileRecordStream
from nupic.encoders import MultiEncoder
from nupic.engine import Network
from nupic.regions.SPRegion import SPRegion
from nupic.regions.TMRegion import TMRegion
from nupic.regions.sp_region import SPRegion
from nupic.regions.tm_region import TMRegion
from nupic.support.unittesthelpers.testcasebase import TestCaseBase

_VERBOSITY = 0 # how chatty the unit tests should be
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/nupic/data/filters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import unittest2 as unittest
from pkg_resources import resource_filename

from nupic.regions.RecordSensor import RecordSensor
from nupic.regions.record_sensor import RecordSensor
from nupic.data.file_record_stream import FileRecordStream
from nupic.encoders import MultiEncoder
from nupic.data.filters import DeltaFilter
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/nupic/engine/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from nupic import engine
from nupic.bindings.regions.TestNode import TestNode
from nupic.regions.SPRegion import SPRegion
from nupic.regions.sp_region import SPRegion



Expand All @@ -45,8 +45,8 @@ def testErrorHandling(self):

orig_import = __import__
def import_mock(name, *args):
if name == "nupic.regions.UnimportableNode":
raise SyntaxError("invalid syntax (UnimportableNode.py, line 5)")
if name == "nupic.regions.unimportable_node":
raise SyntaxError("invalid syntax (unimportable_node.py, line 5)")

return orig_import(name, *args)

Expand All @@ -55,7 +55,7 @@ def import_mock(name, *args):
with self.assertRaises(Exception) as cm:
n.addRegion('r', 'py.UnimportableNode', '')

self.assertEqual(cm.exception.message, "invalid syntax (UnimportableNode.py, line 5)")
self.assertEqual(cm.exception.message, "invalid syntax (unimportable_node.py, line 5)")

# Test failure in the __init__() method
with self.assertRaises(Exception) as cm:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/nupic/regions/anomaly_region_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import numpy

from nupic.regions.AnomalyRegion import AnomalyRegion
from nupic.regions.anomaly_region import AnomalyRegion

try:
import capnp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
TestOptionParser)
from nupic.frameworks.opf.opf_utils import InferenceType

from nupic.regions.KNNAnomalyClassifierRegion import (
from nupic.regions.knn_anomaly_classifier_region import (
KNNAnomalyClassifierRegion,
_CLAClassificationRecord)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/nupic/regions/regions_spec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import unittest2 as unittest

from nupic.regions.Spec import (Spec,
from nupic.regions.spec import (Spec,
InputSpec,
OutputSpec,
ParameterSpec,
Expand Down

0 comments on commit acd3e00

Please sign in to comment.