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

Upgrade to Python 3.13 #338

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

noman404
Copy link
Contributor

Fixes #334

Copy link
Contributor

Choose a reason for hiding this comment

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

while here could we adopt the standard import numpy as np?

Copy link
Contributor Author

@noman404 noman404 Jan 30, 2025

Choose a reason for hiding this comment

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

great point! actually i did ran a sonaqube code analysis scanning which also pointed that, we could have a discussion about those issues all together for improvement https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&id=noman404_policyengine-core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like there are several class methods do not have self also another standard practice

@@ -0,0 +1,6 @@
- bump: major
Copy link
Contributor

Choose a reason for hiding this comment

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

is this backwards-incompatible?

Copy link
Contributor Author

@noman404 noman404 Feb 5, 2025

Choose a reason for hiding this comment

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

Python codeabase should be fine, cause there is no change related to python language specific code. However numpy is not compatible, there are several changes in data type like, float64, int64, inf, default type definition etc.

https://numpy.org/devdocs/numpy_2_0_migration_guide.html

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.15%. Comparing base (9fbe198) to head (83f47bb).
Report is 28 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #338      +/-   ##
==========================================
- Coverage   84.73%   84.15%   -0.59%     
==========================================
  Files         191      194       +3     
  Lines        9773     9989     +216     
  Branches     1018     1046      +28     
==========================================
+ Hits         8281     8406     +125     
- Misses       1204     1290      +86     
- Partials      288      293       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anth-volk
Copy link
Contributor

anth-volk commented Jan 31, 2025 via email

@noman404
Copy link
Contributor Author

noman404 commented Feb 5, 2025

@MaxGhenis we are stuck in a circular dependency scenario here, the test test_us on 3.13 will fail because current PE-US does not use 3.13 and PE-US also fail as current PE-Core not 3.13

@MaxGhenis
Copy link
Contributor

@MaxGhenis we are stuck in a circular dependency scenario here, the test test_us on 3.13 will fail because current PE-US does not use 3.13 and PE-US also fail as current PE-Core not 3.13

@nikhilwoodruff @anth-volk @mikesmit any tips?

@noman404 noman404 marked this pull request as ready for review February 25, 2025 00:49
@MaxGhenis MaxGhenis requested a review from anth-volk March 14, 2025 21:14
Copy link
Contributor

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Have a few questions on this and would love @nikhilwoodruff's review

@@ -10,7 +10,7 @@ format:

install:
pip install -e ".[dev]" --config-settings editable_mode=compat
pip install policyengine-us
pip install git+https://github.com/noman404/policyengine-us.git@noman404/python3.13
Copy link
Contributor

Choose a reason for hiding this comment

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

issue, blocking: This ties us to an installation we do not want

Copy link
Contributor

Choose a reason for hiding this comment

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

question: @nikhilwoodruff How did we resolve the overlapping deps issue Al raised before? And is it still present?

if isinstance(this, tuple):
raise TypeError("First argument must not be a tuple.")

if isinstance(that, tuple):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, non-blocking: Can't we just check both of these args and have one message for both?

# because of the infinities the first sort creates positional indices
# The second argsort converts these positions to ranks, thus fixes the broken sort issue
first_argsort = numpy.argsort(matrix, axis=1, kind="stable")
sorted_matrix = numpy.argsort(first_argsort, axis=1, kind="stable")
Copy link
Contributor

Choose a reason for hiding this comment

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

blocking: I'd love @nikhilwoodruff to confirm the logic here, as I'm less familiar with numpy

@@ -92,6 +92,11 @@ def concat(this: ArrayLike[str], that: ArrayLike[str]) -> ArrayType[str]:
array(['this1.0', 'that2.5']...)

"""
if isinstance(this, tuple):
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why can't these be tuples?

@@ -25,6 +25,7 @@
"pyvis>=0.3.2",
"microdf_python>=0.4.3",
"huggingface_hub>=0.25.1",
"standard-imghdr",
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why do we need this package? I see no reference to it in the PR changes

@@ -66,12 +66,12 @@ def calc(
#
# numpy.finfo(float_).eps
thresholds1 = numpy.outer(
factor + numpy.finfo(numpy.float_).eps,
factor + numpy.finfo(numpy.float64).eps,
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -114,5 +114,10 @@ class TypesZone(Enum):
z1 = "Zone 1"
z2 = "Zone 2"

zone = np.asarray([TypesZone.z1, TypesZone.z2, TypesZone.z2, TypesZone.z1])
zone = np.asarray(
[
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why does this behavior change?

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

Successfully merging this pull request may close these issues.

Upgrade to Python 3.13
3 participants