Skip to content

Commit

Permalink
Test that extra_data can be encoded and decoded (#27)
Browse files Browse the repository at this point in the history
* Test that extra_data can be encoded and decoded

* I had one line and I messed it up
  • Loading branch information
apockill committed Dec 11, 2020
1 parent 36d30cb commit c3c0bad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vcap/vcap/testing/input_output_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cv2
import mock
import numpy as np
import json

from vcap import (
NodeDescription,
Expand Down Expand Up @@ -156,6 +157,12 @@ def _run_inference_on_images(images: List[np.ndarray], capsule: BaseCapsule):
("Capsule failed to output a prediction that matches "
"the NodeDescription it had for it's output type. "
f"Prediction: {prediction}")

# Assert the nodes "extra_data" attribute can be JSON encoded
# without errors. Typically this can happen if there's a numpy
# array carelessly left in the extra_data
json.loads(json.dumps(output_node.extra_data))

# If this capsule can encode things, verify that the backend
# correctly implemented the "distance" function
if (capsule.capability.encoded
Expand Down

0 comments on commit c3c0bad

Please sign in to comment.