import rasterfairy
import json
import numpy as np

with open('/home/te/projects/ml4a-ofx/points.json') as json_file:
    data = json.load(json_file)

for j in data:
    print(j['point'])

    print("**************************************")
    
full_data = np.asarray( data )
#  {'path': '/home/te/projects/ml4a-ofx/images/20190902-0853_4.jpg', 'point': [0.1758463829755783, 0.3165808618068695]}
#for entry in full_data:
#    print (entry)


#print(full_data)

arr = np.asarray( [[1000, 2000], [2, 30], [8, 100], [300, 2]])
print(arr)
tsne = np.asarray(arr)
print(tsne)

# nx * ny = 1000, the number of images
nx = 2
ny = 2

# assign to grid
#grid = rasterfairy.transformPointCloud2D(tsne)
grid = rasterfairy.transformPointCloud2D(tsne, target=(nx, ny))
print(grid)



@@ -42,16 +42,161 @@
 py as np
+%0Aimport math%0A%0A# Expects output from tSNE-images.py and runs rasterfairy on the input,%0A# writing the image paths layed out to a grid as the output
 %0A%0Awith o
@@ -292,13 +292,24 @@
 e)%0A%0A
+arr = %5B%5D%0A
 for 
-j
+tup
  in 
@@ -323,14 +323,18 @@
    p
-rint(j
+oint = tup
 %5B'po
@@ -342,68 +342,130 @@
 nt'%5D
+%0A    arr.append(%5Bpoint%5B0%5D, point%5B1%5D%5D
 )%0A
-%0A
+#
     
-print(%22**************************************%22)%0A    %0A
+arr.append(%5Bmath.floor(point%5B0%5D*100000000), math.floor(point%5B1%5D*100000000)%5D)%0A%0A#
 full
@@ -676,16 +676,17 @@
 _data)%0A%0A
+#
 arr = np
@@ -740,16 +740,17 @@
 0, 2%5D%5D)%0A
+#
 print(ar
@@ -775,16 +775,17 @@
 ay(arr)%0A
+#
 print(ts
@@ -793,78 +793,67 @@
 e)%0A%0A
-# 
 nx 
-* ny = 1000, the number of images%0A
+= 15%0Any = 21%0A%0A# 16x20 hangs forever!?%0A#
 nx = 
-2%0A
+16%0A#
 ny = 2
+0
 %0A
-%0A# assign to grid
 %0A#gr
@@ -901,78 +901,724 @@
 ne)%0A
-grid = rasterfairy.transformPointCloud2D(tsne, target=(nx, ny))%0Aprint(
+print(%22Calling rasterfairy on %22 + str(len(arr)) + %22 coordinates%22)%0AgridAssignment = rasterfairy.transformPointCloud2D(tsne, target=(nx, ny))%0Agrid, gridShape = gridAssignment%0A%0Aout_grid = %5B%5D%0Afor i, dat in enumerate(data):%0A    gridX, gridY = grid%5Bi%5D%0A    out_grid.append(%7B'gx': int(gridX), 'gy': int(gridY), 'path': dat%5B'path'%5D%7D)%0A#    print(dat%5B'path'%5D + %22 gx:%22 + str(int(gridX)) + %22, gy:%22 + str(int(gridY)))%0A%0A#out_grid = out_grid.sort(key = lambda obj: obj%5B'gx'%5D, obj%5B'gy'%5D)%0A%0A# We sort by secondary first - Python sort is stable; it does not change order on equal keys%0Aout_grid.sort(key = lambda obj: obj%5B'gy'%5D)%0Aout_grid.sort(key = lambda obj: obj%5B'gx'%5D)%0A%0Afor element in out_grid:%0A    print(element%5B'path'%5D)%0A%0A#print(out_
 grid

Add first real take