Skip to content

Commit

Permalink
Merge pull request numenta#2046 from oxtopus/issue-2045-cleanup-geosp…
Browse files Browse the repository at this point in the history
…atial-unit-tests

Cleanup geospatial coordinate encoder unit tests
  • Loading branch information
rhyolight committed May 6, 2015
2 parents aebde4d + 6880290 commit ede6b1a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/unit/nupic/encoders/geospatial_coordinate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def testEncodeIntoArrayAltitude(self):
overlap1 = overlap(encoding1, encoding2)
overlap2 = overlap(encoding1, encoding3)

self.assertTrue(overlap1 > overlap2)
self.assertGreater(overlap1, overlap2)


def testEncodeIntoArray3D(self):
Expand All @@ -151,16 +151,16 @@ def testEncodeIntoArray3D(self):
overlap1 = overlap(encoding1, encoding2)
overlap2 = overlap(encoding1, encoding3)

self.assertTrue(overlap1 > overlap2)
self.assertGreater(overlap1, overlap2)


def testReadWrite(self):
scale = 30 # meters
timestep = 60 # seconds
speed = 2.5 # meters per second
original = GeospatialCoordinateEncoder(scale, timestep, n=999, w=25)
encoding1 = encode(original, speed, -122.229194, 37.486782, 0)
encoding2 = encode(original, speed, -122.229294, 37.486882, 100)
encode(original, speed, -122.229194, 37.486782, 0)
encode(original, speed, -122.229294, 37.486882, 100)

proto1 = GeospatialCoordinateEncoderProto.new_message()
original.write(proto1)
Expand Down Expand Up @@ -190,6 +190,7 @@ def encode(encoder, speed, longitude, latitude, altitude=None):
encoder.encodeIntoArray((speed, longitude, latitude, altitude), output)
return output


def overlap(sdr1, sdr2):
assert sdr1.size == sdr2.size
return float((sdr1 & sdr2).sum()) / sdr1.sum()
Expand Down

0 comments on commit ede6b1a

Please sign in to comment.