-
Notifications
You must be signed in to change notification settings - Fork 113
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
Address GC with JPype ≥1.5.0 #504
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #504 +/- ##
=====================================
Coverage 98.8% 98.9%
=====================================
Files 44 44
Lines 4747 4758 +11
=====================================
+ Hits 4694 4706 +12
+ Misses 53 52 -1
|
While looking at these logs, I noticed: XPASS ixmp/tests/core/test_scenario.py::TestScenario::test_add_par[args2-kwargs2] Length mismatch between keys and values Taking a closer look, I found key_or_data = ["new-york", "chicago"]
value = [100, 200, 300]
# This creates as many tuples as possible, stopping when key_or_data runs out
zip(key_or_data, value)
# So there was never nan data in pandas, thus not triggering the ValueError we expect for the test |
Update: this only seems to work for python > 3.9, thus some tests are failing. I'll think about as elegant a fix as possible. |
I would suggest to use Note that the construction: try:
func()
except ValueError as e:
raise ValueError("Helpful message about specific condition X") from e …can only be used if we know for certain that only condition X will cause func() to raise ValueError. If there are 2 or more ways it could raise the same class of exception, then the except clause will inappropriately swallow/hide conditions Y or Z from the user, and actually give them an incorrect message about what they've done wrong. |
That's a good suggestion. In theory, though, we could also not reraise our own unique exception since zip(..., strict=True) will raise a ValueError already. |
It's supposed to, at least. On my system, however: >>> zip(key_or_data, value, strict=True)
<zip object at 0x7fbe4169f9c0>
>>> list(zip(key_or_data, value, strict=True))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: zip() argument 2 is longer than argument 1 So |
Occurs only with Python 3.12 and JPype 1.5.0.
…with Python 3.12 and JPype 1.5.0 only.
- Xfail one test, adjust another.
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.
This looks good to me now, thanks :)
Will close #463, #494, #501.
Also:
Add pytest-xdist to run tests in parallel on 2+ cores, as with other packages in our stack. This reduces the pytest run time for some jobs to <1 min.
One strange thing: the failures of the
test_del_ts
tests noted/discussed in Adjust for JPype1 v1.4.1 #463 do not occur when using pytest-xdist; so those tests are all XPASS on Python ≤ 3.10 on all 3 OS.How to review
PR checklist
Add, expand, or update documentation.N/A