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

Static typing with mypy, flake8, and lots of subjective code changes for Python3... #53

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
3dae0d4
Follow scipy deprecation advice (more or less).
cfcohen Mar 13, 2021
8c94df0
Correct flake8 E117 complaint.
cfcohen Mar 13, 2021
f2a6063
Correct flake8 E121 complaints.
cfcohen Mar 13, 2021
7df20ac
Correct flake8 E122 complaints.
cfcohen Mar 13, 2021
4c71bb5
Correct flake8 E123 complaints.
cfcohen Mar 13, 2021
9674200
Correct flake8 E126 complaints.
cfcohen Mar 13, 2021
724d7e4
Correct flake8 W391 complaint.
cfcohen Mar 13, 2021
00017db
Correct flake8 C812 complaints.
cfcohen Mar 13, 2021
69e3fbb
Correct flake8 C101 complaint.
cfcohen Mar 13, 2021
5bd4a69
Correct flake8 C407 complaints.
cfcohen Mar 13, 2021
ce17aa0
Fix flake8 N813 complaint.
cfcohen Mar 13, 2021
d0e8efe
Correct flake8 N811 complaint.
cfcohen Mar 13, 2021
60265e5
Correct flake8 W504 complaints.
cfcohen Mar 13, 2021
1dd7d29
Correct flake8 D101 complaints.
cfcohen Mar 13, 2021
2241328
Suppress flake8 F841 complaint.
cfcohen Mar 13, 2021
61ff112
Correct flake8 D202 complaints.
cfcohen Mar 13, 2021
da62a36
Correct flake8 D209 complaints.
cfcohen Mar 13, 2021
0b41ec6
Correct flake8 D204 complaints.
cfcohen Mar 13, 2021
4ce0078
Correct flake8 D101 complaints.
cfcohen Mar 13, 2021
9fb940c
Correct flake8 D104 complaints.
cfcohen Mar 13, 2021
8cf2c1c
Correct flake8 D102 complaints.
cfcohen Mar 13, 2021
73e0b40
Correct flake8 E241 complaint.
cfcohen Mar 13, 2021
09dd37f
Correct flake8 E302 complaints.
cfcohen Mar 13, 2021
38e487c
Mark scripts executable when they can be run from command line.
cfcohen Mar 13, 2021
08c6803
Some initial mypy changes to reduce error spew.
cfcohen Mar 14, 2021
38ae29f
Draw attention to possible bug found by mypy.
cfcohen Mar 14, 2021
23e9af2
Correct unfortunate interaction of flake8 and mypy.
cfcohen Mar 14, 2021
0552aa8
Specify types for member of MeOS that weren't declared.
cfcohen Mar 14, 2021
3b5bda0
Apply some types in plots.py and docs/conf.py to make mypy happy.
cfcohen Mar 14, 2021
6f6236f
Convert R, Tref, and Rhoref to lists of length 1.
cfcohen Mar 14, 2021
6478e8a
Significant mypy additions.
cfcohen Mar 14, 2021
f6150a7
Make a couple of assertions to help mypy.
cfcohen Mar 14, 2021
e422923
Tell mypy that a couple of variables exist...
cfcohen Mar 14, 2021
d047187
A few more assertions to help mypy.
cfcohen Mar 14, 2021
2cf70a5
Some gentle variable renaming to allow mypy to do type analysis.
cfcohen Mar 14, 2021
18c4cff
Explicitly mark some variables as floats.
cfcohen Mar 14, 2021
4e9fecf
A rather messy case where None is used in float lists.
cfcohen Mar 14, 2021
d3a4627
An alternative approach to the previous commit using zero indexing.
cfcohen Mar 14, 2021
ed5fc65
Change confusing reuse of variable names.
cfcohen Mar 14, 2021
edaa121
Use then I, J, N and i, j, n code pattern more consistently.
cfcohen Mar 14, 2021
59b3faf
Resolve type ambiguity ir par[].
cfcohen Mar 14, 2021
236f0ee
Clear up some typing issues surrounding _Pv, _rhoL and _rhoG.
cfcohen Mar 15, 2021
3c091b7
Increase typing errors from ~50 to ~150 by typing _fase.
cfcohen Mar 15, 2021
e1a702d
Reduce type errors surrounding fase.
cfcohen Mar 15, 2021
d6b7690
Are HumidAir and SeaWater valid _fase objects?
cfcohen Mar 15, 2021
ed42744
Better consistency for _visco() and _thermo().
cfcohen Mar 15, 2021
51f4108
Region is actually an optional int despite the documentation.
cfcohen Mar 15, 2021
c452989
More mypy error suppresion mostly through assertions.
cfcohen Mar 15, 2021
4f619c3
Some asserts enforcing dict keys and value types.
cfcohen Mar 15, 2021
0ef11e0
Try to be quite a bit clearer about the origin of R and M.
cfcohen Mar 15, 2021
52152d9
Add some mypy stubs for external functions.
cfcohen Mar 15, 2021
ac491ad
Git ignore emacs autosaves.
cfcohen Mar 15, 2021
1fa0f6b
Clean up some typing issues in plots.py.
cfcohen Mar 15, 2021
38d0a95
Explicitly convert to Python float from numpy.Float64.
cfcohen Mar 15, 2021
fa1eb5d
Convert to math.exp() and math.log() where possible.
cfcohen Mar 15, 2021
cb544ab
Isolate numpy.log() and numpy.exp() calls as much as possible.
cfcohen Mar 15, 2021
aaeca01
A working version with no numpy log()/exp() dependency.
cfcohen Mar 15, 2021
f9abf87
More comprehensively cast from numpy.Float64 to Python float.
cfcohen Mar 16, 2021
b05ee95
This commit demonstrates that numpy.Float64 is mostly gone.
cfcohen Mar 16, 2021
e0e2320
Improve static types for derivative()
cfcohen Mar 16, 2021
4c146ed
Work around a mypy quirk with type ordering and function definiton.
cfcohen Mar 16, 2021
a3596dd
Covert from initializing to None to nan in _fase.
cfcohen Mar 16, 2021
a29b333
Make IAPWS97 an _fase class.
cfcohen Mar 17, 2021
f40027a
Remove None elements that were never accessed and confused mypy.
cfcohen Mar 17, 2021
58fb6f5
Initialize r2 and r2p as a complex zero.
cfcohen Mar 17, 2021
fd05e3d
Type propiedades explicitly to make clear the values are optional.
cfcohen Mar 17, 2021
f4ac08f
Fix the last remaining my complaints with iapws97.py.
cfcohen Mar 17, 2021
b5b3270
Change _thermo to always return a float.
cfcohen Mar 17, 2021
14b58ac
Work around some more mypy confusion involving the kwarg being None.
cfcohen Mar 17, 2021
a18bd07
Document that phases have names set by the subclasses.
cfcohen Mar 17, 2021
02f026e
Document that some subclasses define the _surf coefficients.
cfcohen Mar 17, 2021
4da85c5
Mark Fi0 as class variable defined by subclasses.
cfcohen Mar 17, 2021
49c71f3
Add mypy.ini and .flake8 files.
cfcohen Mar 17, 2021
3ce2c8d
Enable 91 new mypy errors by typing test cases.
cfcohen Mar 17, 2021
f92f049
Initialize floats specific to SeaWater class.
cfcohen Mar 17, 2021
ecb0ca7
Technically these can be None as the API is currently defined.
cfcohen Mar 17, 2021
feba249
Reuse variables only if they have the same type.
cfcohen Mar 17, 2021
909ba5b
More variable name reuse with different types.
cfcohen Mar 17, 2021
419a3c2
Add missing type annotations.
cfcohen Mar 17, 2021
e72fb41
Silly flake8 rule about double spaces.
cfcohen Mar 17, 2021
a48c4d1
Missing return type annotation.
cfcohen Mar 17, 2021
683259a
Annotate the documentation function decorator.
cfcohen Mar 17, 2021
1538294
Enable type checking on calculo().
cfcohen Mar 17, 2021
b22a955
Enable type checking in calculo.
cfcohen Mar 17, 2021
a8d3b1b
Import missing optional keyword.
cfcohen Mar 17, 2021
3abe905
Enable type checking in IAPWS95.calculo.
cfcohen Mar 17, 2021
30d9a0d
Consequences of having Optional in iapws08.py on test.py
cfcohen Mar 17, 2021
ac85094
Class hierarchy clarity improvements.
cfcohen Mar 18, 2021
4bfe705
Improve static typing with a custom class instead of a dictionary.
cfcohen Mar 18, 2021
8acaab5
Convert IAPWS97 properties to a custom class.
cfcohen Mar 18, 2021
00d5b3a
Convert MEoS properties to a custom class.
cfcohen Mar 18, 2021
6337fcf
Why so much complexity for constants?
cfcohen Mar 19, 2021
16bff34
Yet more evidence that rhoc and Tc are basically just constants?
cfcohen Mar 19, 2021
f8a556a
Move the constants and _phir methods into a new class.
cfcohen Mar 20, 2021
fb92eb7
Break new class out into a separate file.
cfcohen Mar 20, 2021
5822206
Remove gamma2, since it's always just ones.
cfcohen Mar 20, 2021
0cde2a5
Split up the thousand line calculo function.
cfcohen Mar 20, 2021
fbfd2fe
Remove to two unused variables.
cfcohen Mar 20, 2021
db8243d
Call calculo to determine if state is calculable.
cfcohen Mar 20, 2021
6d7a6c0
Convert kwargs to consistently use None for undefined parameters.
cfcohen Mar 20, 2021
1fcbca1
Rename _thermo to _mode for consistency with iapws95.
cfcohen Mar 20, 2021
b7d2e09
Update IAPWS97 to better match IAPWS95 code structure.
cfcohen Mar 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document that phases have names set by the subclasses.
cfcohen committed Mar 17, 2021
commit a18bd0769b3ba314fa4dc22881095b6d328094cc
4 changes: 4 additions & 0 deletions iapws/_utils.py
Original file line number Diff line number Diff line change
@@ -65,6 +65,10 @@ def getphase(Tc: float, Pc: float, T: float, P: float, x: float, region: int) ->
class _fase(object):
"""Class to implement a null phase"""

# The name of the substance.
# Set in NH3, Air, IAPWS95, D2O, and IAPWS97.
name: str = "unknown"

# One always computed form the other
v: float = float('nan')
rho: float = float('nan')