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

Update _builder.pyx #642

Conversation

mlsquareup
Copy link

Exponentiation appears to cause type conversion to double in some instances.

Proposed changes

Same issue as shown in #534. I cannot deploy causalml models in SageMaker because I see same error, and also on my M1 laptop.

Types of changes

What types of changes does your code introduce to CausalML?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [x ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • [x ] I have added necessary documentation (if appropriate)
  • [x ] Any dependent changes have been merged and published in downstream modules

Further comments

Small change to ensure any type conversion due to exponentiation is undone.

Exponentiation appears to cause type conversion to double in some instances.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -58,7 +58,7 @@ cdef class DepthFirstCausalTreeBuilder(TreeBuilder):
cdef int init_capacity

if tree.max_depth <= 10:
init_capacity = (2 ** (tree.max_depth + 1)) - 1
init_capacity = int((2 ** (tree.max_depth + 1)) - 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the exponentiation results in type conversion to float. This is causing me issues in the installation.

 Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
              # Initial capacity
              cdef int init_capacity
      
              if tree.max_depth <= 10:
                  init_capacity = (2 ** (tree.max_depth + 1)) - 1
                                                              ^
      ------------------------------------------------------------
      
      causalml/inference/tree/causal/_builder.pyx:61:56: Cannot assign type 'double' to 'int'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird though. The rule in Python is that integer exponentiation results in an integer, how is it giving a double here? Does CPython have different rules?

@leoifood
Copy link

This solved my problems installing in python 3.8

@jeongyoonlee
Copy link
Collaborator

Thanks for your contribution, @mlsquareup. Currently, pytest builds are failing (e.g., py3.8). Can you see if you can fix it?

@jeongyoonlee jeongyoonlee self-requested a review July 19, 2023 17:42
@jeongyoonlee jeongyoonlee mentioned this pull request Jul 19, 2023
9 tasks
@mlsquareup
Copy link
Author

Thanks for your contribution, @mlsquareup. Currently, pytest builds are failing (e.g., py3.8). Can you see if you can fix it?

Probably just missing duecredit package. Let me check.

@mlsquareup
Copy link
Author

Let's see if this build works. Seems like we were missing one package for testing.

@bsaunders27
Copy link
Contributor

Fun fact, apparently duecredit isn't actually necessary (see screenshot of successful build. Looks like the issue is with the cached version of Cython being 3.0.0 which has some integration issues (solved in #640 ).

image

@eugeneyarovoi
Copy link

@bsaunders27 I think your PR is a more comprehensive version of what @mlsquareup was trying to do here. Maybe you can just push your changes forward and we can close this?

@jeongyoonlee
Copy link
Collaborator

Hi @mlsquareup. Thanks for your contribution. As the issue has been in #640 and #641, we will close your PR.
We are looking forward to your contribution.

@jeongyoonlee jeongyoonlee added the installation Issues related to installation label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Issues related to installation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants