kedartatwawadi / stanford_compression_library

The goal of the library is to help with research in the area of data compression. This is not meant to be fast or efficient implementation, but rather for educational purpose
MIT License
76 stars 24 forks source link

The default int type of numpy in arithmetic_coding.py #98

Open LongtaoTang opened 5 months ago

LongtaoTang commented 5 months ago

I passed all tests of arithmetic_coding.py on my MacBook but failed 3 on my Windows desktop. And I found the problem is about the default int type of Numpy (I think it changes between different systems). The default type on my MacBook is int64, while it is int32 on my desktop. Since it is difficult to change the default int type of Numpy, it is better to add "dtype=np.int64" in line 197 of arithmetic_coding.py, and it will work well on those System32.

 search_list = (
            low + (np.array(list(freqs.cumulative_freq_dict.values())) * rng) // freqs.total_freq
        )”

To

 search_list = (
            low + (np.array(list(freqs.cumulative_freq_dict.values()), dtype=np.int64) * rng) // freqs.total_freq
        )”
shubhamchandak94 commented 5 months ago

Hi, thanks for bringing this up. Could you make a pull request for the same? Thanks