本文整理汇总了Python中nupic.encoders.geospatial_coordinate.GeospatialCoordinateEncoder类的典型用法代码示例。如果您正苦于以下问题:Python GeospatialCoordinateEncoder类的具体用法?Python GeospatialCoordinateEncoder怎么用?Python GeospatialCoordinateEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeospatialCoordinateEncoder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRadiusForSpeed
def testRadiusForSpeed(self):
scale = 30 # meters
timestep = 60 #seconds
speed = 50 # meters per second
encoder = GeospatialCoordinateEncoder(scale, timestep)
radius = encoder.radiusForSpeed(speed)
self.assertEqual(radius, 75)
示例2: testCoordinateForPosition3D
def testCoordinateForPosition3D(self):
scale = 30 # meters
encoder = GeospatialCoordinateEncoder(scale, 60)
coordinate = encoder.coordinateForPosition(
-122.229194, 37.486782, 1500
)
self.assertEqual(coordinate.tolist(), [-90102, -142918, 128710])
示例3: testCoordinateForPosition
def testCoordinateForPosition(self):
scale = 30 # meters
encoder = GeospatialCoordinateEncoder(scale, 60)
coordinate = encoder.coordinateForPosition(
-122.229194, 37.486782
)
self.assertEqual(coordinate.tolist(), [-453549, 150239])
示例4: testReadWrite
def testReadWrite(self):
scale = 30 # meters
timestep = 60 # seconds
speed = 2.5 # meters per second
original = GeospatialCoordinateEncoder(scale, timestep, n=999, w=25)
encode(original, speed, -122.229194, 37.486782, 0)
encode(original, speed, -122.229294, 37.486882, 100)
proto1 = GeospatialCoordinateEncoderProto.new_message()
original.write(proto1)
# Write the proto to a temp file and read it back into a new proto
with tempfile.TemporaryFile() as f:
proto1.write(f)
f.seek(0)
proto2 = GeospatialCoordinateEncoderProto.read(f)
encoder = GeospatialCoordinateEncoder.read(proto2)
self.assertIsInstance(encoder, GeospatialCoordinateEncoder)
self.assertEqual(encoder.w, original.w)
self.assertEqual(encoder.n, original.n)
self.assertEqual(encoder.name, original.name)
self.assertEqual(encoder.verbosity, original.verbosity)
# Compare a new value with the original and deserialized.
encoding3 = encode(original, speed, -122.229294, 37.486982, 1000)
encoding4 = encode(encoder, speed, -122.229294, 37.486982, 1000)
self.assertTrue(np.array_equal(encoding3, encoding4))
示例5: testRadiusForSpeedInt
def testRadiusForSpeedInt(self):
"""Test that radius will round to the nearest integer"""
scale = 30 # meters
timestep = 62 #seconds
speed = 25 # meters per second
encoder = GeospatialCoordinateEncoder(scale, timestep)
radius = encoder.radiusForSpeed(speed)
self.assertEqual(radius, 38)
示例6: testCoordinateForPositionOrigin3D
def testCoordinateForPositionOrigin3D(self):
scale = 1 # meters
encoder = GeospatialCoordinateEncoder(scale, 60)
coordinate = encoder.coordinateForPosition(0,0,0)
# see WGS80 defining parameters (semi-major axis) on
# http://en.wikipedia.org/wiki/Geodetic_datum#Parameters_for_some_geodetic_systems
self.assertEqual(coordinate.tolist(), [6378137, 0, 0])
示例7: testRadiusForSpeed0
def testRadiusForSpeed0(self):
scale = 30 # meters
timestep = 60 #seconds
speed = 0 # meters per second
n = 999
w = 27
encoder = GeospatialCoordinateEncoder(scale, timestep, n=n, w=w)
radius = encoder.radiusForSpeed(speed)
self.assertEqual(radius, 3)
示例8: testCoordinateForPositionOrigin
def testCoordinateForPositionOrigin(self):
scale = 30 # meters
encoder = GeospatialCoordinateEncoder(scale, 60)
coordinate = encoder.coordinateForPosition(0, 0)
self.assertEqual(coordinate.tolist(), [0, 0])