Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install #9

Open
stestagg opened this issue Jan 4, 2024 · 2 comments
Open

Can't install #9

stestagg opened this issue Jan 4, 2024 · 2 comments
Assignees

Comments

@stestagg
Copy link
Owner

stestagg commented Jan 4, 2024

I tried to install the library, and got this error in the terminal:

Error compiling Cython file:
------------------------------------------------------------
...
while len(self.pages) > 0 and self.pages[-1].count == 0:
self.pages.pop()

      cpdef add(self, usize_t number):
          """Add a positive integer to the bitfield"""
          cdef usize_t page = number / PAGE_FULL_COUNT
                                     ^
  ------------------------------------------------------------

  cimpl/field.pyx:463:35: Cannot assign type 'double' to 'usize_t'

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
          the_page.add(page_index)

      cpdef remove(Bitfield self, usize_t number):
          """Remove a positive integer from the bitfield
          If the integer does not exist in the field, raise a KeyError"""
          cdef usize_t page_no = number / PAGE_FULL_COUNT
                                        ^
  ------------------------------------------------------------

  cimpl/field.pyx:472:38: Cannot assign type 'double' to 'usize_t'

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
              raise KeyError()

      cpdef discard(Bitfield self, usize_t number):
          """Remove a positive integer from the bitfield if it is a member.
          If the element is not a member, do nothing."""
          cdef usize_t page = number / PAGE_FULL_COUNT
                                     ^
  ------------------------------------------------------------

  cimpl/field.pyx:486:35: Cannot assign type 'double' to 'usize_t'
@autoprbot autoprbot self-assigned this Jan 4, 2024
@autoprbot
Copy link
Collaborator

🤖 I'm going to attempt this change. The error messages indicate that the issue is with type casting in cython. the division operation in python 3.x results in a float by default, even when both operands are integers. in cython, when you assign the result of a division to a variable with a specified integer type (in this case, usize_t), you need to ensure that the division operation results in an integer type, not a float.

the fix would involve changing the division operation to perform integer division. in python (and cython), integer division can be done using the // operator instead of the / operator. this should resolve the type mismatch error by ensuring that the result of the division is an integer, which can then be assigned to a variable of type usize_t.

given that the error messages provide the exact locations and nature of the issue, and considering my experience with coding and type casting, i am confident that i can implement this change accurately. the fix would be to replace the / operator with the // operator in the lines of code indicated by the error messages.

@autoprbot
Copy link
Collaborator

🤖 PR created: #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants