Skip to content

Commit

Permalink
Fixes copyjson casting bug. (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Oct 14, 2021
1 parent 7ce1bb9 commit 17dcc99
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION_INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
2 changes: 1 addition & 1 deletion src/libawkward/io/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace awkward {
writer.Int64(value.GetInt());
}
else if (value.IsDouble()) {
writer.Int64((int64_t)value.GetDouble());
writer.Double(value.GetDouble());
}
else if (value.IsString()) {
writer.String(value.GetString());
Expand Down
30 changes: 30 additions & 0 deletions tests/test_1114-fix-copyjson-casting-bug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

from __future__ import absolute_import

import json

import pytest # noqa: F401
import numpy as np # noqa: F401
import awkward as ak # noqa: F401


def test():
f = ak.forms.Form.fromjson(
json.dumps(
{
"class": "NumpyArray",
"itemsize": 8,
"format": "d",
"primitive": "float64",
"parameters": {"thing": 1.23},
}
)
)
assert json.loads(repr(f)) == {
"class": "NumpyArray",
"itemsize": 8,
"format": "d",
"primitive": "float64",
"parameters": {"thing": 1.23}, # not 1 (int)
}

0 comments on commit 17dcc99

Please sign in to comment.