Skip to content
This repository was archived by the owner on Mar 30, 2023. It is now read-only.

Commit 5e2c5c8

Browse files
author
Jason Costello
committed
Serialising numpy ndarrays .tolist()
1 parent e34a2d9 commit 5e2c5c8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

hypervector/resources/core/benchmark.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import requests
23

34
import hypervector
@@ -47,12 +48,20 @@ def list(cls, ensemble):
4748
def new(cls, ensemble, expected_output):
4849
endpoint = f"{hypervector.API_BASE}/definition/{ensemble.definition_uuid}" \
4950
f"/ensemble/{ensemble.ensemble_uuid}/benchmarks/add"
51+
52+
if isinstance(expected_output, np.ndarray):
53+
expected_output = expected_output.tolist()
54+
5055
data = {"expected_output": expected_output}
5156
response = requests.post(endpoint, json=data, headers=cls.get_headers()).json()
5257
return cls.from_response(response)
5358

5459
def assert_equal(self, output_to_assert):
5560
endpoint = f"{hypervector.API_BASE}/benchmark/{self.benchmark_uuid}/assert"
61+
62+
if isinstance(output_to_assert, np.ndarray):
63+
output_to_assert = output_to_assert.tolist()
64+
5665
data = {"output_to_assert": output_to_assert}
5766
response = requests.post(endpoint, json=data, headers=self.get_headers()).json()
5867
return response

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='hypervector-wrapper',
8-
version='0.0.10',
8+
version='0.0.11',
99
description='Python wrapper to use the Hypervector API. Better data tests',
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",
@@ -14,7 +14,8 @@
1414
url="https://github.com/hypervectorio/hypervector-wrapper",
1515
packages=find_packages(exclude=["tests"]),
1616
install_requires=[
17-
"requests ~=2.25.0"
17+
"requests ~=2.25.0",
18+
"numpy ~=1.20.2"
1819
],
1920
extras_require={
2021
"dev": [

0 commit comments

Comments
 (0)