Hey everyone!
I found a bug in the process of converting a dataset to buffer with the “tobuffer” method. The issue is only present in datasets loaded from a JSON file, and I think it stems from the point identifier being converted to a symbol at some point in the writing/reading chain (so the order of the elements in the buffer after importing is for example 1, 10, 100, etc). If it’s not clear, I have a patch that demonstrates the bug (it doesn’t let me attach it here tho).
Cheers!
Thanks for the bug report! If you .zip the patch it should let you upload it.
If you have a GitHub account, you can report the bug there too!
thanks for the bug report. I’m investigating with a simpler patch and will report here, and on github
Hello
Good news, there is no bug 
Bad news, there is a bit that needs explaining better. I think the problem stems from the sentence:
because, actually, the identifier is never a number. it is always a symbol. So JSON orders it the way text is ordered. But a user can never rely on the order to stay the same. this is why there is a labelset that is also dumped when you do `tobuffer` - to get a map that is useful in the future between labels and channel-in-the-buffer.
I’ve made a small explanation patch, with 3 points (ID ‘1’ ‘2’ and ‘10’) with growing value. In it, there are 2 ways to create the dataset (via a dict and via 3 entries) and already, even before saving, the order is not the same. There is also a demo of how to use the ‘label’ when using `tobuffer`.
I hope this helps. Let me know if anything is still unclear.
p
----------begin_max5_patcher----------
1395.3oc2ZssaihCF95jmBKzL2kFgs4PHWsuGqVU4.NsdJXPfosiFM8Ye8AX
R5lvwXhlYUkfB3vu+9O98ayOVux4P96zJGvdveCVs5GqWsReK0MV0b8JmLx6
wojJ8vb3z2xO7MmMlGInuKz2NMmjbfvep8A40hTpP78Bp4k6neH3eZdbAQD+
Li+zikzXgYDgdnsta.He0Q+c5+Wdme8S30YLt7cpmFvlaxRzRWNid.56bZjF
waFp5l+b8Z0gMiDjw4YYTt3BT5uG7LsjBdiBhIbPbIkHn.lflUAXb.gmKjOG
jWlPKa+woLNMNulqeCnV7WRqjBfHX47Gu9HtTCgifJsRPj5HLJPcBimhJx85
pHWKph71CRIGnoUfG.YMX.D+Lgyoof2XhmadrysnIBCwZuDWiKCVqWPtSPUr
a40D38.Q9g5iREg1g.Pp.z2Kjffl3zC1vtZCaD9Ly7jvV3xiMzdPRcVgDZo4
4u.HBfzw+y98Wy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juMzd
5WBb.IEYKAMnxy0VRBMjxyyBRp0qpeubKHn1Px9ia8sgj7FCjrQzDdLNDHea
II3XjD7VkD7N4PfhtWBJXD5NLxVRZP+AajJRszhClf.ZMIMj1CZiTQpUNeXs
mMRuBGSFhVi4sIo6UzjdEPFAckcVQVSoPXyfxXlcOtg1mZEGU6gendgGih90
E25baLdqtW5tZ3kRJJdkVV0LbsPjLw+Vdo5xcazWx3lKCzWVRek0Nd8mWhCo
TxqVHIUWWZ9RRdOvzvmSVdBsjWyZZCPBOoH0r7Ue0IUEj3lO8DYy.q+45+Ef
Ac76c
-----------end_max5_patcher-----------
while the other patch is opened, you can see how frombuffer can be used to retrieve things in the right order. that also allows your IDs to be text-for-real.
----------begin_max5_patcher----------
406.3ocqSssbBBCD8Y3qHSdlx.TCR6uRGmNQXUSGHgIInzww9s2vB5Xq3kZ8
AHrmrrmyI6ls9dz4pVvPIuRdi34s02yCg5.7Fh8nU717RtASiJgMp4ePC52x
BsVDdQYinHrfa4Fv9EgKU1UfVIg8YJapTM1RvhkIY.sGx9YMzqAJMv8PlMrs
n.KtivmXGUHgbechG.q417UB4x20PtsuTwrnvn.RbVJtLYR2RRRXDYV2+ry2
u6UvMZ6BQtMbs.1LtehNUvwQY+cI+LJR1KnjSSBylxbeLkcmp9LMKsS4.ono
p9Q0chilLpYSttYSPyN8+0dp.iguDNcrTqpl2rXAnICKQjR9bnzDbA+GeV+O
l2uWmGyX3xzrQsNREsTH+88Srhc3+77vnZz46E5vMFR7AAW.FqPxsBk7nbv9
F4bm42JSC03hLwd.7bPsWwSYmvU+gIutdMnMCoiz3Fi9Po6ByBvPgrOLEC0v
Zw97YHBW6ZmVWurQiRi1l1O.PqTEfV1HvIH+NC5nDGQkb27YMu2K3jr+N+uA
tagRo.
-----------end_max5_patcher-----------
That’s great! Thanks for the explanation 
1 Like
I will put a note in the helpfiles to stress the -non-numeral- aspect of the identifiers, and therefore their -alphabetical- sorting to/from json… and the consequences for to-from-buffer-ing.
p
That’d be useful as it’s very easy to accidentally turn “1”, “10”, “100” into 0, 1, 2 when moving in and out of dicts and colls.
I’ve argued for the ability to treat identifiers explicitly as numbers in the past (I’m sure) specifically for things like this that are invisibly error prone.
Being able to have paths or arbitrary symbols in there is definitely nice, but I’ve never ever done that. I’ve only ever used the identifier as a number, and specifically an int to boot!