Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Values of type Range are iterated over upon serialization #49

Open
cgranade opened this issue Aug 30, 2019 · 2 comments
Open

Values of type Range are iterated over upon serialization #49

cgranade opened this issue Aug 30, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@cgranade
Copy link
Contributor

Describe the bug
When serializing values of type Range as returned by a function or operation, the serializer expands the Range into an array of its values:

image

This is confirmed by looking at the raw JSON saved to the notebook:

   "outputs": [
    {
     "data": {
      "application/json": "[0,1,2,3,4]",
      "text/html": [
       "<ul><li>0</li><li>1</li><li>2</li><li>3</li><li>4</li></ul>"
      ],
      "text/plain": [
       "0, 1, 2, 3, 4"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ]

This makes it impossible to directly call a function or operation that expects a Range as its input from the Python client.

Expected behavior
Range should serialize and deserialize into a JSON schema that is distinct from the JSON schema for Int[].

@anpaz
Copy link
Member

anpaz commented Aug 30, 2019

Range implements IEnumerable, which is why it gets its items serialized. This should be fixed if we add the JsonObject to the class Range , but that would be in qsharp-runtime

@cgranade
Copy link
Contributor Author

Good point, I'll move the issue to the runtime repo, then, and pick it up from there. Thanks!

@cgranade cgranade transferred this issue from microsoft/iqsharp Aug 30, 2019
@bromeg bromeg added the bug Something isn't working label Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants