Flash "CurveTo" and "LineTo" in Shapes - c++

I'm working in trying to display some old SWF files with Direct2D.
I found swfmill which, for a simple SWF (found here) that displays a "W"
produces XML code, part of which is this one:
<ShapeSetup x="-214" y="470" fillStyle1="1"/>
<LineTo x="-20" y="0"/>
<CurveTo x1="-35" y1="-74" x2="-45" y2="-109"/>
<CurveTo x1="-46" y1="-109" x2="-109" y2="-244"/>
<CurveTo x1="-110" y1="-244" x2="-32" y2="-50"/>
<CurveTo x1="-33" y1="-50" x2="-27" y2="-18"/>
<CurveTo x1="-27" y1="-19" x2="-21" y2="-3"/>
<CurveTo x1="-21" y1="-1" x2="0" y2="-9"/>
<CurveTo x1="0" y1="-10" x2="53" y2="0"/>
<LineTo x="304" y="0"/>
<CurveTo x1="43" y1="0" x2="0" y2="10"/>
<CurveTo x1="0" y1="10" x2="-24" y2="0"/>
<CurveTo x1="-100" y1="6" x2="0" y2="70"/>
<CurveTo x1="0" y1="16" x2="8" y2="27"/>
<CurveTo x1="8" y1="27" x2="100" y2="229"/>
<CurveTo x1="99" y1="229" x2="59" y2="120"/>
<CurveTo x1="22" y1="-56" x2="73" y2="-216"/>
<CurveTo x1="72" y1="-215" x2="14" y2="-56"/>
<CurveTo x1="-53" y1="-131" x2="-24" y2="-21"/>
<CurveTo x1="-24" y1="-22" x2="-41" y2="-7"/>
<CurveTo x1="-29" y1="-1" x2="0" y2="-9"/>
<CurveTo x1="0" y1="-10" x2="52" y2="0"/>
<LineTo x="305" y="0"/>
<CurveTo x1="28" y1="0" x2="7" y2="2"/>
<CurveTo x1="8" y1="2" x2="0" y2="6"/>
<CurveTo x1="0" y1="6" x2="-40" y2="4"/>
<CurveTo x1="-84" y1="13" x2="0" y2="68"/>
<CurveTo x1="0" y1="106" x2="234" y2="531"/>
<CurveTo x1="46" y1="-116" x2="44" y2="-123"/>
<LineTo x="80" y="-220"/>
<CurveTo x1="35" y1="-97" x2="4" y2="-25"/>
<CurveTo x1="5" y1="-25" x2="0" y2="-21"/>
<CurveTo x1="0" y1="-89" x2="-85" y2="-2"/>
<CurveTo x1="-19" y1="0" x2="0" y2="-10"/>
<CurveTo x1="0" y1="-6" x2="6" y2="-2"/>
<CurveTo x1="6" y1="-2" x2="28" y2="0"/>
<LineTo x="165" y="0"/>
<CurveTo x1="74" y1="0" x2="10" y2="2"/>
<CurveTo x1="11" y1="1" x2="0" y2="9"/>
<CurveTo x1="0" y1="8" x2="-16" y2="0"/>
<CurveTo x1="-74" y1="6" x2="-43" y2="83"/>
<CurveTo x1="-42" y1="83" x2="-154" y2="449"/>
<CurveTo x1="-81" y1="235" x2="-27" y2="64"/>
<LineTo x="-21" y="0"/>
<CurveTo x1="-58" y1="-160" x2="-55" y2="-132"/>
<CurveTo x1="-54" y1="-132" x2="-100" y2="-257"/>
<LineTo x="-229" y="681"/>
<ShapeSetup/>
I'm not sure how to interpret this shape.
What I've tried:
I tried with a ID2D1PathGeometry and BeginFigure (for the ShapeSetup),
AddLine (for each LineTo),
AddQuadraticBezier (for each CurveTo) but the result is this:
I realized that I must combine some geometries but I'm not sure how. A spec I found here says:
FillStyle0 and FillStyle1 The Adobe Flash authoring tool supports two fill styles per edge, one for each side of the edge: FillStyle0 and
FillStyle1.
For shapes that don’t self-intersect or overlap,
FillStyle0 should be used.
For overlapping shapes the situation is more complex. For example, if a shape consists of two overlapping squares, and only FillStyle0 is defined, Flash Player renders a ‘hole’ where the paths overlap. This area can be filled using FillStyle1. In this situation, the rule is that for any directed vector, FillStyle0 is the color to the left
of the vector, and FillStyle1 is the color to
the right of the vector
Is there anyone that understands how that shape should be drawn?

Probably, coordinates are all relative. So you need to calculate positions incrementally.
For example,
<ShapeSetup x="-214" y="470" fillStyle1="1"/>
<LineTo x="-20" y="0"/>
<CurveTo x1="-35" y1="-74" x2="-45" y2="-109"/>
:
are to be translated to
pSink->BeginFigure(D2D1::Point2F(-214, 470), D2D1_FIGURE_BEGIN_FILLED);
pSink->AddLine(D2D1::Point2F(-234, 470)); // -214, 470 + (-20, 0)
D2D1_QUADRATIC_BEZIER_SEGMENT seg = {
D2D1::Point2F(-269, 396), // -234, 470 + (-35,-74)
D2D1::Point2F(-314, 287) // -269, 396 + (-45,-109)
};
pSink->AddQuadraticBezier(&seg);
:
Appendix
Testing it in XAML or SVG path-data form,
M -214,470
l -20, 0
q -35,-74 -80,-183
q -46,-109 -155,-353
q -110,-244 -142,-294
q -33,-50 -60,-68
q -27,-19 -48,-22
q -21,-1 -21,-10
q 0,-10 53,-10
l 304, 0
q 43,0 43,10
q 0,10 -24,10
q -100,6 -100,76
q 0,16 8,43
q 8,27 108,256
q 99,229 158,349
q 22,-56 95,-272
q 72,-215 86,-271
q -53,-131 -77,-152
q -24,-22 -65,-29
q -29,-1 -29,-10
q 0,-10 52,-10
l 305, 0
q 28,0 35,2
q 8,2 8,8
q 0,6 -40,10
q -84,13 -84,81
q 0,106 234,637
q 46,-116 90,-239
l 80, -220
q 35,-97 39,-122
q 5,-25 5,-46
q 0,-89 -85,-91
q -19,0 -19,-10
q 0,-6 6,-8
q 6,-2 34,-2
l 165, 0
q 74,0 84,2
q 11,1 11,10
q 0,8 -16,8
q -74,6 -117,89
q -42,83 -196,532
q -81,235 -108,299
l -21, 0
q -58,-160 -113,-292
q -54,-132 -154,-389
l -229, 681
Z
surely got W.

Related

find numbers in text using regex

