Connection
Base URL, credentials and a reachable server.
Interleave two nonnegative integer grid coordinates into a Morton index with a declared bit width.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
def morton2(x, y, bits):
if type(bits) is not int or not 1 <= bits <= 16:
raise ValueError("bits.range")
if any(type(v) is not int or not 0 <= v < (1 << bits)
for v in (x, y)):
raise ValueError("coordinate.range")
result = 0
for i in range(bits):
result |= ((x >> i) & 1) << (2 * i)
result |= ((y >> i) & 1) << (2 * i + 1)
return result