Skip to content

Commit 337326d

Browse files
daspecsterlukesneeringer
authored andcommitted
Fix build failing with float precision mismatch (googleapis#3002)
1 parent 0776e23 commit 337326d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

speech/unit_tests/test_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ def test_sync_recognize_with_gax(self):
297297

298298
alternatives = [{
299299
'transcript': 'testing 1 2 3',
300-
'confidence': 0.9224355,
300+
'confidence': 0.740234375,
301301
}, {
302302
'transcript': 'testing 4 5 6',
303-
'confidence': 0.0123456,
303+
'confidence': 0.6396484375,
304304
}]
305305
result = _make_result(alternatives)
306306

@@ -500,19 +500,19 @@ def test_stream_recognize_interim_results(self):
500500

501501
alternatives = [{
502502
'transcript': 'testing streaming 1 2 3',
503-
'confidence': 0.9224355,
503+
'confidence': 0.5888671875,
504504
}, {
505505
'transcript': 'testing streaming 4 5 6',
506-
'confidence': 0.0123456,
506+
'confidence': 0.28125,
507507
}]
508508
first_response = _make_streaming_response(
509-
_make_streaming_result([], is_final=False, stability=0.122435))
509+
_make_streaming_result([], is_final=False, stability=0.314453125))
510510
second_response = _make_streaming_response(
511511
_make_streaming_result(alternatives, is_final=False,
512-
stability=0.1432343))
512+
stability=0.28125))
513513
last_response = _make_streaming_response(
514514
_make_streaming_result(alternatives, is_final=True,
515-
stability=0.9834534))
515+
stability=0.4375))
516516
responses = [first_response, second_response, last_response]
517517

518518
channel_args = []
@@ -542,8 +542,8 @@ def speech_api(channel=None):
542542
self.assertIsInstance(results[0], StreamingSpeechResult)
543543
self.assertEqual(results[0].alternatives, [])
544544
self.assertFalse(results[0].is_final)
545-
self.assertEqual(results[0].stability, 0.122435)
546-
self.assertEqual(results[1].stability, 0.1432343)
545+
self.assertEqual(results[0].stability, 0.314453125)
546+
self.assertEqual(results[1].stability, 0.28125)
547547
self.assertFalse(results[1].is_final)
548548
self.assertEqual(results[1].transcript,
549549
results[1].alternatives[0].transcript,
@@ -556,7 +556,7 @@ def speech_api(channel=None):
556556
self.assertEqual(results[1].alternatives[1].confidence,
557557
alternatives[1]['confidence'])
558558
self.assertTrue(results[2].is_final)
559-
self.assertEqual(results[2].stability, 0.9834534)
559+
self.assertEqual(results[2].stability, 0.4375)
560560
self.assertEqual(results[2].transcript,
561561
results[2].alternatives[0].transcript,
562562
alternatives[0]['transcript'])
@@ -580,10 +580,10 @@ def test_stream_recognize(self):
580580

581581
alternatives = [{
582582
'transcript': 'testing streaming 1 2 3',
583-
'confidence': 0.9224355,
583+
'confidence': 0.4375,
584584
}, {
585585
'transcript': 'testing streaming 4 5 6',
586-
'confidence': 0.0123456,
586+
'confidence': 0.84375,
587587
}]
588588

589589
first_response = _make_streaming_response(

vision/unit_tests/test_annotations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _make_pb_entity():
2323
description = 'testing 1 2 3'
2424
locale = 'US'
2525
mid = 'm/w/45342234'
26-
score = 0.235434231
26+
score = 0.390625
2727

2828
entity_annotation = image_annotator_pb2.EntityAnnotation(
2929
mid=mid,
@@ -108,7 +108,7 @@ def test_it(self):
108108
description = 'testing 1 2 3'
109109
locale = 'US'
110110
mid = 'm/w/45342234'
111-
score = 0.235434231
111+
score = 0.390625
112112
entity_annotation = _make_pb_entity()
113113
entities = self._call_fut([entity_annotation])
114114
self.assertEqual(len(entities), 1)
@@ -183,7 +183,7 @@ def test_it(self):
183183
description = 'testing 1 2 3'
184184
locale = 'US'
185185
mid = 'm/w/45342234'
186-
score = 0.235434231
186+
score = 0.390625
187187
entity_annotation = _make_pb_entity()
188188

189189
image_response = image_annotator_pb2.AnnotateImageResponse(

vision/unit_tests/test_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_logo_pb_annotation(self):
3939
description = 'testing 1 2 3'
4040
locale = 'US'
4141
mid = 'm/w/45342234'
42-
score = 0.235434231
42+
score = 0.875
4343
entity_annotation = image_annotator_pb2.EntityAnnotation()
4444
entity_annotation.mid = mid
4545
entity_annotation.locale = locale

0 commit comments

Comments
 (0)