Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/bson_binary_vector/float32.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
"description": "Infinity Vector FLOAT32",
"valid": true,
"vector": ["-inf", 0.0, "inf"],
"vector": [{"$numberDouble": "-Infinity"}, 0.0, {"$numberDouble": "Infinity"} ],
"dtype_hex": "0x27",
"dtype_alias": "FLOAT32",
"padding": 0,
Expand Down
8 changes: 2 additions & 6 deletions test/test_bson_binary_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

import binascii
import codecs
import json
import struct
from pathlib import Path
from test import unittest

from bson import decode, encode
from bson import decode, encode, json_util
from bson.binary import Binary, BinaryVectorDtype

_TEST_PATH = Path(__file__).parent / "bson_binary_vector"
Expand Down Expand Up @@ -62,9 +61,6 @@ def run_test(self):
cB_exp = binascii.unhexlify(canonical_bson_exp.encode("utf8"))
decoded_doc = decode(cB_exp)
binary_obs = decoded_doc[test_key]
# Handle special float cases like '-inf'
if dtype_exp in [BinaryVectorDtype.FLOAT32]:
vector_exp = [float(x) for x in vector_exp]

# Test round-tripping canonical bson.
self.assertEqual(encode(decoded_doc), cB_exp, description)
Expand Down Expand Up @@ -104,7 +100,7 @@ def run_test(self):
def create_tests():
for filename in _TEST_PATH.glob("*.json"):
with codecs.open(str(filename), encoding="utf-8") as test_file:
test_method = create_test(json.load(test_file))
test_method = create_test(json_util.loads(test_file.read()))
setattr(TestBSONBinaryVector, "test_" + filename.stem, test_method)


Expand Down
Loading