Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2019 +/- ##
=======================================
Coverage 76.47% 76.47%
=======================================
Files 464 464
Lines 54936 54938 +2
Branches 9305 9305
=======================================
+ Hits 42012 42014 +2
Misses 9798 9798
Partials 3126 3126 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| CompositionLike: TypeAlias = str | dict[str, float] | ArrayLike | ||
| StateSetter: TypeAlias = tuple[float, float, CompositionLike] | ||
| CompositionLike: TypeAlias = str | Mapping[str, float | int] | ArrayLike | ||
| State2Setter: TypeAlias = tuple[float | None, float | None] |
There was a problem hiding this comment.
I honestly never knew this was an option... You can do stuff like gas.TP = None, 101325.0? What does that do, keep the current temperature as-is? (EDIT: Confirmed that's exactly what it does, TIL!) And if so, why is there no T.setter and P.setter?
There was a problem hiding this comment.
Yes, the setters allowing None are a convenient way of changing the state while holding one other property constant. The reason there is no setter for T or P (or H or V or ...) alone is because it's not clear which other thermodynamic property should be held constant.
There was a problem hiding this comment.
Of course! That make a lot of sense. Is this feature documented somewhere? It's very convenient, and I'm shocked I never knew about it.
There was a problem hiding this comment.
It's mentioned in the Python Tutorial, but perhaps there are a few other places it should be highlighted.
| # at https://cantera.org/license.txt for license and copyright information. | ||
|
|
||
| from typing import Literal, TypeAlias, TypedDict | ||
| from typing import Literal, Never, TypeAlias, TypedDict |
There was a problem hiding this comment.
Need to import Never from typing_extensions instead, to maintain support for Python 3.10. I have some Ruff settings I use which highlight this sort of issue. EDIT: Actually, it was mypy in this case.
There was a problem hiding this comment.
Thanks for the pointer. I was glad to see that the error message in the CI job also suggested this change.
There was a problem hiding this comment.
Of course! I'm hoping to write up something for the dev guide this week, which will definitely include a recommended way to run the type checking locally so you can be pretty sure the CI won't fail.
For now, you can try these mypy and stubtest commands from main.yaml:
mypy --config-file interfaces/cython/pyproject.toml -p cantera
stubtest --mypy-config-file interfaces/cython/pyproject.toml --ignore-disjoint-bases --allowlist interfaces/cython/.mypyignore canteraNoting that they are both run post-install.
There was a problem hiding this comment.
Good to hear. A dev guide for running things locally will be greatly appreciated!
69335a6 to
894d7e5
Compare
|
|
| data: ArrayLike | None = None, | ||
| input_data: _ChebyshevRateInput | None = None, | ||
| init: bool = True, | ||
| ) -> None: ... |
There was a problem hiding this comment.
I'm seeing this is causing an error in the CI:
cantera.ChebyshevRate.__init__ is inconsistent, runtime does not have parameter "temperature_range". You may need to write stubs for __new__ instead of __init__.This is the same issue I've had with most __cinit__ methods, as their function signature is not passed on to __init__ on the Python side. The way I've been handling it so far is to simply add the specific __init__ to the interfaces/cython/.mypyignore file. Make sure to use the --generate-allowlist option to get the right formatting (it will likely appear twice - once in cantera.ChebyshevRate.__init__ and once in cantera.reaction.ChebyshevRate.__init__).
It's not ideal, but seems to be a limitation of Cython.
|
Just left a comment about how to fix it on the |
Ah, but there's a bit of a catch-22 with this at present: If the either of the previous |
Right, it should probably either be the first command in the three, or better yet, its own separate step. Maybe it should also run without the current allowlist, then print the diff between the result and the current |
894d7e5 to
fa5b17a
Compare
ischoegl
left a comment
There was a problem hiding this comment.
Thanks! I’ll go head and approve.
Changes proposed in this pull request
Fix some of the new Python type annotations based on (incorrect) errors indicated in the examples and test suite.
Checklist
scons build&scons test) and unit tests address code coverage