pydenticon icon indicating copy to clipboard operation
pydenticon copied to clipboard

The generator does not work with non-square output sizes

Open benelot opened this issue 2 years ago • 3 comments

I tried to print pydenticons for my numpy matrices, which works quite well for square input, but gets a problem with non-square identicons.

data = np.array2string(np_array)

# Instantiate a generator.
generator = Generator(10, 3, digest=hashlib.sha256)

# Call the method and get the results.
asciidenticon = generator.generate(data, 10, 3, output_format="ascii")
print(asciidenticon)

Am I using it incorrectly?

benelot avatar Feb 22 '23 11:02 benelot

Interestingly, this way around it works quite well, but the height of 4 seems to cause issues, saying two matrices are equal when they are not. But this is related to the vertical symmetry property of the identicons, reducing the entropy of the identicon massively to only a few bits.

data = np.array2string(np_array)

# Instantiate a generator.
generator = Generator(4, 25, digest=hashlib.sha256)

# Call the method and get the results.
asciidenticon = generator.generate(data, 4, 25, output_format="ascii")
print(asciidenticon)

benelot avatar Feb 22 '23 11:02 benelot

Hm... You know, I wouldn't be surprised if I never tested with non-square output size. When you say you face a problem, can you elaborate a bit?

azaghal avatar Feb 22 '23 22:02 azaghal

Haha, yes I thought so. It is rather atypical to have them non-square, but I use them to compare to numpy matrices so I quickly see if they are the same, so I print the ascii version to console. If I use a non-square output size, I get a classical array index out of bounds error.

benelot avatar Feb 25 '23 21:02 benelot