@@ -172,27 +172,23 @@ def test__init__(self, fix1_model, postgres_uri):
172172 # )
173173
174174 model .test_dc = DataCollector (
175- model = model ,
176- agent_reporters = {"wealth" : lambda m : 1 }
175+ model = model , agent_reporters = {"wealth" : lambda m : 1 }
177176 )
178177 assert model .test_dc is not None
179178
180179 with pytest .raises (
181180 TypeError ,
182181 match = "Agent reporter keys must be strings" ,
183182 ):
184- model .test_dc = DataCollector (
185- model = model ,
186- agent_reporters = {123 : "wealth" }
187- )
183+ model .test_dc = DataCollector (model = model , agent_reporters = {123 : "wealth" })
188184
189185 with pytest .raises (
190186 TypeError ,
191187 match = "must be either a string .* or a callable" ,
192188 ):
193189 model .test_dc = DataCollector (
194- model = model ,
195- agent_reporters = {"wealth" : 123 } # This is illegal
190+ model = model ,
191+ agent_reporters = {"wealth" : 123 }, # This is illegal
196192 )
197193
198194 with pytest .raises (
@@ -752,7 +748,7 @@ def test_collect_no_agentsets_list(self, fix1_model, caplog):
752748
753749 dc = DataCollector (model = model , agent_reporters = {"wealth" : "wealth" })
754750 dc .collect ()
755-
751+
756752 assert "could not find '_agentsets'" in caplog .text
757753 assert dc .data ["agent" ].shape == (0 , 0 )
758754
@@ -762,29 +758,35 @@ def test_collect_agent_set_no_df(self, fix1_model, caplog):
762758 class NoDfSet :
763759 def __init__ (self ):
764760 self .__class__ = type ("NoDfSet" , (object ,), {})
765-
761+
766762 fix1_model .sets ._agentsets .append (NoDfSet ())
767-
768- fix1_model .dc = DataCollector (fix1_model , agent_reporters = {"wealth" : "wealth" , "age" : "age" })
763+
764+ fix1_model .dc = DataCollector (
765+ fix1_model , agent_reporters = {"wealth" : "wealth" , "age" : "age" }
766+ )
769767 fix1_model .dc .collect ()
770-
768+
771769 assert "has no 'df' attribute" in caplog .text
772- assert fix1_model .dc .data ["agent" ].shape == (12 , 7 )
770+ assert fix1_model .dc .data ["agent" ].shape == (12 , 7 )
773771
774772 def test_collect_df_no_unique_id (self , fix1_model , caplog ):
775773 """Tests that the collector logs a warning and skips a set if its df has no unique_id."""
776- bad_set = fix1_model .sets ._agentsets [0 ]
777- bad_set ._df = bad_set ._df .drop ("unique_id" )
778-
779- fix1_model .dc = DataCollector (fix1_model , agent_reporters = {"wealth" : "wealth" , "age" : "age" })
774+ bad_set = fix1_model .sets ._agentsets [0 ]
775+ bad_set ._df = bad_set ._df .drop ("unique_id" )
776+
777+ fix1_model .dc = DataCollector (
778+ fix1_model , agent_reporters = {"wealth" : "wealth" , "age" : "age" }
779+ )
780780 fix1_model .dc .collect ()
781-
781+
782782 assert "has no 'unique_id' column" in caplog .text
783783 assert fix1_model .dc .data ["agent" ].shape == (8 , 7 )
784784
785785 def test_collect_no_matching_reporters (self , fix1_model ):
786786 """Tests that the collector returns an empty frame if no reporters match any columns."""
787- fix1_model .dc = DataCollector (fix1_model , agent_reporters = {"baz" : "foo" , "qux" : "bar" })
787+ fix1_model .dc = DataCollector (
788+ fix1_model , agent_reporters = {"baz" : "foo" , "qux" : "bar" }
789+ )
788790 fix1_model .dc .collect ()
789791
790- assert fix1_model .dc .data ["agent" ].shape == (0 , 0 )
792+ assert fix1_model .dc .data ["agent" ].shape == (0 , 0 )
0 commit comments