Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
DEVOPS-353: Fix tests to run with nupic.core directly instead of nupic
Browse files Browse the repository at this point in the history
  • Loading branch information
lscheinkman committed Mar 6, 2018
1 parent 9ae6155 commit 4e800a6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bindings/py/tests/sparse_link_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np
import numpy.testing
from nupic.bindings.regions.PyRegion import PyRegion
from nupic.engine import Network
import nupic.bindings.engine_internal as engine

TEST_DATA_SPARSE = np.array([4, 7])
MAX_ACTIVE = TEST_DATA_SPARSE.size
Expand Down Expand Up @@ -170,7 +170,7 @@ def getOutputElementCount(self, name):

def createNetwork(fromRegion, toRegion):
"""Create test network"""
network = Network()
network = engine.Network()
config = str({"maxActive": MAX_ACTIVE, "outputWidth": OUTPUT_WIDTH})
network.addRegion("from", fromRegion, config)
network.addRegion("to", toRegion, config)
Expand All @@ -185,16 +185,17 @@ class SparseLinkTest(unittest.TestCase):

def setUp(self):
"""Register test regions"""
Network.registerPyRegion(SparseRegion.__module__, SparseRegion.__name__)
Network.registerPyRegion(DenseRegion.__module__, DenseRegion.__name__)
engine.Network.registerPyRegion(SparseRegion.__module__, SparseRegion.__name__)
engine.Network.registerPyRegion(DenseRegion.__module__, DenseRegion.__name__)

def testSparseToSparse(self):
"""Test links between sparse to sparse"""
net = createNetwork("py.SparseRegion", "py.SparseRegion")
net.initialize()
net.run(1)

actual = net.regions["to"].getOutputData("dataOut")
region = net.getRegions().getByName("to")
actual = region.getOutputArray("dataOut")
np.testing.assert_array_equal(actual, TEST_DATA_SPARSE)

def testSparseToDense(self):
Expand All @@ -203,7 +204,8 @@ def testSparseToDense(self):
net.initialize()
net.run(1)

actual = net.regions["to"].getOutputData("dataOut")
region = net.getRegions().getByName("to")
actual = region.getOutputArray("dataOut")
np.testing.assert_array_equal(actual, TEST_DATA_DENSE)

def testDenseToSparse(self):
Expand All @@ -212,7 +214,8 @@ def testDenseToSparse(self):
net.initialize()
net.run(1)

actual = net.regions["to"].getOutputData("dataOut")
region = net.getRegions().getByName("to")
actual = region.getOutputArray("dataOut")
np.testing.assert_array_equal(actual, TEST_DATA_SPARSE)

def testDenseToDense(self):
Expand All @@ -221,7 +224,8 @@ def testDenseToDense(self):
net.initialize()
net.run(1)

actual = net.regions["to"].getOutputData("dataOut")
region = net.getRegions().getByName("to")
actual = region.getOutputArray("dataOut")
np.testing.assert_array_equal(actual, TEST_DATA_DENSE)


Expand Down

0 comments on commit 4e800a6

Please sign in to comment.