77# Packages
88import numpy as np
99from 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 ("\t WARNING: There is negative capital stock" )
778+ logging . info ("\t WARNING: There is negative capital stock" )
771779 flag2 = False
772780 if (nssmat < 0 ).any ():
773- print (
781+ logging . info (
774782 "\t WARNING: Labor supply violates nonnegativity " , "constraints."
775783 )
776784 flag2 = True
777785 if (nssmat > ltilde ).any ():
778- print ("\t WARNING: Labor supply violates the ltilde constraint." )
786+ logging . info ("\t WARNING: Labor supply violates the ltilde constraint." )
779787 flag2 = True
780788 if flag2 is False :
781- print (
789+ logging . info (
782790 "\t There were no violations of the constraints on labor" ,
783791 " supply." ,
784792 )
785793 if (cssmat < 0 ).any ():
786- print ("\t WARNING: Consumption violates nonnegativity" , " constraints." )
794+ logging . info ("\t WARNING: Consumption violates nonnegativity" , " constraints." )
787795 else :
788- print (
796+ logging . info (
789797 "\t There 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 "\t WARNING: 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 "\t WARNING: Labor supply violates nonnegativity" ,
820828 " constraints in period %.f." % t ,
821829 )
822830 if (n_dist > ltilde ).any ():
823- print (
831+ logging . info (
824832 "\t WARNING: Labor suppy violates the ltilde constraint" ,
825833 " in period %.f." % t ,
826834 )
827835 if (c_dist < 0 ).any ():
828- print (
836+ logging . info (
829837 "\t WARNING: Consumption violates nonnegativity" ,
830838 " constraints in period %.f." % t ,
831839 )
0 commit comments