go-enry / go-license-detector

Reliable project licenses detector.
Other
124 stars 36 forks source link

Update gonum.org/v1/gonum v0.7.0 to 0.9.0 #19

Open pravi opened 2 years ago

pravi commented 2 years ago

We are packaging this module for Debian, but we already have gonum.org/v1/gonum v0.9.0 and would like to use that instead of 0.7.0

But one test is failing with the new version, so please update the test with new version.

$ go test -v ./licensedb ./licensedb/api ./licensedb/filer ./licensedb/internal ./licensedb/internal/assets ./licensedb/internal/fastlog ./licensedb/internal/normalize ./licensedb/internal/processors ./licensedb/internal/wmh
=== RUN   TestDataset
895 902 99%
--- PASS: TestDataset (16.23s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb 16.513s
?       github.com/go-enry/go-license-detector/v4/licensedb/api [no test files]
=== RUN   TestLocalFiler
--- PASS: TestLocalFiler (0.00s)
=== RUN   TestGitFiler
--- PASS: TestGitFiler (0.01s)
=== RUN   TestZipFiler
--- PASS: TestZipFiler (0.00s)
=== RUN   TestNestedFiler
--- PASS: TestNestedFiler (0.00s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb/filer   0.019s
=== RUN   TestSplitLicenseName
--- PASS: TestSplitLicenseName (0.00s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb/internal    0.300s
?       github.com/go-enry/go-license-detector/v4/licensedb/internal/assets [no test files]
=== RUN   TestFastlog
--- PASS: TestFastlog (0.00s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb/internal/fastlog    0.037s
=== RUN   TestNormalizeLines
--- PASS: TestNormalizeLines (0.00s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb/internal/normalize  0.006s
=== RUN   TestHTML
--- PASS: TestHTML (0.00s)
PASS
ok      github.com/go-enry/go-license-detector/v4/licensedb/internal/processors 0.031s
=== RUN   TestWMHSerialize
--- PASS: TestWMHSerialize (0.01s)
=== RUN   TestWMHHash
    wmh_test.go:98: 
            Error Trace:    wmh_test.go:98
            Error:          Not equal: 
                            expected: []uint64{0x10032, 0x0, 0x1005a, 0x10050, 0x1005a, 0x1e, 0x10050, 0x5a, 0x28, 0x10028, 0x1003c, 0x10032, 0x1005a, 0x1005a, 0x9003c, 0x14, 0x10050, 0x1005a, 0x1003c, 0x1005a, 0x4005a, 0x20050, 0x1003c, 0x1003c, 0x10014, 0x1005a, 0x10028, 0x10046, 0x1005a, 0x10046, 0xa, 0x5a, 0x1003c, 0x10032, 0x1005a, 0x10046, 0x1005a, 0x0, 0x2005a, 0x1005a, 0x10028, 0x1005a, 0x10050, 0x10046, 0x10046, 0x20050, 0x1001e, 0x1005a, 0x10032, 0x1005a}
                            actual  : []uint64{0x1003c, 0x40046, 0x10046, 0x46, 0x10028, 0x5003c, 0x3c, 0x1e, 0x1e, 0x10032, 0x1005a, 0x2005a, 0x46, 0x10046, 0x10046, 0x10014, 0x10032, 0x20032, 0x10050, 0x10050, 0x10032, 0x5a, 0x10028, 0x10046, 0x10046, 0x1003c, 0x20050, 0x2003c, 0x10046, 0x1000a, 0x10028, 0x1005a, 0x30046, 0x1005a, 0x1003c, 0x5a, 0x28, 0x1001e, 0x20050, 0x10046, 0x1005a, 0x10050, 0x1003c, 0x10032, 0x10032, 0x1000a, 0x1005a, 0x10050, 0x1003c, 0x10032}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,52 +1,52 @@
                             ([]uint64) (len=50) {
                            + (uint64) 65596,
                            + (uint64) 262214,
                            + (uint64) 65606,
                            + (uint64) 70,
                            + (uint64) 65576,
                            + (uint64) 327740,
                            + (uint64) 60,
                            + (uint64) 30,
                            + (uint64) 30,
                              (uint64) 65586,
                            - (uint64) 0,
                            + (uint64) 65626,
                            + (uint64) 131162,
                            + (uint64) 70,
                            + (uint64) 65606,
                            + (uint64) 65606,
                            + (uint64) 65556,
                            + (uint64) 65586,
                            + (uint64) 131122,
                            + (uint64) 65616,
                            + (uint64) 65616,
                            + (uint64) 65586,
                            + (uint64) 90,
                            + (uint64) 65576,
                            + (uint64) 65606,
                            + (uint64) 65606,
                            + (uint64) 65596,
                            + (uint64) 131152,
                            + (uint64) 131132,
                            + (uint64) 65606,
                            + (uint64) 65546,
                            + (uint64) 65576,
                            + (uint64) 65626,
                            + (uint64) 196678,
                            + (uint64) 65626,
                            + (uint64) 65596,
                            + (uint64) 90,
                            + (uint64) 40,
                            + (uint64) 65566,
                            + (uint64) 131152,
                            + (uint64) 65606,
                              (uint64) 65626,
                              (uint64) 65616,
                            - (uint64) 65626,
                            - (uint64) 30,
                            - (uint64) 65616,
                            - (uint64) 90,
                            - (uint64) 40,
                            - (uint64) 65576,
                              (uint64) 65596,
                              (uint64) 65586,
                            - (uint64) 65626,
                            - (uint64) 65626,
                            - (uint64) 589884,
                            - (uint64) 20,
                            - (uint64) 65616,
                            - (uint64) 65626,
                            - (uint64) 65596,
                            - (uint64) 65626,
                            - (uint64) 262234,
                            - (uint64) 131152,
                            - (uint64) 65596,
                            - (uint64) 65596,
                            - (uint64) 65556,
                            - (uint64) 65626,
                            - (uint64) 65576,
                            - (uint64) 65606,
                            - (uint64) 65626,
                            - (uint64) 65606,
                            - (uint64) 10,
                            - (uint64) 90,
                            - (uint64) 65596,
                              (uint64) 65586,
                            - (uint64) 65626,
                            - (uint64) 65606,
                            - (uint64) 65626,
                            - (uint64) 0,
                            - (uint64) 131162,
                            - (uint64) 65626,
                            - (uint64) 65576,
                            + (uint64) 65546,
                              (uint64) 65626,
                              (uint64) 65616,
                            - (uint64) 65606,
                            - (uint64) 65606,
                            - (uint64) 131152,
                            - (uint64) 65566,
                            - (uint64) 65626,
                            - (uint64) 65586,
                            - (uint64) 65626
                            + (uint64) 65596,
                            + (uint64) 65586
                             }
            Test:           TestWMHHash
--- FAIL: TestWMHHash (0.00s)
=== RUN   TestWMHTrash
2021/11/10 23:00:53 len(values)=9 is not equal to len(indices)=10
2021/11/10 23:00:53 len(values)=10 is not equal to len(indices)=9
2021/11/10 23:00:53 index is out of range: 100 @ 9
--- PASS: TestWMHTrash (0.00s)
FAIL
FAIL    github.com/go-enry/go-license-detector/v4/licensedb/internal/wmh    0.070s
FAIL
bzz commented 1 year ago

From the log - it seems that the test in question is simply comparing the hash with the gold wmh.bin output. I guess only @vmarkovtsev knows how this file was created in the first place in https://github.com/go-enry/go-license-detector/commit/1972482a7d6ac88fce6b4c0df22d65a341583e8c but my guess is that it was done in Python.

If that is so - why changing the version of gonum changes the behaviour of gonum/stat/distuv (the only thing that seems to used from it in wmh.go) - is beyond me.

From a quick glance, there seems to be some changes in stat/distuv at https://github.com/gonum/gonum/releases/tag/v0.8.1 https://github.com/gonum/gonum/releases/tag/v0.8.1 but why should that affect the .Rand() \w a fixed seed (the only thing that is consumed in wmh.go) is a mistery šŸ¤·