I am trying to find a way to extract the numbers (xxx.xxxx) from this textfile (was a gml cityJson file):
</bldg:lod2Solid>
<bldg:lod2TerrainIntersection>
<gml:MultiCurve>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.98 5808526.986 68.01 371139.991 5808526.991 68.01 371140 5808526.995 68.01 371140.01 5808527 68.01 371140.378 5808527.169 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.378 5808527.169 68.01 371140.809 5808527.245 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.809 5808527.245 68.01 371141 5808527.229 68.01 371141.212 5808527.212 68.008 371141.245 5808527.209 68.006</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.245 5808527.209 68.006 371141.657 5808527.063 67.986</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.657 5808527.063 67.986 371141.75 5808527 67.98 371141.899 5808526.899 67.977 371142 5808526.83 67.973 371142.019 5808526.817 67.974</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.019 5808526.817 67.974 371142.306 5808526.486 67.993</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.306 5808526.486 67.993 371142.365 5808526.365 67.997 371142.499 5808526.094 67.988</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.499 5808526.094 67.988 371142.518 5808526 67.985 371142.586 5808525.665 67.998</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.561 5808525.228 67.982 371142.581 5808525.581 68.001 371142.586 5808525.665 67.998</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.386 5808524.801 67.992 371142.468 5808525 67.979 371142.561 5808525.228 67.982</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.107 5808524.435 68.03 371142.386 5808524.801 67.992</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.743 5808524.152 68.057 371142 5808524.352 68.043 371142.107 5808524.435 68.03</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.318 5808523.973 68.077 371141.382 5808524 68.075 371141.743 5808524.152 68.057</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.862 5808523.91 68.09 371140.918 5808523.918 68.09 371141 5808523.929 68.089 371141.318 5808523.973 68.077</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.404 5808523.968 68.096 371140.862 5808523.91 68.09</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.977 5808524.141 68.095 371140 5808524.132 68.096 371140.094 5808524.094 68.097 371140.325 5808524 68.097 371140.404 5808523.968 68.096</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.61 5808524.419 68.072 371139.977 5808524.141 68.095</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.326 5808524.782 68.063 371139.526 5808524.526 68.065 371139.61 5808524.419 68.072</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.811 5808525.146 68.103 371138 5808525.101 68.111 371138.081 5808525.081 68.113 371138.419 5808525 68.095 371138.887 5808524.887 68.074 371139 5808524.86 68.06 371139.326 5808524.782 68.063</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.811 5808525.146 68.103 371137.896 5808525.896 68.037 371137.908 5808526 68.035 371137.995 5808526.769 68.015</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.995 5808526.769 68.015 371138 5808526.769 68.015 371138.741 5808526.741 68.015 371139 5808526.731 68.015 371139.643 5808526.707 68.016</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.643 5808526.707 68.016 371139.98 5808526.986 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
</gml:MultiCurve>
</bldg:lod2TerrainIntersection>
<bldg:boundedBy>
<bldg:WallSurface gml:id="UUID_776cbf08-4447-4c77-8c77-4ea39b283a81">
<core:creationDate>2022-03-03</core:creationDate>
<bldg:lod2MultiSurface>
<gml:MultiSurface gml:id="UUID_3d4e234e-add8-43d9-b90c-abbcbbe6073c">
<gml:surfaceMember>
my plan was to first find everything between <bldg:lod2TerrainIntersection>
and </bldg:lod2TerrainIntersection> via regex /<bldg:lod2TerrainIntersection>(.*?)<\/bldg:lod2TerrainIntersection>/g but it is not finding anything...
then the plan was to extract the numbers via regex: \d+\.\d+ to extract all numbers which are xxx.xxx is also not working :/
What am I doing wrong? or would there be a better way to do that?
thanks a lot for help!
Since regex are not reliable at parsing nested contents like an xml document, the best option to better deal with your expectation would be using the DOMParser object as long as Javascript will be the runtime to perform this job.
Here I show a function that will parse a given text content being an xml and will retrieve all its posList nodes inside each lod2TerrainIntersection parent node. The result will be returned as an array of string for each parent element.
So that the posList tag value will be extracted and you'll have all those "numbers" isolated as values of an array. Now once you have those values you can parse them as you best prefer.
function parseContent(xmlcontent){
//parse the xml document
const parser = new DOMParser();
const xml = parser.parseFromString(xmlcontent, "text/xml");
//select elements having tagname bldg:lod2TerrainIntersection
const nodes_lod2TerrainIntersection = xml.getElementsByTagName('bldg:lod2TerrainIntersection');
//fetch the result as an array of collections of posList values for each parent container
const values = [...nodes_lod2TerrainIntersection].map(parentNode => {
//select all the descendant being gml:postList
const nodes_posList = parentNode.getElementsByTagName('gml:posList');
//return the array of values coming from all those nodes
return [...nodes_posList].map( node => node.textContent );
});
return values;
}
This is an example of array returned for a single parent node:
[
"371139.98 5808526.986 68.01 371139.991 5808526.991 68.01 371140 5808526.995 68.01 371140.01 5808527 68.01 371140.378 5808527.169 68.01",
"371140.378 5808527.169 68.01 371140.809 5808527.245 68.01",
"371140.809 5808527.245 68.01 371141 5808527.229 68.01 371141.212 5808527.212 68.008 371141.245 5808527.209 68.006",
...
]
function parseContent(xmlcontent){
//parse the xml document
const parser = new DOMParser();
const xml = parser.parseFromString(xmlcontent, "text/xml");
//select elements having tagname bldg:lod2TerrainIntersection
const nodes_lod2TerrainIntersection = xml.getElementsByTagName('bldg:lod2TerrainIntersection');
//fetch the result as an array of collections of posList values for each parent container
const values = [...nodes_lod2TerrainIntersection].map(parentNode => {
//select all the descendant being gml:postList
const nodes_posList = parentNode.getElementsByTagName('gml:posList');
//return the array of values coming from all those nodes
return [...nodes_posList].map( node => node.textContent );
});
return values;
}
//I added a root element to your xml just to add some xml consistency
const filecontent = `<?xml version="1.0" encoding="UTF-8"?>
<core:Model
xmlns:bldg="http://www.opengis.net/citygml/building/2.0"
xmlns:gml="http://www.opengis.net/gml"
xmlns:core="http://www.opengis.net/citygml/2.0">
<bldg:lod2TerrainIntersection>
<gml:MultiCurve>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.98 5808526.986 68.01 371139.991 5808526.991 68.01 371140 5808526.995 68.01 371140.01 5808527 68.01 371140.378 5808527.169 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.378 5808527.169 68.01 371140.809 5808527.245 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.809 5808527.245 68.01 371141 5808527.229 68.01 371141.212 5808527.212 68.008 371141.245 5808527.209 68.006</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.245 5808527.209 68.006 371141.657 5808527.063 67.986</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.657 5808527.063 67.986 371141.75 5808527 67.98 371141.899 5808526.899 67.977 371142 5808526.83 67.973 371142.019 5808526.817 67.974</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.019 5808526.817 67.974 371142.306 5808526.486 67.993</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.306 5808526.486 67.993 371142.365 5808526.365 67.997 371142.499 5808526.094 67.988</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.499 5808526.094 67.988 371142.518 5808526 67.985 371142.586 5808525.665 67.998</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.561 5808525.228 67.982 371142.581 5808525.581 68.001 371142.586 5808525.665 67.998</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.386 5808524.801 67.992 371142.468 5808525 67.979 371142.561 5808525.228 67.982</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371142.107 5808524.435 68.03 371142.386 5808524.801 67.992</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.743 5808524.152 68.057 371142 5808524.352 68.043 371142.107 5808524.435 68.03</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371141.318 5808523.973 68.077 371141.382 5808524 68.075 371141.743 5808524.152 68.057</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.862 5808523.91 68.09 371140.918 5808523.918 68.09 371141 5808523.929 68.089 371141.318 5808523.973 68.077</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371140.404 5808523.968 68.096 371140.862 5808523.91 68.09</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.977 5808524.141 68.095 371140 5808524.132 68.096 371140.094 5808524.094 68.097 371140.325 5808524 68.097 371140.404 5808523.968 68.096</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.61 5808524.419 68.072 371139.977 5808524.141 68.095</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.326 5808524.782 68.063 371139.526 5808524.526 68.065 371139.61 5808524.419 68.072</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.811 5808525.146 68.103 371138 5808525.101 68.111 371138.081 5808525.081 68.113 371138.419 5808525 68.095 371138.887 5808524.887 68.074 371139 5808524.86 68.06 371139.326 5808524.782 68.063</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.811 5808525.146 68.103 371137.896 5808525.896 68.037 371137.908 5808526 68.035 371137.995 5808526.769 68.015</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371137.995 5808526.769 68.015 371138 5808526.769 68.015 371138.741 5808526.741 68.015 371139 5808526.731 68.015 371139.643 5808526.707 68.016</gml:posList>
</gml:LineString>
</gml:curveMember>
<gml:curveMember>
<gml:LineString>
<gml:posList srsDimension="3">371139.643 5808526.707 68.016 371139.98 5808526.986 68.01</gml:posList>
</gml:LineString>
</gml:curveMember>
</gml:MultiCurve>
</bldg:lod2TerrainIntersection>
</core:Model>`;
const values = parseContent(filecontent);
console.log(values);

I am creating graph using plotly, However i am not sure how to do it for india, below is the code for US in python

I am using Cloropleth function and a dictionary for states and their short forms
figure = {'data': [go.Choropleth( # colorscale = "Blues",
locations=geo_dist['State'],
z=geo_dist['Log Num'].astype(float),
locationmode='USA-states',
text=geo_dist['text'],
geo='geo',
colorbar_title='Num in Log2',
marker_line_color='white',
colorscale=['#fdf7ff', '#835af1'],
)], 'layout': {'title': 'Geographic Segmentation for US',
'geo': {'scope': 'asia'}}}
This is done for US, I want for India
fundamentally if you want to use geometry that is not included in plotly you need to provide geojson
have found source of geojson that defined geometry for Indian states
you reference a data frame in you sample code, so I have simulated it
then a simple case of linking data frame to geometry using locations and featureidkey
import requests
import pandas as pd
import numpy as np
import plotly.graph_objects as go
r = requests.get("https://www.geoboundaries.org/gbRequest.html?ISO=IND&ADM=ADM1")
india = requests.get(r.json()[0]["gjDownloadURL"]).json()
geo_dist = pd.DataFrame(
columns=["text", "State"],
data=[
["Tamil Nadu", "IN-TN"],
["Puducherry", "IN-PY"],
["Himachal Pradesh", "IN-HP"],
["Uttarakhand", "IN-UT"],
["Sikkim", "IN-SK"],
["Delhi", "IN-DL"],
["Uttar Pradesh", "IN-UP"],
["Haryana", "IN-HR"],
["Punjab", "IN-PB"],
["Chandigarh", "IN-CH"],
["Rajasthan", "IN-RJ"],
["Jammu and Kashmir", "IN-JK"],
["Gujarat", "IN-GJ"],
["Madhya Pradesh", "IN-MP"],
["Maharashtra", "IN-MH"],
["Union Territory of Dadra & Nagar Haveli", "IN-DN"],
["Daman and Diu", "IN-DD"],
["Bihar", "IN-BR"],
["West Bengal", "IN-WB"],
["Jharkhand", "IN-JH"],
["Chhattisgarh", "IN-CT"],
["Odisha", "IN-OR"],
["Goa", "IN-GA"],
["Kerala", "IN-KL"],
["Karnataka", "IN-KA"],
["Andhra Pradesh", "IN-AP"],
["Andaman and Nicobar Islands", "IN-AN"],
["Assam", "IN-AS"],
["Tripura", "IN-TR"],
["Arunachal Pradesh", "IN-AR"],
["Lakshadweep", "IN-LD"],
["Meghalaya", "IN-ML"],
["Manipur", "IN-MN"],
["Nagaland", "IN-NL"],
["Mizoram", "IN-MZ"],
["Telangana", "IN-TG"],
],
)
geo_dist["Log Num"] = np.random.uniform(1, 10, len(geo_dist))
figure = {
"data": [
go.Choropleth( # colorscale = "Blues",
locations=geo_dist["State"],
featureidkey="properties.shapeISO",
geojson=india,
z=geo_dist["Log Num"].astype(float),
# locationmode="USA-states",
text=geo_dist["text"],
geo="geo",
colorbar_title="Num in Log2",
marker_line_color="white",
colorscale=["#fdf7ff", "#835af1"],
)
],
"layout": {
"title": "Geographic Segmentation for India",
"geo": {"fitbounds": "locations"},
},
}
go.Figure(figure)

How to get keyboard name? (to visually distinguish keyboards in a specific language)

