zopefoundation / zope.index

Indices for using with catalog like text, field, etc.
Other
10 stars 12 forks source link

Drop Python 3.3 from .manylinux-install.sh #21

Closed mgedmin closed 5 years ago

mgedmin commented 5 years ago

This was overlooked when dd38abc6bee3ac849623e4beaa528d7ce4a9422d dropped Python 3.3 from the other files.

mgedmin commented 5 years ago

A very strange failure on Appveyor for Python 2.7 (32-bit only).

zope-testrunner --test-path=src
Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
Error in test test_random (zope.index.text.tests.test_ricecode.TestRiceCode)
Traceback (most recent call last):
  File "c:\python27\lib\unittest\case.py", line 329, in run
    testMethod()
  File "c:\python27\lib\site-packages\zope\index\text\tests\test_ricecode.py", line 25, in test_random
    l2 = decode_deltas(l_0, deltas)
  File "c:\python27\lib\site-packages\zope\index\text\ricecode.py", line 185, in decode_deltas
    deltas = enc_deltas.tolist()
AttributeError: 'list' object has no attribute 'tolist'
  Ran 720 tests with 0 failures, 1 errors and 0 skipped in 0.968 seconds.
Tearing down left over layers:
  Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
Command exited with code 1

Note that while "appveyor/branch" failed, "appveyor/pr" succeeded, so this failure appears to be non-deterministic?!

jamadden commented 5 years ago

so this failure appears to be non-deterministic?!

Well the test case is called test_random 🤷‍♂️

jamadden commented 5 years ago

so this failure appears to be non-deterministic?!

Yup, that error will happen when the randomly sized list turns out to be 0.

        for size in [10, 20, 50, 100, 200]:
            l = list(range(random.randint(1, size), size + random.randint(1, size)))
            l_0, deltas = encode_deltas(l)

In that case, encode_deltas returns a list as its second value, instead of a RiceCode object:

def encode_deltas(l):
    """Encode deltas in list *l* using a :class:`RiceCode` of size 6."""
    if len(l) == 1:
        return l[0], []
mgedmin commented 5 years ago

Under what cicrumstances can

            l = list(range(random.randint(1, size), size + random.randint(1, size)))

produce an empty list?

The smallest case seems to be when the 1st randint returns the largest possible value and the second the smallest, which turns it into list(range(size, size+1)), and it should have one item in it. What am I missing?

EDIT: my brain, since it's not the input list that's size 0, it's the returned value.

jamadden commented 5 years ago

What am I missing?

Sorry, I misspoke. I meant size one, not size 0. The code snippet is correct.

mgedmin commented 5 years ago

Anyway, this is a separate bug: #22.