-
Notifications
You must be signed in to change notification settings - Fork 777
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
Update _builder.pyx #642
Conversation
Exponentiation appears to cause type conversion to double in some instances.
|
@@ -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) |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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?
This solved my problems installing in python 3.8 |
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. |
Let's see if this build works. Seems like we were missing one package for testing. |
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 ). |
@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? |
Hi @mlsquareup. Thanks for your contribution. As the issue has been in #640 and #641, we will close your PR. |
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 applyChecklist
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.Further comments
Small change to ensure any type conversion due to exponentiation is undone.