Opened 15 months ago

Last modified 8 weeks ago

#31610 new defect

PolyBori-Bug

Reported by: gh-hadipourh Owned by:
Priority: critical Milestone: sage-9.7
Component: packages: standard Keywords: BRiAL, PyPolyBoRi, degrevlex
Cc: fbissey, chapoton Merged in:
Authors: Hosein Hadipour Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by gh-hadipourh)

Hello all,

I'd just like to report a bug inside the interface of PolyBori? (BRiAL). It seems, that the load command doesn't work correctly when the term ordering is 'revlex' or 'degrevlex'.

For example using the following commands, one can create a Boolean ideal, store and again load it into the work space.

names = ['x%d' % i for i in [0 .. 100]]
BPR = BooleanPolynomialRing(names=names, order='deglex')
random_samples = [BPR.random_element() for _ in [0 .. 100]]
random_ideal = ideal(random_samples)
save(random_ideal, 'random_ideal')
reset()
ID = load('random_ideal.sobj')

However, as you can see in the following lines, if the term ordering is set to 'degrevlex', the load command produces an error.

names = ['x%d' % i for i in [0 .. 100]]
BPR = BooleanPolynomialRing(names=names, order='degrevlex')
random_samples = [BPR.random_element() for _ in [0 .. 100]]
random_ideal = ideal(random_samples)
save(random_ideal, 'random_ideal')
reset()
ID = load('random_ideal.sobj')

Error:

KeyError                                  Traceback (most recent call last)
sage-9-1/SageMath/local/lib/python3.7/site-packages/sage/all_cmdline.py in <module>()
      5 save(random_ideal, 'random_ideal')
      6 reset()
----> 7 ID = load('random_ideal.sobj')

sage-9-1/SageMath/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2900)()
    156 
    157     ## Load file by absolute filename
--> 158     with open(filename, 'rb') as fobj:
    159         X = loads(fobj.read(), compress=compress, **kwargs)
    160     try:

sage-9-1/SageMath/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2850)()
    157     ## Load file by absolute filename
    158     with open(filename, 'rb') as fobj:
--> 159         X = loads(fobj.read(), compress=compress, **kwargs)
    160     try:
    161         X._default_filename = os.path.abspath(filename)

sage-9-1/SageMath/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.loads (build/cythonized/sage/misc/persist.c:7424)()
   1042 
   1043     unpickler = SageUnpickler(io.BytesIO(s), **kwargs)
-> 1044     return unpickler.load()
   1045 
   1046 

sage-9-1/SageMath/local/lib/python3.7/site-packages/sage/rings/polynomial/pbori.pyx in sage.rings.polynomial.pbori.unpickle_BooleanPolynomial0 (build/cythonized/sage/rings/polynomial/pbori.cpp:59767)()
   7837     """
   7838     from brial.parallel import _decode_polynomial
-> 7839     return _decode_polynomial(l)
   7840 
   7841 

sage-9-1/SageMath/local/lib/python3.7/site-packages/brial/parallel.py in _decode_polynomial(code)
    154 
    155 def _decode_polynomial(code):
--> 156     return from_fast_pickable(*code)[0]
    157 
    158 

sage-9-1/SageMath/local/lib/python3.7/site-packages/brial/parallel.py in from_fast_pickable(l, r)
    137     for i in reversed(range(len(terms))):
    138         (v, t, e) = terms[i]
--> 139         t = i2poly[t]
    140         e = i2poly[e]
    141         terms[i] = if_then_else(v, t, e)

KeyError: 3

The version of SageMath as well as the specification of the operating system for which the above issue has been observed are as follows:

SageMath version 9.1, Release Date: 2020-05-20
Linux hosein 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

It should be noted that the same issue exists for SageMath version 9.1 running on Windows 10.

Change History (8)

comment:1 Changed 15 months ago by gh-hadipourh

  • Description modified (diff)

comment:2 Changed 15 months ago by mkoeppe

  • Cc fbissey added
  • Component changed from PLEASE CHANGE to packages: standard
  • Type changed from PLEASE CHANGE to defect

comment:3 Changed 15 months ago by fbissey

  • Cc chapoton added

OK, it still happens in 9.3.rc1

sage: names = ['x%d' % i for i in [0 .. 100]]
....: BPR = BooleanPolynomialRing(names=names, order='degrevlex')
....: random_samples = [BPR.random_element() for _ in [0 .. 100]]
....: random_ideal = ideal(random_samples)
....: save(random_ideal, 'random_ideal')
....: reset()
sage: load('random_ideal.sobj')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/lib/python3.9/site-packages/sage/all_cmdline.py in <module>
----> 1 load('random_ideal.sobj')

/usr/lib/python3.9/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_9/build/cythonized/sage/misc/persist.c:2923)()
    155 
    156     ## Load file by absolute filename
--> 157     with open(filename, 'rb') as fobj:
    158         X = loads(fobj.read(), compress=compress, **kwargs)
    159     try:

/usr/lib/python3.9/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_9/build/cythonized/sage/misc/persist.c:2873)()
    156     ## Load file by absolute filename
    157     with open(filename, 'rb') as fobj:
--> 158         X = loads(fobj.read(), compress=compress, **kwargs)
    159     try:
    160         X._default_filename = os.path.abspath(filename)

/usr/lib/python3.9/site-packages/sage/misc/persist.pyx in sage.misc.persist.loads (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_9/build/cythonized/sage/misc/persist.c:7540)()
    933 
    934     unpickler = SageUnpickler(io.BytesIO(s), **kwargs)
--> 935     return unpickler.load()
    936 
    937 

/usr/lib/python3.9/site-packages/sage/rings/polynomial/pbori/pbori.pyx in sage.rings.polynomial.pbori.pbori.unpickle_BooleanPolynomial0 (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_9/build/cythonized/sage/rings/polynomial/pbori/pbori.cpp:61426)()
   7781     """
   7782     from sage.rings.polynomial.pbori.parallel import _decode_polynomial
-> 7783     return _decode_polynomial(l)
   7784 
   7785 

/usr/lib/python3.9/site-packages/sage/rings/polynomial/pbori/parallel.py in _decode_polynomial(code)
    166 
    167 def _decode_polynomial(code):
--> 168     return from_fast_pickable(*code)[0]
    169 
    170 

/usr/lib/python3.9/site-packages/sage/rings/polynomial/pbori/parallel.py in from_fast_pickable(l, r)
    149     for i in reversed(range(len(terms))):
    150         (v, t, e) = terms[i]
--> 151         t = i2poly[t]
    152         e = i2poly[e]
    153         terms[i] = if_then_else(v, t, e)

KeyError: 8

Not really my area of expertise, which is another reason it needed merging in sage. Frédéric Chapoton may have a better idea of where the problem may be.

comment:4 Changed 15 months ago by gh-hadipourh

  • Authors set to Hosein Hadipour

comment:5 Changed 14 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Moving to 9.4, as 9.3 has been released.

comment:6 Changed 10 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:7 Changed 6 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:8 Changed 8 weeks ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.