I have for example 2 languages installed — English and Russian. And Russian has 2 keyboards — Ordinary and Mnemonic:
When I run the code:
UINT uLayouts;
HKL *lpList = NULL;
wchar_t szBufLng[512], szBufCtry[512];
uLayouts = GetKeyboardLayoutList(0, NULL);
lpList = (HKL*)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
for(int i = 0; i < uLayouts; ++i)
{
GetLocaleInfo(MAKELCID(((UINT)lpList[i] & 0xffffffff),
SORT_DEFAULT), LOCALE_SISO639LANGNAME, szBufLng, 512);
GetLocaleInfo(MAKELCID(((UINT)lpList[i] & 0xffffffff),
SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, szBufCtry, 512);
wprintf(L"%s-%s, %x\n", szBufLng, szBufCtry, (UINT)lpList[i]);
memset(szBufLng, 0, 512);
memset(szBufCtry, 0, 512);
}
if(lpList)
LocalFree(lpList);
I get the following result:
en-US, 04090409
ru-RU, 04190419
ru-RU, f0330419
My question is how to distinguish the mnemonic?
At least to display something like this:
en-US, 04090409
ru-RU, 04190419
rum-RU, f0330419
How to get keyboard name?
Same problem is discussed here (no solution):
https://forums.codeguru.com/showthread.php?492287-Keyboard-Layout-Name
http://web.archive.org/web/20081025132249/http://blogs.msdn.com/michkap/archive/2004/12/05/275231.aspx
http://web.archive.org/web/20100330193933/http://blogs.msdn.com/michkap/archive/2008/09/29/8968315.aspx
I exported data from the registry (\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts) in Windows 10 and based on it created a table. And with the help of SHLoadIndirectString got the localized name of the keyboard.
struct LAYOUT_KEYBOARD_INFO {
LCID layout_id;
short display_name_id;
wchar_t default_keyboard_name[64];
};
LAYOUT_KEYBOARD_INFO LAYOUT_KEYBOARDS[] = {
{0x0401, 5084, L"Arabic (101)"},
{0x0402, 5053, L"Bulgarian (Typewriter)"},
{0x0404, 5065, L"Chinese (Traditional) - US Keyboard"},
{0x0405, 5031, L"Czech"},
{0x0406, 5007, L"Danish"},
{0x0407, 5011, L"German"},
{0x0408, 5046, L"Greek"},
{0x0409, 5000, L"US"},
{0x040A, 5020, L"Spanish"},
{0x040B, 5009, L"Finnish"},
{0x040C, 5010, L"French"},
{0x040D, 5083, L"Hebrew"},
{0x040E, 5033, L"Hungarian"},
{0x040F, 5013, L"Icelandic"},
{0x0410, 5015, L"Italian"},
{0x0411, 5061, L"Japanese"},
{0x0412, 5063, L"Korean"},
{0x0413, 5008, L"Dutch"},
{0x0414, 5018, L"Norwegian"},
{0x0415, 5035, L"Polish (Programmers)"},
{0x0416, 5003, L"Portuguese (Brazilian ABNT)"},
{0x0418, 5037, L"Romanian (Legacy)"},
{0x0419, 5055, L"Russian"},
{0x041A, 5030, L"Standard"},
{0x041B, 5039, L"Slovak"},
{0x041C, 5029, L"Albanian"},
{0x041D, 5022, L"Swedish"},
{0x041E, 5079, L"Thai Kedmanee"},
{0x041F, 5060, L"Turkish Q"},
{0x0420, 5129, L"Urdu"},
{0x0422, 5058, L"Ukrainian"},
{0x0423, 5052, L"Belarusian"},
{0x0424, 5041, L"Slovenian"},
{0x0425, 5042, L"Estonian"},
{0x0426, 5043, L"Latvian"},
{0x0427, 5045, L"Lithuanian IBM"},
{0x0428, 5151, L"Tajik"},
{0x0429, 5124, L"Persian"},
{0x042A, 5118, L"Vietnamese"},
{0x042B, 5120, L"Armenian Eastern"},
{0x042C, 5117, L"Azeri Latin"},
{0x042E, 5163, L"Sorbian Standard (Legacy)"},
{0x042F, 5109, L"Macedonian (FYROM)"},
{0x0432, 5191, L"Setswana"},
{0x0437, 5119, L"Georgian"},
{0x0438, 5108, L"Faeroese"},
{0x0439, 5096, L"Devanagari - INSCRIPT"},
{0x043A, 5140, L"Maltese 47-Key"},
{0x043B, 5138, L"Norwegian with Sami"},
{0x043F, 5113, L"Kazakh"},
{0x0440, 5128, L"Kyrgyz Cyrillic"},
{0x0442, 5150, L"Turkmen"},
{0x0444, 5116, L"Tatar (Legacy)"},
{0x0445, 5135, L"Bengali"},
{0x0446, 5101, L"Punjabi"},
{0x0447, 5097, L"Gujarati"},
{0x0448, 5100, L"Oriya"},
{0x0449, 5102, L"Tamil"},
{0x044A, 5103, L"Telugu"},
{0x044B, 5098, L"Kannada"},
{0x044C, 5139, L"Malayalam"},
{0x044D, 5177, L"Assamese - INSCRIPT"},
{0x044E, 5104, L"Marathi"},
{0x0450, 5127, L"Mongolian Cyrillic"},
{0x0451, 5154, L"Tibetan (PRC)"},
{0x0452, 5145, L"United Kingdom Extended"},
{0x0453, 5161, L"Khmer"},
{0x0454, 5162, L"Lao"},
{0x045A, 5130, L"Syriac"},
{0x045B, 5166, L"Sinhala"},
{0x045C, 5209, L"Cherokee Nation"},
{0x0461, 5169, L"Nepali"},
{0x0463, 5159, L"Pashto (Afghanistan)"},
{0x0465, 5132, L"Divehi Phonetic"},
{0x0468, 5187, L"Hausa"},
{0x046A, 5189, L"Yoruba"},
{0x046C, 5186, L"Sesotho sa Leboa"},
{0x046D, 5148, L"Bashkir"},
{0x046E, 5168, L"Luxembourgish"},
{0x046F, 5170, L"Greenlandic"},
{0x0470, 5188, L"Igbo"},
{0x0474, 5231, L"Guarani"},
{0x0475, 5198, L"Hawaiian"},
{0x0480, 5165, L"Uyghur (Legacy)"},
{0x0481, 5146, L"Maori"},
{0x0485, 5160, L"Sakha"},
{0x0488, 5190, L"Wolof"},
{0x0492, 5199, L"Central Kurdish"},
{0x0804, 5072, L"Chinese (Simplified) - US Keyboard"},
{0x0807, 5024, L"Swiss German"},
{0x0809, 5025, L"United Kingdom"},
{0x080A, 5017, L"Latin American"},
{0x080C, 5002, L"Belgian French"},
{0x0813, 5001, L"Belgian (Period)"},
{0x0816, 5019, L"Portuguese"},
{0x081A, 5038, L"Serbian (Latin)"},
{0x082C, 5115, L"Azeri Cyrillic"},
{0x083B, 5144, L"Swedish with Sami"},
{0x0843, 5114, L"Uzbek Cyrillic"},
{0x0850, 5158, L"Mongolian (Mongolian Script)"},
{0x085D, 5156, L"Inuktitut - Latin"},
{0x085F, 5229, L"Central Atlas Tamazight"},
{0x0C04, 5192, L"Chinese (Traditional, Hong Kong S.A.R.) - US Keyboard"},
{0x0C0C, 5005, L"Canadian French (Legacy)"},
{0x0C1A, 5057, L"Serbian (Cyrillic)"},
{0x0C51, 5235, L"Dzongkha"},
{0x1004, 5193, L"Chinese (Simplified, Singapore) - US Keyboard"},
{0x1009, 5004, L"Canadian French"},
{0x100C, 5023, L"Swiss French"},
{0x105F, 5207, L"Tifinagh (Basic)"},
{0x1404, 5194, L"Chinese (Traditional, Macao S.A.R.) - US Keyboard"},
{0x1809, 5014, L"Irish"},
{0x201A, 5155, L"Bosnian (Cyrillic)"},
{0x4009, 5196, L"India"},
// Added F to "Layout Id"
{0xF028, 5085, L"Arabic (102)"},
{0xF004, 5054, L"Bulgarian (Latin)"},
{0xF005, 5032, L"Czech (QWERTY)"},
{0xF012, 5012, L"German (IBM)"},
{0xF016, 5048, L"Greek (220)"},
{0xF002, 5092, L"United States-Dvorak"},
{0xF086, 5021, L"Spanish Variation"},
{0xF006, 5034, L"Hungarian 101-key"},
{0xF003, 5016, L"Italian (142)"},
{0xF007, 5036, L"Polish (214)"},
{0xF010, 5126, L"Portuguese (Brazilian ABNT2)"},
{0xF0A5, 5175, L"Romanian (Standard)"},
{0xF008, 5056, L"Russian (Typewriter)"},
{0xF013, 5040, L"Slovak (QWERTY)"},
{0xF021, 5080, L"Thai Pattachote"},
{0xF014, 5059, L"Turkish F"},
{0xF015, 5044, L"Latvian (QWERTY)"},
{0xF027, 5088, L"Lithuanian"},
{0xF025, 5121, L"Armenian Western"},
{0xF0BD, 5234, L"Azerbaijani (Standard)"},
{0xF09F, 5164, L"Sorbian Extended"},
{0xF0A4, 5174, L"Macedonian (FYROM) - Standard"},
{0xF0AB, 5182, L"Georgian (QWERTY)"},
{0xF00C, 5105, L"Hindi Traditional"},
{0xF02B, 5141, L"Maltese 48-Key"},
{0xF02C, 5143, L"Sami Extended Norway"},
{0xF0BC, 5233, L"Tatar"},
{0xF02A, 5136, L"Bengali - INSCRIPT (Legacy)"},
{0xF0B5, 5222, L"Tibetan (PRC) - Updated"},
{0xF02F, 5200, L"Khmer (NIDA)"},
{0xF00E, 5131, L"Syriac Phonetic"},
{0xF0A0, 5167, L"Sinhala - Wij 9"},
{0xF037, 5201, L"Cherokee Nation Phonetic"},
{0xF0A7, 5171, L"Inuktitut - Naqittaut"},
{0xF00D, 5133, L"Divehi Typewriter"},
{0xF0AD, 5185, L"Uyghur"},
{0xF01E, 5089, L"Belgian (Comma)"},
{0xF02D, 5137, L"Finnish with Sami"},
{0xF0B2, 5225, L"Traditional Mongolian (Standard)"},
{0xF030, 5249, L"Myanmar (Phonetic order)"},
{0xF020, 5110, L"Canadian Multilingual Standard"},
{0xF036, 5208, L"Tifinagh (Full)"},
{0xF026, 5125, L"Gaelic"},
{0xF029, 5086, L"Arabic (102) AZERTY"},
{0xF0A3, 5173, L"Bulgarian (Phonetic)"},
{0xF00A, 5087, L"Czech Programmers"},
{0xF018, 5049, L"Greek (319)"},
{0xF001, 5026, L"United States-International"},
{0xF03D, 5214, L"Hebrew (Standard)"},
{0xF0A6, 5176, L"Romanian (Programmers)"},
{0xF033, 5203, L"Russian - Mnemonic"},
{0xF022, 5081, L"Thai Kedmanee (non-ShiftLock)"},
{0xF0A8, 5179, L"Ukrainian (Enhanced)"},
{0xF0B1, 5224, L"Latvian (Standard)"},
{0xF0A1, 5172, L"Lithuanian Standard"},
{0xF038, 5217, L"Armenian Phonetic"},
{0xF0AE, 5184, L"Sorbian Standard"},
{0xF0AC, 5181, L"Georgian (Ergonomic)"},
{0xF0A9, 5178, L"Bengali - INSCRIPT"},
{0xF0C8, 5246, L"Tamil 99"},
{0xF02E, 5142, L"Sami Extended Finland-Sweden"},
{0xF031, 5204, L"New Tai Lue"},
{0xF0AA, 5180, L"Bulgarian"},
{0xF017, 5050, L"Greek (220) Latin"},
{0xF01A, 5027, L"United States-Dvorak for left hand"},
{0xF023, 5082, L"Thai Pattachote (non-ShiftLock)"},
{0xF039, 5218, L"Armenian Typewriter"},
{0xF03B, 5215, L"Georgian Ministry of Education and Science Schools"},
{0xF034, 5205, L"Tai Le"},
{0xF0AF, 5195, L"Bulgarian (Phonetic Traditional)"},
{0xF011, 5051, L"Greek (319) Latin"},
{0xF01B, 5028, L"United States-Dvorak for right hand"},
{0xF03C, 5216, L"Georgian (Old Alphabets)"},
{0xF032, 5206, L"Ogham"},
{0xF019, 5047, L"Greek Latin"},
{0xF00B, 5123, L"US English Table for IBM Arabic 238_L"},
{0xF03A, 5213, L"Persian (Standard)"},
{0xF01F, 5122, L"Greek Polytonic"},
{0xF03E, 5210, L"Lisu (Basic)"},
{0xF03F, 5211, L"Lisu (Standard)"},
{0xF040, 5212, L"N’Ko"},
{0xF041, 5219, L"Phags-pa"},
{0xF0B3, 5220, L"Buginese"},
{0xF0B4, 5221, L"Gothic"},
{0xF0B6, 5223, L"Ol Chiki"},
{0xF0B7, 5226, L"Osmanya"},
{0xF0B8, 5227, L"Old Italic"},
{0xF0B9, 5228, L"Sora"},
{0xF0BA, 5230, L"Javanese"},
{0xF0BB, 5232, L"Futhark"},
{0xF0CB, 5250, L"Myanmar (Visual Order)"},
{0xF0CC, 5251, L"ADLaM"},
{0xF0CD, 5252, L"Osage"}
};
CString GetLayoutKeyboardDisplayName(DWORD layout, bool fLocalized = true) {
DWORD layout_id = layout >> 16;
CString keyboard_name = L"";
int number_of_elements = sizeof(LAYOUT_KEYBOARDS)/sizeof(LAYOUT_KEYBOARDS[0]);
for (int i = 0; i < number_of_elements; i++)
if (LAYOUT_KEYBOARDS[i].layout_id == layout_id) {
wchar_t szBuf[512];
if (fLocalized && SHLoadIndirectString(L"#%SystemRoot%\\system32\\input.dll,-" + IntToStr(LAYOUT_KEYBOARDS[i].display_name_id), szBuf, 512, NULL) == S_OK)
keyboard_name.Format(L"%s", szBuf);
else
keyboard_name = LAYOUT_KEYBOARDS[i].default_keyboard_name;
memset(szBuf, 0, 512);
return keyboard_name;
}
keyboard_name.Format(L"%X", layout_id);
keyboard_name.TrimLeft(L"0");
return keyboard_name;
}
//...
wprintf(L"%X, %s\n", (UINT)lpList[i], GetLayoutKeyboardDisplayName((UINT)lpList[i]));
Keyboard layouts can be obtained from windows regedit.
the following is python code:
# -*- coding: utf-8 -*-
# 从注册表中获取所有的键盘布局
# get all keyboard layouts from win regedit
import json
import winreg
def get_keyboard_layouts():
"""
windows 从注册表中获取所有的键盘布局
参考: https://stackoverflow.com/questions/66841378
"""
print('get keyboard layouts')
# reg root path
loc_root = winreg.HKEY_LOCAL_MACHINE
# Keyboard Layouts reg path
loc_keyboards = r'SYSTEM\CurrentControlSet\Control\Keyboard Layouts'
# open reg path, get handle
handle_keyboards = winreg.OpenKey(key=loc_root, sub_key=loc_keyboards)
# get info of reg 'Keyboard Layouts'
# The result is a tuple of 3 items:
# An integer that identifies the number of sub keys this key has.
# An integer that identifies the number of values this key has.
# An integer that identifies when the key was last modified (if available)
# as 100's of nanoseconds since Jan 1, 1600.
info_keyboards = winreg.QueryInfoKey(handle_keyboards)
# get sub key length
keyboards_len = info_keyboards[0]
keyboard_layout = {}
# traverse to get sub key
for i in range(keyboards_len):
# sub key name
name_keyboard = winreg.EnumKey(handle_keyboards, i)
# sub key path
loc_keyboard = fr'{loc_keyboards}\{name_keyboard}'
# open sub key
handle_keyboard = winreg.OpenKey(key=loc_root, sub_key=loc_keyboard)
# get layout text
layout_text = winreg.QueryValueEx(handle_keyboard, 'Layout Text')[0]
# save layout name and layout text
keyboard_layout[name_keyboard] = layout_text
# 转换关系参考 https://stackoverflow.com/questions/42047253/
# to hex string
# {'00000401': 'Arabic (101)', '00000402': 'Bulgarian (Typewriter)'}
# 得到的是 16 进制的字符串, 要转换为 0x804 的 16进制数
# 16 进制字符串转 16 进制整数
# int(win32api.GetKeyboardLayoutName(), 10) > 804
# 16 进制字符串转 10 进制整数
# int(win32api.GetKeyboardLayoutName(), 16) > 2052
name_keyboard_hex = hex(int(name_keyboard, 16))
# save hex layout name and layout text
keyboard_layout[name_keyboard_hex] = layout_text
handle_keyboard.Close()
handle_keyboards.Close()
return keyboard_layout
if __name__ == '__main__':
print(json.dumps(get_keyboard_layouts()))
keyboard_layouts = {
"00000401": "Arabic (101)",
"0x401": "Arabic (101)",
"00000402": "Bulgarian (Typewriter)",
"0x402": "Bulgarian (Typewriter)",
"00000404": "Chinese (Traditional) - US Keyboard",
"0x404": "Chinese (Traditional) - US Keyboard",
"00000405": "Czech",
"0x405": "Czech",
"00000406": "Danish",
"0x406": "Danish",
"00000407": "German",
"0x407": "German",
"00000408": "Greek",
"0x408": "Greek",
"00000409": "US",
"0x409": "US",
"0000040a": "Spanish",
"0x40a": "Spanish",
"0000040b": "Finnish",
"0x40b": "Finnish",
"0000040c": "French",
"0x40c": "French",
"0000040d": "Hebrew",
"0x40d": "Hebrew",
"0000040e": "Hungarian",
"0x40e": "Hungarian",
"0000040f": "Icelandic",
"0x40f": "Icelandic",
"00000410": "Italian",
"0x410": "Italian",
"00000411": "Japanese",
"0x411": "Japanese",
"00000412": "Korean",
"0x412": "Korean",
"00000413": "Dutch",
"0x413": "Dutch",
"00000414": "Norwegian",
"0x414": "Norwegian",
"00000415": "Polish (Programmers)",
"0x415": "Polish (Programmers)",
"00000416": "Portuguese (Brazilian ABNT)",
"0x416": "Portuguese (Brazilian ABNT)",
"00000418": "Romanian (Legacy)",
"0x418": "Romanian (Legacy)",
"00000419": "Russian",
"0x419": "Russian",
"0000041a": "Standard",
"0x41a": "Standard",
"0000041b": "Slovak",
"0x41b": "Slovak",
"0000041c": "Albanian",
"0x41c": "Albanian",
"0000041d": "Swedish",
"0x41d": "Swedish",
"0000041e": "Thai Kedmanee",
"0x41e": "Thai Kedmanee",
"0000041f": "Turkish Q",
"0x41f": "Turkish Q",
"00000420": "Urdu",
"0x420": "Urdu",
"00000422": "Ukrainian",
"0x422": "Ukrainian",
"00000423": "Belarusian",
"0x423": "Belarusian",
"00000424": "Slovenian",
"0x424": "Slovenian",
"00000425": "Estonian",
"0x425": "Estonian",
"00000426": "Latvian",
"0x426": "Latvian",
"00000427": "Lithuanian IBM",
"0x427": "Lithuanian IBM",
"00000428": "Tajik",
"0x428": "Tajik",
"00000429": "Persian",
"0x429": "Persian",
"0000042a": "Vietnamese",
"0x42a": "Vietnamese",
"0000042b": "Armenian Eastern",
"0x42b": "Armenian Eastern",
"0000042c": "Azeri Latin",
"0x42c": "Azeri Latin",
"0000042e": "Sorbian Standard (Legacy)",
"0x42e": "Sorbian Standard (Legacy)",
"0000042f": "Macedonian (FYROM)",
"0x42f": "Macedonian (FYROM)",
"00000432": "Setswana",
"0x432": "Setswana",
"00000437": "Georgian",
"0x437": "Georgian",
"00000438": "Faeroese",
"0x438": "Faeroese",
"00000439": "Devanagari - INSCRIPT",
"0x439": "Devanagari - INSCRIPT",
"0000043a": "Maltese 47-Key",
"0x43a": "Maltese 47-Key",
"0000043b": "Norwegian with Sami",
"0x43b": "Norwegian with Sami",
"0000043f": "Kazakh",
"0x43f": "Kazakh",
"00000440": "Kyrgyz Cyrillic",
"0x440": "Kyrgyz Cyrillic",
"00000442": "Turkmen",
"0x442": "Turkmen",
"00000444": "Tatar (Legacy)",
"0x444": "Tatar (Legacy)",
"00000445": "Bengali",
"0x445": "Bengali",
"00000446": "Punjabi",
"0x446": "Punjabi",
"00000447": "Gujarati",
"0x447": "Gujarati",
"00000448": "Oriya",
"0x448": "Oriya",
"00000449": "Tamil",
"0x449": "Tamil",
"0000044a": "Telugu",
"0x44a": "Telugu",
"0000044b": "Kannada",
"0x44b": "Kannada",
"0000044c": "Malayalam",
"0x44c": "Malayalam",
"0000044d": "Assamese - INSCRIPT",
"0x44d": "Assamese - INSCRIPT",
"0000044e": "Marathi",
"0x44e": "Marathi",
"00000450": "Mongolian Cyrillic",
"0x450": "Mongolian Cyrillic",
"00000451": "Tibetan (PRC)",
"0x451": "Tibetan (PRC)",
"00000452": "United Kingdom Extended",
"0x452": "United Kingdom Extended",
"00000453": "Khmer",
"0x453": "Khmer",
"00000454": "Lao",
"0x454": "Lao",
"0000045a": "Syriac",
"0x45a": "Syriac",
"0000045b": "Sinhala",
"0x45b": "Sinhala",
"0000045c": "Cherokee Nation",
"0x45c": "Cherokee Nation",
"00000461": "Nepali",
"0x461": "Nepali",
"00000463": "Pashto (Afghanistan)",
"0x463": "Pashto (Afghanistan)",
"00000465": "Divehi Phonetic",
"0x465": "Divehi Phonetic",
"00000468": "Hausa",
"0x468": "Hausa",
"0000046a": "Yoruba",
"0x46a": "Yoruba",
"0000046c": "Sesotho sa Leboa",
"0x46c": "Sesotho sa Leboa",
"0000046d": "Bashkir",
"0x46d": "Bashkir",
"0000046e": "Luxembourgish",
"0x46e": "Luxembourgish",
"0000046f": "Greenlandic",
"0x46f": "Greenlandic",
"00000470": "Igbo",
"0x470": "Igbo",
"00000474": "Guarani",
"0x474": "Guarani",
"00000475": "Hawaiian",
"0x475": "Hawaiian",
"00000480": "Uyghur (Legacy)",
"0x480": "Uyghur (Legacy)",
"00000481": "Maori",
"0x481": "Maori",
"00000485": "Sakha",
"0x485": "Sakha",
"00000488": "Wolof",
"0x488": "Wolof",
"00000492": "Central Kurdish",
"0x492": "Central Kurdish",
"00000804": "Chinese (Simplified) - US Keyboard",
"0x804": "Chinese (Simplified) - US Keyboard",
"00000807": "Swiss German",
"0x807": "Swiss German",
"00000809": "United Kingdom",
"0x809": "United Kingdom",
"0000080a": "Latin American",
"0x80a": "Latin American",
"0000080c": "Belgian French",
"0x80c": "Belgian French",
"00000813": "Belgian (Period)",
"0x813": "Belgian (Period)",
"00000816": "Portuguese",
"0x816": "Portuguese",
"0000081a": "Serbian (Latin)",
"0x81a": "Serbian (Latin)",
"0000082c": "Azeri Cyrillic",
"0x82c": "Azeri Cyrillic",
"0000083b": "Swedish with Sami",
"0x83b": "Swedish with Sami",
"00000843": "Uzbek Cyrillic",
"0x843": "Uzbek Cyrillic",
"00000850": "Mongolian (Mongolian Script)",
"0x850": "Mongolian (Mongolian Script)",
"0000085d": "Inuktitut - Latin",
"0x85d": "Inuktitut - Latin",
"0000085f": "Central Atlas Tamazight",
"0x85f": "Central Atlas Tamazight",
"00000c04": "Chinese (Traditional, Hong Kong S.A.R.) - US Keyboard",
"0xc04": "Chinese (Traditional, Hong Kong S.A.R.) - US Keyboard",
"00000c0c": "Canadian French (Legacy)",
"0xc0c": "Canadian French (Legacy)",
"00000c1a": "Serbian (Cyrillic)",
"0xc1a": "Serbian (Cyrillic)",
"00000C51": "Dzongkha",
"0xc51": "Dzongkha",
"00001004": "Chinese (Simplified, Singapore) - US Keyboard",
"0x1004": "Chinese (Simplified, Singapore) - US Keyboard",
"00001009": "Canadian French",
"0x1009": "Canadian French",
"0000100c": "Swiss French",
"0x100c": "Swiss French",
"0000105f": "Tifinagh (Basic)",
"0x105f": "Tifinagh (Basic)",
"00001404": "Chinese (Traditional, Macao S.A.R.) - US Keyboard",
"0x1404": "Chinese (Traditional, Macao S.A.R.) - US Keyboard",
"00001809": "Irish",
"0x1809": "Irish",
"0000201a": "Bosnian (Cyrillic)",
"0x201a": "Bosnian (Cyrillic)",
"00004009": "India",
"0x4009": "India",
"00010401": "Arabic (102)",
"0x10401": "Arabic (102)",
"00010402": "Bulgarian (Latin)",
"0x10402": "Bulgarian (Latin)",
"00010405": "Czech (QWERTY)",
"0x10405": "Czech (QWERTY)",
"00010407": "German (IBM)",
"0x10407": "German (IBM)",
"00010408": "Greek (220)",
"0x10408": "Greek (220)",
"00010409": "United States-Dvorak",
"0x10409": "United States-Dvorak",
"0001040a": "Spanish Variation",
"0x1040a": "Spanish Variation",
"0001040e": "Hungarian 101-key",
"0x1040e": "Hungarian 101-key",
"00010410": "Italian (142)",
"0x10410": "Italian (142)",
"00010415": "Polish (214)",
"0x10415": "Polish (214)",
"00010416": "Portuguese (Brazilian ABNT2)",
"0x10416": "Portuguese (Brazilian ABNT2)",
"00010418": "Romanian (Standard)",
"0x10418": "Romanian (Standard)",
"00010419": "Russian (Typewriter)",
"0x10419": "Russian (Typewriter)",
"0001041b": "Slovak (QWERTY)",
"0x1041b": "Slovak (QWERTY)",
"0001041e": "Thai Pattachote",
"0x1041e": "Thai Pattachote",
"0001041f": "Turkish F",
"0x1041f": "Turkish F",
"00010426": "Latvian (QWERTY)",
"0x10426": "Latvian (QWERTY)",
"00010427": "Lithuanian",
"0x10427": "Lithuanian",
"0001042b": "Armenian Western",
"0x1042b": "Armenian Western",
"0001042c": "Azerbaijani (Standard)",
"0x1042c": "Azerbaijani (Standard)",
"0001042e": "Sorbian Extended",
"0x1042e": "Sorbian Extended",
"0001042f": "Macedonian (FYROM) - Standard",
"0x1042f": "Macedonian (FYROM) - Standard",
"00010437": "Georgian (QWERTY)",
"0x10437": "Georgian (QWERTY)",
"00010439": "Hindi Traditional",
"0x10439": "Hindi Traditional",
"0001043a": "Maltese 48-Key",
"0x1043a": "Maltese 48-Key",
"0001043b": "Sami Extended Norway",
"0x1043b": "Sami Extended Norway",
"00010444": "Tatar",
"0x10444": "Tatar",
"00010445": "Bengali - INSCRIPT (Legacy)",
"0x10445": "Bengali - INSCRIPT (Legacy)",
"00010451": "Tibetan (PRC) - Updated",
"0x10451": "Tibetan (PRC) - Updated",
"00010453": "Khmer (NIDA)",
"0x10453": "Khmer (NIDA)",
"0001045a": "Syriac Phonetic",
"0x1045a": "Syriac Phonetic",
"0001045b": "Sinhala - Wij 9",
"0x1045b": "Sinhala - Wij 9",
"0001045c": "Cherokee Nation Phonetic",
"0x1045c": "Cherokee Nation Phonetic",
"0001045d": "Inuktitut - Naqittaut",
"0x1045d": "Inuktitut - Naqittaut",
"00010465": "Divehi Typewriter",
"0x10465": "Divehi Typewriter",
"00010480": "Uyghur",
"0x10480": "Uyghur",
"0001080c": "Belgian (Comma)",
"0x1080c": "Belgian (Comma)",
"0001083b": "Finnish with Sami",
"0x1083b": "Finnish with Sami",
"00010850": "Traditional Mongolian (Standard)",
"0x10850": "Traditional Mongolian (Standard)",
"00010c00": "Myanmar (Phonetic order)",
"0x10c00": "Myanmar (Phonetic order)",
"00011009": "Canadian Multilingual Standard",
"0x11009": "Canadian Multilingual Standard",
"0001105f": "Tifinagh (Full)",
"0x1105f": "Tifinagh (Full)",
"00011809": "Gaelic",
"0x11809": "Gaelic",
"00020401": "Arabic (102) AZERTY",
"0x20401": "Arabic (102) AZERTY",
"00020402": "Bulgarian (Phonetic)",
"0x20402": "Bulgarian (Phonetic)",
"00020405": "Czech Programmers",
"0x20405": "Czech Programmers",
"00020408": "Greek (319)",
"0x20408": "Greek (319)",
"00020409": "United States-International",
"0x20409": "United States-International",
"0002040d": "Hebrew (Standard)",
"0x2040d": "Hebrew (Standard)",
"00020418": "Romanian (Programmers)",
"0x20418": "Romanian (Programmers)",
"00020419": "Russian - Mnemonic",
"0x20419": "Russian - Mnemonic",
"0002041e": "Thai Kedmanee (non-ShiftLock)",
"0x2041e": "Thai Kedmanee (non-ShiftLock)",
"00020422": "Ukrainian (Enhanced)",
"0x20422": "Ukrainian (Enhanced)",
"00020426": "Latvian (Standard)",
"0x20426": "Latvian (Standard)",
"00020427": "Lithuanian Standard",
"0x20427": "Lithuanian Standard",
"0002042b": "Armenian Phonetic",
"0x2042b": "Armenian Phonetic",
"0002042e": "Sorbian Standard",
"0x2042e": "Sorbian Standard",
"00020437": "Georgian (Ergonomic)",
"0x20437": "Georgian (Ergonomic)",
"00020445": "Bengali - INSCRIPT",
"0x20445": "Bengali - INSCRIPT",
"00020449": "Tamil 99",
"0x20449": "Tamil 99",
"0002083b": "Sami Extended Finland-Sweden",
"0x2083b": "Sami Extended Finland-Sweden",
"00020c00": "New Tai Lue",
"0x20c00": "New Tai Lue",
"00030402": "Bulgarian",
"0x30402": "Bulgarian",
"00030408": "Greek (220) Latin",
"0x30408": "Greek (220) Latin",
"00030409": "United States-Dvorak for left hand",
"0x30409": "United States-Dvorak for left hand",
"0003041e": "Thai Pattachote (non-ShiftLock)",
"0x3041e": "Thai Pattachote (non-ShiftLock)",
"0003042b": "Armenian Typewriter",
"0x3042b": "Armenian Typewriter",
"00030437": "Georgian Ministry of Education and Science Schools",
"0x30437": "Georgian Ministry of Education and Science Schools",
"00030c00": "Tai Le",
"0x30c00": "Tai Le",
"00040402": "Bulgarian (Phonetic Traditional)",
"0x40402": "Bulgarian (Phonetic Traditional)",
"00040408": "Greek (319) Latin",
"0x40408": "Greek (319) Latin",
"00040409": "United States-Dvorak for right hand",
"0x40409": "United States-Dvorak for right hand",
"00040437": "Georgian (Old Alphabets)",
"0x40437": "Georgian (Old Alphabets)",
"00040c00": "Ogham",
"0x40c00": "Ogham",
"00050408": "Greek Latin",
"0x50408": "Greek Latin",
"00050409": "US English Table for IBM Arabic 238_L",
"0x50409": "US English Table for IBM Arabic 238_L",
"00050429": "Persian (Standard)",
"0x50429": "Persian (Standard)",
"00060408": "Greek Polytonic",
"0x60408": "Greek Polytonic",
"00070c00": "Lisu (Basic)",
"0x70c00": "Lisu (Basic)",
"00080c00": "Lisu (Standard)",
"0x80c00": "Lisu (Standard)",
"00090c00": "N\u2019Ko",
"0x90c00": "N\u2019Ko",
"000a0c00": "Phags-pa",
"0xa0c00": "Phags-pa",
"000b0c00": "Buginese",
"0xb0c00": "Buginese",
"000c0c00": "Gothic",
"0xc0c00": "Gothic",
"000d0c00": "Ol Chiki",
"0xd0c00": "Ol Chiki",
"000e0c00": "Osmanya",
"0xe0c00": "Osmanya",
"000f0c00": "Old Italic",
"0xf0c00": "Old Italic",
"00100c00": "Sora",
"0x100c00": "Sora",
"00110c00": "Javanese",
"0x110c00": "Javanese",
"00120c00": "Futhark",
"0x120c00": "Futhark",
"00130c00": "Myanmar (Visual Order)",
"0x130c00": "Myanmar (Visual Order)",
"00140c00": "ADLaM",
"0x140c00": "ADLaM",
"00150c00": "Osage",
"0x150c00": "Osage"
}

Batch Transform Error for deepAR algorithm

Describe the bug
Hi,
I'm running the batch transforms from this Amazon SageMaker Batch Transform for the deepAR model implementation in the tutorial
Stock Price Prediction, using SageMaker DeepAR.
Batch transform code
from sagemaker.transformer import Transformer
model = session.create_model_from_job(estimator._current_job_name, name='{}-test'.format(estimator._current_job_name))
test_transformer = Transformer(model,
1,
'ml.m4.xlarge',
output_path='s3://sagemaker-eu-west-1-xxxxxxxxxxxx/sagemaker/stock-prediction/output',
sagemaker_session=session,
strategy='BatchStrategy',
assemble_with='Line')
test_transformer.transform('s3://sagemaker-eu-west-1-xxxxxxxxxxxx/sagemaker/stock-prediction/source/D/test/test.json', split_type='Line')
test_transformer.wait()
JSON input
{"start": "2018-07-24 00:00:00", "target": [81.73, 79.86, 83.39, 82.91, 82.91, 82.97, 82.97, 82.69, 81.5, 81.18, 82.34, 82.34, 83.51, 83.51, 84.05, 84.48, 84.81, 83.58, 83.58, 83.29, 83.29, 82.45, 81.31, 81.8, 81.41, 81.41, 81.75, 81.75, 82.93, 82.29, 81.08, 81.29, 81.29, 83.19, 83.19, 84.39, 84.23, 84.6, 83.41, 83.41, 82.79, 82.79, 81.88, 81.25, 80.73, 81.07, 81.07, 81.1, 81.1, 80.76, 81.32, 82.47, 82.93, 82.93, 82.54, 82.54, 82.67, 83.54, 85.32, 85.77, 85.77, 83.5, 83.5, 79.0, 79.03, 79.0, 77.71, 77.71, 78.14, 78.14, 78.7, 78.26, 78.26, 77.68, 77.68, 76.87, 76.87, 76.39, 75.35, 74.3, 74.49, 74.49, 75.21, 75.21, 75.75, 75.24, 75.13, 74.64, 74.64, 74.44, 74.44, 73.5, 72.69, 74.5, 75.02, 75.02, 76.4, 76.4], "dynamic_feat": [[82.2, 81.31, 83.39, 84.23, 84.23, 83.12, 83.12, 83.27, 82.28, 81.66, 83.02, 83.02, 84.38, 84.38, 84.79, 84.68, 85.42, 84.19, 84.19, 84.02, 84.02, 83.51, 82.93, 82.15, 81.78, 81.78, 82.45, 82.45, 83.15, 83.66, 81.76, 81.46, 81.46, 83.33, 83.33, 85.22, 84.68, 85.75, 83.98, 83.98, 82.89, 82.89, 82.95, 82.11, 81.84, 81.19, 81.19, 81.5, 81.5, 81.05, 81.45, 83.35, 83.25, 83.25, 83.05, 83.05, 83.81, 83.82, 85.48, 86.74, 86.74, 85.26, 85.26, 83.2, 79.03, 79.16, 78.44, 78.44, 78.7, 78.7, 79.44, 78.99, 78.99, 77.94, 77.94, 77.39, 77.39, 76.78, 76.0, 75.21, 75.52, 75.52, 75.86, 75.86, 75.98, 75.47, 76.4, 75.2, 75.2, 75.94, 75.94, 74.53, 74.09, 74.97, 75.02, 75.02, 79.38, 79.38], [81.06, 79.38, 81.22, 82.45, 82.45, 82.51, 82.51, 81.97, 80.88, 79.22, 82.11, 82.11, 82.86, 82.86, 84.05, 83.53, 84.57, 82.9, 82.9, 83.28, 83.28, 81.92, 80.79, 81.3, 80.46, 80.46, 81.73, 81.73, 81.95, 81.18, 80.92, 80.76, 80.76, 82.43, 82.43, 84.26, 83.52, 83.17, 83.21, 83.21, 82.15, 82.15, 81.44, 81.03, 80.43, 80.46, 80.46, 80.65, 80.65, 80.18, 80.37, 82.28, 82.42, 82.42, 82.04, 82.04, 82.26, 82.56, 83.85, 85.26, 85.26, 83.4, 83.4, 78.51, 77.35, 78.18, 77.32, 77.32, 78.09, 78.09, 78.0, 78.05, 78.05, 77.24, 77.24, 76.72, 76.72, 75.66, 75.12, 73.74, 74.3, 74.3, 73.8, 73.8, 75.25, 74.65, 75.06, 73.08, 73.08, 74.07, 74.07, 72.85, 72.44, 73.48, 73.62, 73.62, 75.33, 75.33], [81.13, 81.1, 81.59, 84.18, 84.18, 82.55, 82.55, 82.6, 81.88, 79.95, 82.32, 82.32, 82.96, 82.96, 84.56, 84.09, 84.77, 83.83, 83.83, 83.48, 83.48, 83.46, 82.86, 81.86, 81.46, 81.46, 82.1, 82.1, 82.06, 83.43, 81.76, 81.26, 81.26, 82.44, 82.44, 84.85, 84.57, 83.59, 83.63, 83.63, 82.46, 82.46, 82.68, 81.45, 81.48, 80.85, 80.85, 80.67, 80.67, 81.02, 81.25, 82.42, 82.58, 82.58, 82.14, 82.14, 83.5, 82.72, 83.93, 86.52, 86.52, 85.21, 85.21, 82.98, 77.98, 78.19, 77.59, 77.59, 78.31, 78.31, 78.85, 78.55, 78.55, 77.64, 77.64, 77.16, 77.16, 76.65, 75.89, 73.86, 74.63, 74.63, 74.49, 74.49, 75.42, 75.27, 76.19, 74.16, 74.16, 75.89, 75.89, 73.16, 73.42, 73.59, 73.86, 73.86, 75.48, 75.48]]}
{"start": "2018-07-24 00:00:00", "target": [196.9, 193.9, 197.8, 197.3, 197.3, 197.45, 197.45, 197.0, 189.85, 186.45, 184.45, 184.45, 186.65, 186.65, 188.15, 188.05, 189.0, 186.5, 186.5, 187.45, 187.45, 185.9, 182.9, 184.05, 182.65, 182.65, 184.9, 184.9, 185.3, 160.85, 153.95, 155.45, 155.45, 160.1, 160.1, 159.9, 160.35, 161.1, 158.05, 158.05, 156.6, 156.6, 155.15, 152.7, 151.4, 150.15, 150.15, 150.35, 150.35, 147.0, 149.6, 149.35, 150.7, 150.7, 151.1, 151.1, 150.0, 151.9, 158.0, 159.1, 159.1, 156.8, 156.8, 152.9, 151.7, 151.5, 149.95, 149.95, 151.5, 151.5, 152.75, 146.95, 146.95, 144.3, 144.3, 143.85, 143.85, 143.1, 139.2, 137.0, 140.15, 140.15, 138.4, 138.4, 140.6, 138.95, 137.75, 131.5, 131.5, 133.3, 133.3, 133.3, 129.45, 138.5, 136.1, 136.1, 143.55, 143.55], "dynamic_feat": [[197.25, 196.25, 198.1, 198.35, 198.35, 198.3, 198.3, 197.7, 196.45, 186.8, 187.75, 187.75, 188.65, 188.65, 189.35, 188.4, 190.05, 187.1, 187.1, 188.45, 188.45, 187.25, 186.35, 185.0, 183.9, 183.9, 186.05, 186.05, 185.65, 186.1, 158.95, 155.95, 155.95, 161.4, 161.4, 160.15, 160.7, 162.45, 159.55, 159.55, 157.6, 157.6, 157.55, 155.2, 153.55, 152.15, 152.15, 151.9, 151.9, 150.55, 149.85, 151.5, 151.35, 151.35, 151.8, 151.8, 151.7, 152.45, 158.4, 160.35, 160.35, 157.95, 157.95, 156.85, 151.9, 151.7, 151.1, 151.1, 152.75, 152.75, 154.25, 148.25, 148.25, 144.45, 144.45, 144.0, 144.0, 145.1, 142.0, 140.1, 141.3, 141.3, 140.55, 140.55, 142.3, 139.45, 140.75, 133.0, 133.0, 134.6, 134.6, 134.25, 133.85, 140.95, 136.2, 136.2, 146.65, 146.65], [194.0, 192.5, 195.7, 196.15, 196.15, 196.75, 196.75, 195.25, 189.3, 183.0, 184.05, 184.05, 185.25, 185.25, 187.7, 186.55, 187.85, 185.35, 185.35, 186.05, 186.05, 184.55, 182.05, 183.15, 181.25, 181.25, 184.6, 184.6, 184.0, 157.9, 153.35, 154.1, 154.1, 157.05, 157.05, 157.75, 159.3, 159.1, 157.95, 157.95, 155.95, 155.95, 154.45, 149.75, 151.35, 148.85, 148.85, 150.25, 150.25, 146.65, 146.75, 149.25, 149.25, 149.25, 150.25, 150.25, 148.8, 149.65, 154.0, 158.3, 158.3, 156.35, 156.35, 151.6, 148.5, 149.65, 148.95, 148.95, 150.4, 150.4, 151.15, 145.05, 145.05, 141.4, 141.4, 142.5, 142.5, 142.35, 138.8, 136.1, 137.6, 137.6, 137.5, 137.5, 139.35, 137.75, 137.7, 127.9, 127.9, 132.25, 132.25, 130.6, 129.15, 130.9, 133.1, 133.1, 135.9, 135.9], [194.15, 195.75, 196.05, 198.2, 198.2, 196.85, 196.85, 196.7, 195.65, 183.6, 186.9, 186.9, 185.8, 185.8, 188.5, 187.5, 188.3, 186.5, 186.5, 186.35, 186.35, 186.95, 186.15, 184.25, 182.6, 182.6, 184.9, 184.9, 184.0, 185.65, 158.5, 155.25, 155.25, 157.8, 157.8, 159.8, 159.9, 159.95, 158.9, 158.9, 156.9, 156.9, 157.25, 154.3, 151.85, 151.85, 151.85, 150.55, 150.55, 150.2, 148.6, 149.9, 151.15, 151.15, 150.5, 150.5, 151.55, 150.05, 154.1, 159.65, 159.65, 157.6, 157.6, 156.25, 150.75, 150.3, 150.15, 150.15, 151.1, 151.1, 152.2, 148.25, 148.25, 143.6, 143.6, 143.4, 143.4, 144.75, 141.7, 136.1, 139.05, 139.05, 140.15, 140.15, 139.4, 139.4, 140.55, 132.7, 132.7, 134.55, 134.55, 131.6, 133.1, 131.4, 135.35, 135.35, 136.8, 136.8]]}
{"start": "2018-07-24 00:00:00", "target": [59.14, 57.88, 59.51, 59.29, 59.29, 59.35, 59.35, 59.15, 58.24, 57.41, 58.16, 58.16, 58.25, 58.25, 58.89, 59.06, 59.04, 57.2, 57.2, 57.23, 57.23, 56.45, 55.05, 55.29, 54.92, 54.92, 55.29, 55.29, 55.87, 55.3, 54.41, 54.75, 54.75, 56.11, 56.11, 56.3, 56.67, 56.65, 55.7, 55.7, 55.0, 55.0, 54.2, 54.28, 54.32, 54.48, 54.48, 54.5, 54.5, 54.05, 54.53, 55.09, 55.54, 55.54, 55.41, 55.41, 55.77, 56.32, 57.21, 57.61, 57.61, 56.13, 56.13, 54.74, 54.83, 55.59, 54.35, 54.35, 54.88, 54.88, 56.0, 56.44, 56.44, 55.61, 55.61, 54.6, 54.6, 54.42, 53.6, 52.7, 52.89, 52.89, 52.92, 52.92, 53.23, 52.76, 52.41, 51.39, 51.39, 50.81, 50.81, 50.48, 50.0, 51.35, 51.37, 51.37, 52.43, 52.43], "dynamic_feat": [[59.72, 58.79, 59.75, 59.6, 59.6, 59.62, 59.62, 59.59, 58.85, 57.71, 58.53, 58.53, 58.99, 58.99, 59.4, 59.27, 59.38, 58.11, 58.11, 57.86, 57.86, 57.35, 56.71, 55.72, 55.29, 55.29, 55.59, 55.59, 55.99, 56.37, 54.97, 55.0, 55.0, 56.21, 56.21, 56.98, 56.73, 57.33, 56.27, 56.27, 55.44, 55.44, 54.98, 54.66, 55.09, 54.5, 54.5, 54.68, 54.68, 54.45, 54.54, 55.61, 56.14, 56.14, 55.85, 55.85, 56.47, 56.47, 57.56, 58.81, 58.81, 57.08, 57.08, 56.16, 54.88, 55.61, 55.36, 55.36, 55.1, 55.1, 56.43, 57.09, 57.09, 55.94, 55.94, 55.26, 55.26, 54.6, 54.3, 53.39, 53.84, 53.84, 53.21, 53.21, 53.54, 52.88, 53.52, 52.25, 52.25, 52.22, 52.22, 50.86, 51.35, 51.77, 51.37, 51.37, 54.53, 54.53], [58.42, 57.31, 57.82, 58.89, 58.89, 59.17, 59.17, 58.82, 58.06, 56.76, 57.69, 57.69, 58.09, 58.09, 58.85, 58.59, 58.84, 56.97, 56.97, 57.23, 57.23, 56.06, 54.75, 55.05, 54.22, 54.22, 55.16, 55.16, 54.84, 54.36, 54.35, 54.35, 54.35, 55.17, 55.17, 56.3, 56.01, 55.69, 55.63, 55.63, 54.75, 54.75, 53.86, 53.87, 54.25, 54.1, 54.1, 54.0, 54.0, 53.75, 53.78, 55.02, 55.16, 55.16, 55.13, 55.13, 55.32, 55.84, 56.51, 57.36, 57.36, 56.05, 56.05, 54.22, 53.73, 54.47, 54.12, 54.12, 54.33, 54.33, 55.26, 56.27, 56.27, 55.37, 55.37, 54.54, 54.54, 53.63, 53.52, 52.13, 52.75, 52.75, 52.03, 52.03, 53.0, 52.28, 52.37, 48.77, 48.77, 50.81, 50.81, 49.78, 49.84, 50.57, 50.34, 50.34, 51.37, 51.37], [58.43, 58.59, 57.86, 59.54, 59.54, 59.21, 59.21, 59.46, 58.54, 57.16, 57.78, 57.78, 58.31, 58.31, 59.25, 58.88, 59.0, 57.81, 57.81, 57.52, 57.52, 57.26, 56.69, 55.48, 55.1, 55.1, 55.51, 55.51, 54.92, 56.14, 54.88, 54.84, 54.84, 55.18, 55.18, 56.62, 56.35, 55.83, 55.94, 55.94, 55.21, 55.21, 54.85, 53.91, 54.5, 54.37, 54.37, 54.09, 54.09, 54.44, 54.11, 55.35, 55.44, 55.44, 55.26, 55.26, 56.37, 56.09, 56.73, 58.56, 58.56, 57.03, 57.03, 55.97, 53.86, 54.47, 54.94, 54.94, 54.35, 54.35, 56.06, 56.7, 56.7, 55.89, 55.89, 55.11, 55.11, 54.52, 54.13, 52.15, 53.22, 53.22, 52.89, 52.89, 53.14, 52.77, 53.31, 51.83, 51.83, 52.07, 52.07, 50.09, 50.83, 50.69, 50.74, 50.74, 51.4, 51.4]]}
{"start": "2018-07-24 00:00:00", "target": [57.1, 55.92, 58.18, 58.38, 58.38, 58.32, 58.32, 57.9, 56.2, 55.02, 56.02, 56.02, 56.0, 56.0, 55.86, 57.14, 56.88, 55.42, 55.42, 55.06, 55.06, 54.8, 53.74, 53.72, 53.4, 53.4, 53.76, 53.76, 54.42, 53.92, 53.24, 53.44, 53.44, 55.02, 55.02, 55.76, 55.44, 55.28, 54.52, 54.52, 53.6, 53.6, 52.9, 52.7, 52.22, 52.06, 52.06, 52.0, 52.0, 51.6, 51.7, 52.84, 54.72, 54.72, 55.56, 55.56, 57.14, 58.36, 59.08, 59.12, 59.12, 58.34, 58.34, 57.54, 57.58, 58.72, 58.0, 58.0, 58.4, 58.4, 58.3, 57.9, 57.9, 57.1, 57.1, 56.04, 56.04, 56.06, 54.52, 53.42, 53.4, 53.4, 54.84, 54.84, 57.0, 56.46, 55.9, 55.0, 55.0, 54.62, 54.62, 53.88, 50.78, 51.76, 51.56, 51.56, 53.52, 53.52], "dynamic_feat": [[57.42, 56.92, 58.36, 58.72, 58.72, 58.46, 58.46, 58.44, 57.58, 55.4, 56.44, 56.44, 56.64, 56.64, 57.22, 57.24, 57.36, 56.32, 56.32, 55.46, 55.46, 55.52, 54.98, 54.38, 53.78, 53.78, 54.34, 54.34, 54.62, 55.2, 53.8, 53.46, 53.46, 55.36, 55.36, 56.08, 55.54, 56.32, 54.94, 54.94, 54.52, 54.52, 53.74, 53.16, 53.08, 52.06, 52.06, 52.22, 52.22, 52.0, 51.82, 53.28, 55.46, 55.46, 55.8, 55.8, 57.56, 58.44, 59.44, 60.46, 60.46, 58.84, 58.84, 59.02, 57.62, 59.24, 58.2, 58.2, 58.94, 58.94, 58.8, 58.62, 58.62, 57.52, 57.52, 56.48, 56.48, 56.6, 55.76, 53.86, 54.38, 54.38, 55.64, 55.64, 57.66, 56.94, 57.16, 55.32, 55.32, 56.0, 56.0, 54.0, 53.52, 52.08, 51.56, 51.56, 54.72, 54.72], [55.94, 55.88, 57.54, 57.98, 57.98, 58.1, 58.1, 57.7, 55.78, 54.38, 55.5, 55.5, 55.8, 55.8, 55.86, 55.86, 56.74, 54.44, 54.44, 54.68, 54.68, 54.34, 53.3, 53.32, 52.36, 52.36, 53.62, 53.62, 53.7, 53.34, 53.12, 52.88, 52.88, 53.88, 53.88, 55.64, 54.82, 54.42, 54.32, 54.32, 52.98, 52.98, 52.38, 52.48, 52.14, 51.22, 51.22, 51.66, 51.66, 51.32, 51.44, 51.82, 53.44, 53.44, 54.94, 54.94, 56.62, 57.4, 58.34, 58.66, 58.66, 58.08, 58.08, 56.9, 56.66, 57.36, 57.2, 57.2, 58.1, 58.1, 57.68, 57.74, 57.74, 56.96, 56.96, 56.02, 56.02, 55.42, 54.32, 52.86, 53.26, 53.26, 53.2, 53.2, 53.86, 55.74, 55.84, 53.48, 53.48, 54.26, 54.26, 53.08, 50.78, 51.24, 50.42, 50.42, 51.56, 51.56], [56.0, 56.48, 58.08, 58.18, 58.18, 58.22, 58.22, 58.08, 57.14, 54.9, 55.56, 55.56, 56.44, 56.44, 57.0, 56.04, 57.28, 55.86, 55.86, 54.74, 54.74, 55.5, 54.96, 54.1, 53.34, 53.34, 53.92, 53.92, 53.76, 54.86, 53.8, 53.24, 53.24, 53.9, 53.9, 55.88, 55.54, 54.7, 54.42, 54.42, 54.52, 54.52, 53.46, 52.76, 52.7, 52.06, 52.06, 51.68, 51.68, 52.0, 51.7, 51.9, 53.56, 53.56, 55.1, 55.1, 56.96, 57.54, 58.46, 60.26, 60.26, 58.44, 58.44, 58.74, 56.82, 57.36, 57.64, 57.64, 58.28, 58.28, 58.62, 58.34, 58.34, 57.44, 57.44, 56.32, 56.32, 56.44, 55.6, 53.06, 54.2, 54.2, 53.4, 53.4, 55.76, 56.92, 56.96, 55.2, 55.2, 55.92, 55.92, 53.42, 53.16, 51.6, 51.16, 51.16, 51.56, 51.56]]}
{"start": "2018-07-24 00:00:00", "target": [150.38, 145.92, 151.7, 151.12, 151.12, 151.46, 151.46, 152.22, 146.6, 143.4, 145.34, 145.34, 145.48, 145.48, 146.88, 147.82, 147.84, 144.38, 144.38, 143.98, 143.98, 142.9, 138.44, 139.44, 138.74, 138.74, 139.0, 139.0, 140.72, 138.82, 137.94, 138.0, 138.0, 141.46, 141.46, 143.38, 143.16, 142.86, 140.84, 140.84, 137.94, 137.94, 136.2, 136.14, 136.24, 136.08, 136.08, 137.5, 137.5, 137.38, 138.4, 140.78, 144.0, 144.0, 144.48, 144.48, 148.24, 151.1, 152.5, 154.38, 154.38, 152.94, 152.94, 150.48, 151.3, 153.86, 151.6, 151.6, 152.5, 152.5, 152.94, 152.08, 152.08, 149.3, 149.3, 147.0, 147.0, 146.54, 143.54, 140.48, 140.16, 140.16, 144.42, 144.42, 147.42, 147.1, 145.58, 143.98, 143.98, 142.34, 142.34, 139.7, 133.7, 137.0, 136.88, 136.88, 142.42, 142.42], "dynamic_feat": [[151.6, 148.98, 152.34, 153.42, 153.42, 152.2, 152.2, 153.36, 151.6, 143.9, 145.62, 145.62, 147.08, 147.08, 149.1, 148.72, 148.8, 146.78, 146.78, 144.92, 144.92, 144.68, 143.36, 140.74, 139.32, 139.32, 140.62, 140.62, 141.16, 142.3, 138.52, 138.4, 138.4, 142.14, 142.14, 144.92, 143.52, 145.36, 141.4, 141.4, 139.18, 139.18, 138.3, 137.2, 138.04, 136.32, 136.32, 138.94, 138.94, 137.76, 138.56, 141.88, 144.7, 144.7, 145.26, 145.26, 150.24, 151.96, 154.1, 157.2, 157.2, 153.62, 153.62, 155.0, 151.54, 155.68, 152.52, 152.52, 154.46, 154.46, 154.46, 154.26, 154.26, 150.68, 150.68, 147.76, 147.76, 148.06, 146.1, 142.8, 142.62, 142.62, 146.72, 146.72, 149.32, 147.4, 149.3, 144.84, 144.84, 146.78, 146.78, 140.74, 139.54, 137.88, 136.88, 136.88, 146.34, 146.34], [148.84, 145.26, 149.66, 150.52, 150.52, 150.92, 150.92, 150.7, 145.36, 140.38, 143.34, 143.34, 144.92, 144.92, 146.8, 146.04, 146.64, 143.24, 143.24, 143.68, 143.68, 142.34, 137.46, 138.9, 136.54, 136.54, 139.0, 139.0, 138.02, 136.66, 137.52, 136.86, 136.86, 139.3, 139.3, 143.38, 141.64, 140.66, 140.12, 140.12, 136.42, 136.42, 134.9, 135.42, 135.54, 134.2, 134.2, 135.6, 135.6, 136.04, 136.56, 140.68, 141.14, 141.14, 143.2, 143.2, 146.5, 149.3, 151.9, 152.8, 152.8, 151.2, 151.2, 149.06, 147.94, 150.44, 149.86, 149.86, 152.08, 152.08, 151.68, 151.86, 151.86, 149.02, 149.02, 146.56, 146.56, 144.54, 142.88, 138.1, 140.12, 140.12, 139.66, 139.66, 145.0, 145.52, 145.4, 139.16, 139.16, 141.68, 141.68, 138.54, 133.0, 135.0, 134.02, 134.02, 137.92, 137.92], [149.02, 148.64, 150.44, 153.32, 153.32, 151.82, 151.82, 151.32, 150.12, 142.12, 143.76, 143.76, 145.3, 145.3, 147.72, 146.94, 147.5, 145.56, 145.56, 144.06, 144.06, 144.54, 143.34, 140.06, 138.06, 138.06, 140.3, 140.3, 138.3, 141.78, 138.16, 138.08, 138.08, 139.34, 139.34, 144.72, 143.38, 141.74, 140.48, 140.48, 138.26, 138.26, 138.0, 136.24, 136.1, 135.94, 135.94, 135.6, 135.6, 137.46, 137.92, 140.98, 141.38, 141.38, 143.64, 143.64, 149.14, 149.66, 152.2, 156.9, 156.9, 151.72, 151.72, 153.92, 148.38, 150.46, 151.34, 151.34, 152.58, 152.58, 154.06, 153.48, 153.48, 150.46, 150.46, 147.6, 147.6, 147.8, 145.62, 138.32, 141.8, 141.8, 140.16, 140.16, 146.96, 147.4, 148.96, 143.52, 143.52, 146.56, 146.56, 139.58, 138.58, 136.08, 135.3, 135.3, 137.98, 137.98]]}
JSON.out
And when I open the output file JSON.out, it has 5 lines like the one below. (each line for each stock unique instance I guess).
I also got this error when run batch transforms on Console.
{"error":"The field dynamic_feat needs to be provided in the full prediction range but request has dynamic_feat only for 0 time units in the prediction range when trying to predict for 91 time units."}
To reproduce
Replace the Forecasting and Plotting code in the deepAR notebook with Batch Transform.
Expected behavior
A clear and concise description of what you expected to happen.
JSON output has values of 3 months for targeted stock.
System information
SageMaker Python SDK version:
Framework name (eg. PyTorch) or algorithm (eg. KMeans):
Framework version:
Python version: 3.7.7
CPU or GPU: CPU
Custom Docker image (Y/N): N
I think you had a description of what is expected by the batch transform job.
Batch transform predicts future values. Since you have prediction horizon of 91 time units (mentioned in the error message), it is expected that you provide dynamic features for all that time units.
As stated in the documentation:
If the model was trained with the dynamic_feat field, you must provide
this field for inference. In addition, each of the features has to have the length of the provided target plus the prediction_length. In other words, you must provide the feature value in the future.
Now your target and each dynamic feature have 97 values. It is expected that you provide additional 91 values for each dynamic feature. Taking into account these additional 91 values, predictions of the target will be made.
Precisely!
If you train with dynamic features, you're basically giving the model an auxiliary regression.
That is: For the model to predict x periods in the future, it will need the values of the auxiliary regression on those x periods.
So, if you trained with dynamic features, imagine you are doing inference with a time series of 10 time steps and predicting the next 3.
Your input of the time series will be (length 10):
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
But your input dynamic feature series must be (length 13):
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, x1, x2. x3]

