Closed softwareengineerprogrammer closed 7 months ago
Looks good, but I don't understand the new construct on Model.py:
self.reserv: Reservoir = TDPReservoir(self)
The addition of : Reservoir
is a type hint. In this case I added the hint because it enabled PyCharm to give me better autocomplete suggestions as I was working on code that referenced model.reserv
(i.e. typing model.reserv.
and then being presented with suggestions for .value
, .quantity()
, etc.).
In general, we should ideally be using/adding type hints for all code as best practice since they improve contributor experience, code comprehensibility, and serve as a guardrail against many common classes of programming errors. I have created a tracking item for this: https://github.com/NREL/GEOPHIRES-X/issues/100. However, I am deferring on adding types everywhere for a few reasons for now:
pre-commit
is enabled for styling. Setting up type linting (in addition to type hinting) adds significant workSo for now, I am just doing the following:
It seems logical, and I will endeavor to follow your suggestions below about when to add type hints… but I clearly don’t know how to add the proper type hints in all cases…
From: Jonathan Pezzino @.> Sent: Thursday, February 15, 2024 10:39 AM To: NREL/GEOPHIRES-X @.> Cc: Malcolm Ross @.>; Review requested @.> Subject: Re: [NREL/GEOPHIRES-X] CoolProp integration; Pressure-aware water property calculations (v3.4.2) (PR #121)
Looks good, but I don't understand the new construct on Model.py: self.reserv: Reservoir = TDPReservoir(self)
The addition of : Reservoir is a type hint. In this case I added the hint because it enabled PyCharm to give me better autocomplete suggestions as I was working on code that referenced model.reserv (i.e. typing model.reserv. and then being presented with suggestions for .value, .quantity(), etc.).
In general, we should ideally be using/adding type hints for all code as best practice since they improve contributor experience, code comprehensibility, and serve as a guardrail against many common classes of programming errors. I have created a tracking item for this: #100 https://github.com/NREL/GEOPHIRES-X/issues/100 . However, I am deferring on adding types everywhere for a few reasons for now:
So for now, I am just doing the following:
— Reply to this email directly, view it on GitHub https://github.com/NREL/GEOPHIRES-X/pull/121#issuecomment-1946531796 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AWGVYT5AKQHOJ2DPXSRKAFTYTY2ZVAVCNFSM6AAAAABDJKGS4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBWGUZTCNZZGY . You are receiving this because your review was requested. https://github.com/notifications/beacon/AWGVYT3IIPY5CRMGI7KPLUDYTY2ZVA5CNFSM6AAAAABDJKGS4OWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTUAW35I.gif Message ID: @. @.> >
Self-reviewed sub-PRs:
Reviewers are encouraged to look at diff to example outputs (https://github.com/NREL/GEOPHIRES-X/pull/121/files#diff-34b4448aead45f08341092fe535fc9270bcf1d8420c517)
Deployed and verified on backend/UI (https://jonathanpezzino.com/geothermal/geophires)