Ask Your Question

Revision history [back]

Cython compilation fail after separating code

Hello,

My karma is not high enough to publish links, so I will have to grossly link them next to the text. Please replace (dot) with . for all links in square brackets [].

The code in my master branch [github(dot)com/alexhutman/Zero-Forcing-Number/blob/master/OneGinormousFile.pyx] is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module [github(dot)com/alexhutman/Zero-Forcing-Number/tree/cleanup/zeroforcing/fastqueue] compiles without any problems. The metagraph module [github(dot)com/alexhutman/Zero-Forcing-Number/blob/cleanup/zeroforcing/metagraph/metagraph.pyx], however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log [pastebin(dot)com/DF0ed82M]:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅

Cython compilation fail after separating code

Hello,

My karma is not high enough to publish links, so I will have to grossly link them next to the text. Please replace (dot) with . for all links in square brackets [].

The code in my master branch [github(dot)com/alexhutman/Zero-Forcing-Number/blob/master/OneGinormousFile.pyx] branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module [github(dot)com/alexhutman/Zero-Forcing-Number/tree/cleanup/zeroforcing/fastqueue] module compiles without any problems. The metagraph module [github(dot)com/alexhutman/Zero-Forcing-Number/blob/cleanup/zeroforcing/metagraph/metagraph.pyx], module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log [pastebin(dot)com/DF0ed82M]:log:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅

Cython compilation fail after separating code

Hello,

The code in my master branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module compiles without any problems. The metagraph module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅

Cython compilation fail after separating code

Hello,

I am on SageMath version 9.8.beta2, Release Date: 2022-10-16, Using Python 3.10.5.

The code in my master branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module compiles without any problems. The metagraph module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅

Cython compilation fail after separating code

Hello,

I am on SageMath version 9.8.beta2, Release Date: 2022-10-16, Using Python 3.10.5.

I am using an Intel i9-12900K on WSL version 1.0.0.0, WSL Kernel version 5.15.74.2.


The code in my master branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module compiles without any problems. The metagraph module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅

Cython compilation fail after separating code

Hello,

I am on SageMath version 9.8.beta2, Release Date: 2022-10-16, Using Python 3.10.5.

I am using an Intel i9-12900K on WSL version 1.0.0.0, WSL Kernel version 5.15.74.2.


The code in my master branch is all in a big Cython file called OneGinormousFile.pyx. Running sage OneGinormousFile.pyx results in no compilation errors, and I'm able to call the functions defined in this file in a Jupyter notebook with no problems.

In the cleanup branch, I then tried separating the code into logical modules for easier readability/organization. When running sage setup.py build_ext --inplace, the fastqueue module compiles without any problems. The metagraph module, however, gives me a bunch of type coercion errors. Below is a brief snippet, but here is the full error log:

>sage --python3 setup.py build_ext --inplace

Compiling zeroforcing/metagraph/metagraph.pyx because it changed.
[1/1] Cythonizing zeroforcing/metagraph/metagraph.pyx

Error compiling Cython file:
------------------------------------------------------------
...

    cdef mp_bitcnt_t extra

    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
                                                 ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:177:50: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
    bits.size = size
    if fused_bitset_t is bitset_t:
        bits.limbs = (size - 1) / (8 * LIMB_SIZE) + 1
        bits.bits = <mp_limb_t*>check_calloc(bits.limbs, LIMB_SIZE)
    else:
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:180:54: Cannot assign type 'double' to 'mp_size_t'

Error compiling Cython file:
------------------------------------------------------------
...
        bits.limbs = ((size - 1) / (8*ALIGNMENT) + 1) * (ALIGNMENT/LIMB_SIZE)
        extra = (ALIGNMENT + LIMB_SIZE - 2) // LIMB_SIZE
        bits.mem = check_calloc(bits.limbs + extra, LIMB_SIZE)
        bits.bits = <mp_limb_t*> align(bits.mem, ALIGNMENT)
        bits.non_zero_chunks_are_initialized = False
        bits.non_zero_chunks = <mp_bitcnt_t*> check_allocarray((bits.limbs*LIMB_SIZE) / ALIGNMENT, sizeof(mp_bitcnt_t))
                                                                                     ^
------------------------------------------------------------

/mnt/e/projects/python/sage/src/sage/data_structures/bitset_base.pxd:185:86: Cannot assign type 'double' to 'size_t'

Does anyone know why this is happening? There isn't a problem in the code since it's giving errors on Sage's bitset modules and it's only when the code is separated. I'm out of ideas 😅