luabind 'Trying to use unregistered class' on return

I'm currently using luabind to bind a class (sf::Time from SFML 2.0 to be exact), and I keep getting an exception from luabind. Here is my binding code:
using namespace luabind;
module(L, "system")
[
class_<sf::Time>("Time")
.def(constructor<>())
.def("toSeconds", &sf::Time::asSeconds)
.def("toMilliseconds", &sf::Time::asMilliseconds)
.def("toMicroseconds", &sf::Time::asMicroseconds)
.def(self == other<sf::Time>())
.def(self < other<sf::Time>())
.def(self <= other<sf::Time>())
.def(self - other<sf::Time>())
.def(self + other<sf::Time>())
.def(self * float())
.def(self / float())
.scope
[
def("seconds", &sf::seconds),
def("milliseconds", &sf::milliseconds),
def("microseconds", &sf::microseconds)
],
...
My lua code is:
local t = system.Time.seconds(10)
The signature of sf::seconds is:
sf::Time sf::seconds(float)
I've tried wrapping the call to sf::seconds in my own function that returns sf::Time, and I tried using sf::Time* as the return value as well. No matter what, I keep getting the error.
Any ideas?
EDIT:
I have tested the class its self, and i can create it in Lua using system.Time(), no problem. All the methods work correctly, but system.Time.seconds and the other static methods don't work.