Skip to content

Commit 4d2453e

Browse files
committed
use logging in household.py
1 parent 896406b commit 4d2453e

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

ogcore/household.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
# Packages
88
import numpy as np
99
from ogcore import tax, utils
10+
import logging
11+
from ogcore.SS import VERBOSE
12+
13+
# Configure logging
14+
log_level = logging.INFO if VERBOSE else logging.WARNING
15+
logging.basicConfig(
16+
level=log_level, format="%(message)s" # Only show the message itself
17+
)
1018

1119
"""
1220
------------------------------------------------------------------------
@@ -764,28 +772,28 @@ def constraint_checker_SS(bssmat, nssmat, cssmat, ltilde):
764772
Warnings: if constraints are violated, warnings printed
765773
766774
"""
767-
print("Checking constraints on capital, labor, and consumption.")
775+
logging.info("Checking constraints on capital, labor, and consumption.")
768776

769777
if (bssmat < 0).any():
770-
print("\tWARNING: There is negative capital stock")
778+
logging.info("\tWARNING: There is negative capital stock")
771779
flag2 = False
772780
if (nssmat < 0).any():
773-
print(
781+
logging.info(
774782
"\tWARNING: Labor supply violates nonnegativity ", "constraints."
775783
)
776784
flag2 = True
777785
if (nssmat > ltilde).any():
778-
print("\tWARNING: Labor supply violates the ltilde constraint.")
786+
logging.info("\tWARNING: Labor supply violates the ltilde constraint.")
779787
flag2 = True
780788
if flag2 is False:
781-
print(
789+
logging.info(
782790
"\tThere were no violations of the constraints on labor",
783791
" supply.",
784792
)
785793
if (cssmat < 0).any():
786-
print("\tWARNING: Consumption violates nonnegativity", " constraints.")
794+
logging.info("\tWARNING: Consumption violates nonnegativity", " constraints.")
787795
else:
788-
print(
796+
logging.info(
789797
"\tThere were no violations of the constraints on", " consumption."
790798
)
791799

@@ -810,22 +818,22 @@ def constraint_checker_TPI(b_dist, n_dist, c_dist, t, ltilde):
810818
811819
"""
812820
if (b_dist <= 0).any():
813-
print(
821+
logging.info(
814822
"\tWARNING: Aggregate capital is less than or equal to ",
815823
"zero in period %.f." % t,
816824
)
817825
if (n_dist < 0).any():
818-
print(
826+
logging.info(
819827
"\tWARNING: Labor supply violates nonnegativity",
820828
" constraints in period %.f." % t,
821829
)
822830
if (n_dist > ltilde).any():
823-
print(
831+
logging.info(
824832
"\tWARNING: Labor suppy violates the ltilde constraint",
825833
" in period %.f." % t,
826834
)
827835
if (c_dist < 0).any():
828-
print(
836+
logging.info(
829837
"\tWARNING: Consumption violates nonnegativity",
830838
" constraints in period %.f." % t,
831839
)

0 commit comments

Comments
 (0)