Goal
Address pervasive code-hygiene issues that hurt debuggability and reliability. Part of #3. These are independent, low-risk cleanups suitable for several small PRs.
Findings
print() used for diagnostics (~75 occurrences). e.g. SimExec.py:79-83, Phases.py:148-153, Commons.py:319-321. No way to control verbosity. → Replace with the logging module (module-level loggers, levels).
- Bare
except: clauses that swallow all errors. e.g. ThermoModule.py:82, StatsModule.py:413, Crystallizers.py:124. → Catch specific exceptions; re-raise or log.
- Hardcoded relative data paths that break once installed/moved. e.g.
Streams.py:292 ('../../data/evaporator/compounds_evap.json'), ParamEstim.py:1339 ('../data/englezos_example.csv'), SolidLiquidSep.py:1346 ('../../../publications/...'). → Resolve via importlib.resources / package data, or require explicit paths.
- Commented-out / dead code (e.g. stale JAX/autograd blocks
Crystallizers.py:37-46, 120-125) and unnecessary # -*- coding: utf-8 -*- headers. → Remove.
Tasks
Acceptance criteria
- No bare
except: remain (enforced by a lint rule, e.g. flake8 E722).
- Library emits via
logging, silent by default for importers.
- Data files resolve correctly when PharmaPy is pip-installed outside the source tree.
Suggested split
Do these as 3-4 separate PRs (logging, excepts, paths, dead code) to keep diffs reviewable.
Upstream PR
Wave 2 — split into separate small upstream PRs (logging / bare excepts / paths / dead code). Never bundle with a formatting pass — that mixing is what triggered the #107 revert. See #3.
Goal
Address pervasive code-hygiene issues that hurt debuggability and reliability. Part of #3. These are independent, low-risk cleanups suitable for several small PRs.
Findings
print()used for diagnostics (~75 occurrences). e.g.SimExec.py:79-83,Phases.py:148-153,Commons.py:319-321. No way to control verbosity. → Replace with theloggingmodule (module-level loggers, levels).except:clauses that swallow all errors. e.g.ThermoModule.py:82,StatsModule.py:413,Crystallizers.py:124. → Catch specific exceptions; re-raise or log.Streams.py:292('../../data/evaporator/compounds_evap.json'),ParamEstim.py:1339('../data/englezos_example.csv'),SolidLiquidSep.py:1346('../../../publications/...'). → Resolve viaimportlib.resources/ package data, or require explicit paths.Crystallizers.py:37-46, 120-125) and unnecessary# -*- coding: utf-8 -*-headers. → Remove.Tasks
prints (keep genuine user-facing output deliberate).Acceptance criteria
except:remain (enforced by a lint rule, e.g. flake8E722).logging, silent by default for importers.Suggested split
Do these as 3-4 separate PRs (logging, excepts, paths, dead code) to keep diffs reviewable.
Upstream PR
Wave 2 — split into separate small upstream PRs (logging / bare excepts / paths / dead code). Never bundle with a formatting pass — that mixing is what triggered the #107 revert. See #3.