d2xy() and xy2d() don't appear to be working correctly.
(I haven't been able to get get_chrom_range() to be consistent, and I think I narrowed it down to d2xy and xy2d)
My understanding is if you feed a distance d to d2xy() and get back coords x and y, and then turn around and feed that same x and y back into xy2d(), you ought to get back the original d. But this snippet shows that's not the case:
from scurgen import hilbert
n = 4
for d in range(n * n):
x, y = hilbert.d2xy(n, d)
d2 = hilbert.xy2d(n, x, y)
flag = ""
if d != d2:
flag = "***"
print d, d2, flag
d2xy() and xy2d() don't appear to be working correctly.
(I haven't been able to get get_chrom_range() to be consistent, and I think I narrowed it down to d2xy and xy2d)
My understanding is if you feed a distance
d
tod2xy()
and get back coordsx
andy
, and then turn around and feed that samex
andy
back intoxy2d()
, you ought to get back the originald
. But this snippet shows that's not the case:Here's the output, with mismatches flagged:
I don't fully understand all the AND and XORs in these two algorithms, so I'm stuck at this point.