-
Notifications
You must be signed in to change notification settings - Fork 23
Upgrade to Python 3.13 #338
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
base: master
Are you sure you want to change the base?
Changes from all commits
3be9260
071b558
464a21d
593bc87
1451a32
5405f6a
db02965
9fdd051
f5b94d4
dbc7011
41a30bd
30d234b
3de837c
0e73e54
2325018
b12e932
03bbfb9
f24e1a6
7e35330
83f47bb
2044b5e
c012d8c
779ef0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- bump: major | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this backwards-incompatible? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
changes: | ||
changed: | ||
- python 3.13.0 | ||
- numpy 2.1.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,11 @@ def concat(this: ArrayLike[str], that: ArrayLike[str]) -> ArrayType[str]: | |
array(['this1.0', 'that2.5']...) | ||
|
||
""" | ||
if isinstance(this, tuple): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why can't these be tuples? |
||
raise TypeError("First argument must not be a tuple.") | ||
|
||
if isinstance(that, tuple): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
raise TypeError("Second argument must not be a tuple.") | ||
|
||
if isinstance(this, numpy.ndarray) and not numpy.issubdtype( | ||
this.dtype, numpy.str_ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,7 +253,11 @@ def get_rank( | |
# We double-argsort all lines of the matrix. | ||
# Double-argsorting gets the rank of each value once sorted | ||
# For instance, if x = [3,1,6,4,0], y = numpy.argsort(x) is [4, 1, 0, 3, 2] (because the value with index 4 is the smallest one, the value with index 1 the second smallest, etc.) and z = numpy.argsort(y) is [2, 1, 4, 3, 0], the rank of each value. | ||
sorted_matrix = numpy.argsort(numpy.argsort(matrix)) | ||
|
||
# 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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
# Build the result vector by taking for each person the value in the right line (corresponding to its household id) and the right column (corresponding to its position) | ||
result = sorted_matrix[ids, positions] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documented at https://numpy.org/doc/2.1/numpy_2_0_migration_guide.html |
||
numpy.array(self.thresholds + [numpy.inf]), | ||
) | ||
|
||
if round_base_decimals is not None: | ||
thresholds1 = numpy.round_(thresholds1, round_base_decimals) | ||
thresholds1 = numpy.round(thresholds1, round_base_decimals) | ||
|
||
a = numpy.maximum( | ||
numpy.minimum(base1, thresholds1[:, 1:]) - thresholds1[:, :-1], 0 | ||
|
@@ -82,8 +82,8 @@ def calc( | |
|
||
else: | ||
r = numpy.tile(self.rates, (len(tax_base), 1)) | ||
b = numpy.round_(a, round_base_decimals) | ||
return numpy.round_(r * b, round_base_decimals).sum(axis=1) | ||
b = numpy.round(a, round_base_decimals) | ||
return numpy.round(r * b, round_base_decimals).sum(axis=1) | ||
|
||
def combine_bracket( | ||
self, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
general_requirements = [ | ||
"pytest>=8,<9", | ||
"numpy~=1.26.4", | ||
"numpy~=2.1.0", | ||
"sortedcontainers<3", | ||
"numexpr<3", | ||
"dpath<3", | ||
|
@@ -25,6 +25,7 @@ | |
"pyvis>=0.3.2", | ||
"microdf_python>=0.4.3", | ||
"huggingface_hub>=0.25.1", | ||
"standard-imghdr", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
] | ||
|
||
dev_requirements = [ | ||
|
@@ -60,6 +61,7 @@ | |
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
"Topic :: Scientific/Engineering :: Information Analysis", | ||
], | ||
description="Core microsimulation engine enabling country-specific policy models.", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Why does this behavior change? |
||
z.name | ||
for z in [TypesZone.z1, TypesZone.z2, TypesZone.z2, TypesZone.z1] | ||
] | ||
) | ||
assert_near(P.single.owner[zone], [100, 200, 200, 100]) |
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.
issue, blocking: This ties us to an installation we do not want
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.
question: @nikhilwoodruff How did we resolve the overlapping deps issue Al raised before? And is it still present?