@@ -141,10 +141,11 @@ def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2):
141
141
"""
142
142
import numpy as np
143
143
144
+ center_pad = 1
144
145
tile_center = t // 2
145
- tile_length = t + 3 # 1 for middle of cross, 2 for spacing between tiles
146
+ tile_length = t + 2 + center_pad # 2 for spacing between tiles
146
147
# want the enter plot to fill in [0, 1] when scale=1
147
- scale /= max (m , n ) * tile_length - 3
148
+ scale /= max (m , n ) * tile_length - 2 - center_pad
148
149
149
150
grid_offsets = {}
150
151
@@ -153,10 +154,11 @@ def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2):
153
154
else :
154
155
center = np .asarray (center )
155
156
156
- paddims = dim - 2
157
- if paddims < 0 :
157
+ if dim < 2 :
158
158
raise ValueError ("layout must have at least two dimensions" )
159
159
160
+ paddims = np .zeros (dim - 2 , dtype = 'float' )
161
+
160
162
if len (center ) != dim :
161
163
raise ValueError ("length of center coordinates must match dimension of layout" )
162
164
@@ -167,24 +169,24 @@ def _xy_coords(i, j, u, k):
167
169
if k < tile_center :
168
170
p = k
169
171
else :
170
- p = k + 1
172
+ p = k + center_pad
171
173
172
174
if u :
173
- xy = np .array ([tile_center , - 1 * p ])
175
+ xy = np .array ([tile_center , - 1 * p ], dtype = 'float' )
174
176
else :
175
- xy = np .array ([p , - 1 * tile_center ])
177
+ xy = np .array ([p , - 1 * tile_center ], dtype = 'float' )
176
178
177
179
# next offset the corrdinates based on the which tile
178
180
if i > 0 or j > 0 :
179
181
if (i , j ) in grid_offsets :
180
182
xy += grid_offsets [(i , j )]
181
183
else :
182
- off = np .array ([j * tile_length , - 1 * i * tile_length ])
184
+ off = np .array ([j * tile_length , - 1 * i * tile_length ], dtype = 'float' )
183
185
xy += off
184
186
grid_offsets [(i , j )] = off
185
187
186
188
# convention for Chimera-lattice pictures is to invert the y-axis
187
- return np .hstack ((xy * scale , np . zeros ( paddims ) )) + center
189
+ return np .hstack ((xy * scale , paddims )) + center
188
190
189
191
return _xy_coords
190
192
0 commit comments