@@ -108,8 +108,11 @@ def test_analyse_structure(self):
108108 # Verify each site was notified of the new structure
109109 self .assertEqual (mock_notify .call_count , 3 )
110110
111- # Verify assign_site_occupations was called with atoms and structure
112- mock_assign .assert_called_once_with (self .atoms , self .structure )
111+ # Verify assign_site_occupations was called with atoms and lattice_matrix
112+ mock_assign .assert_called_once ()
113+ args = mock_assign .call_args [0 ]
114+ self .assertIs (args [0 ], self .atoms )
115+ np .testing .assert_array_equal (args [1 ], self .structure .lattice .matrix )
113116
114117 def test_assign_site_occupations_atom_in_site (self ):
115118 """Test assign_site_occupations when atoms are already in sites."""
@@ -126,7 +129,7 @@ def test_assign_site_occupations_atom_in_site(self):
126129 mock_contains_atom .return_value = True
127130
128131 # Call method
129- self .collection .assign_site_occupations (self .atoms , self .structure )
132+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
130133
131134 # Verify site occupations were reset
132135 self .assertEqual (self .site1 .contains_atoms , [])
@@ -154,7 +157,7 @@ def test_assign_site_occupations_atom_moved(self):
154157 mock_contains_atom .return_value = False
155158
156159 # Call method
157- self .collection .assign_site_occupations (self .atoms , self .structure )
160+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
158161
159162 # Verify site occupations were reset
160163 self .assertEqual (self .site1 .contains_atoms , [])
@@ -184,7 +187,7 @@ def test_assign_site_occupations_atom_not_in_site(self):
184187 mock_contains_atom .side_effect = lambda atom , ** kwargs : atom is self .atom1 and mock_contains_atom .mock_calls [0 ][1 ][0 ] is atom
185188
186189 # Call method
187- self .collection .assign_site_occupations (self .atoms , self .structure )
190+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
188191
189192 # Verify site occupations were reset
190193 self .assertEqual (self .site1 .contains_atoms , [])
@@ -217,7 +220,7 @@ def test_empty_atoms_list_polyhedral(self):
217220 )
218221
219222 # Call the method with empty atom list
220- collection .assign_site_occupations ([], structure )
223+ collection .assign_site_occupations ([], lattice . matrix )
221224
222225 # Verify that contains_atoms was reset for both sites
223226 self .assertEqual (site1 .contains_atoms , [])
@@ -311,7 +314,7 @@ def test_checks_recent_site_via_priority_heuristic(self):
311314 patch .object (collection , 'site_by_index' ) as mock_site_by_index :
312315 mock_site_by_index .return_value = mock_site
313316
314- collection .assign_site_occupations ([mock_atom ], mock_structure )
317+ collection .assign_site_occupations ([mock_atom ], np . eye ( 3 ) * 10.0 )
315318
316319 mock_site_by_index .assert_called_with (5 )
317320 mock_update .assert_called_with (mock_site , mock_atom )
@@ -501,7 +504,7 @@ def setUp(self):
501504 def test_calls_generator_for_each_atom (self ):
502505 """Test that _get_priority_sites is called once per atom."""
503506 with patch .object (self .collection , '_get_priority_sites' , return_value = []):
504- self .collection .assign_site_occupations (self .atoms , self .structure )
507+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
505508 self .collection ._get_priority_sites .assert_called_once_with (self .atom )
506509
507510 def test_calls_generator_for_multiple_atoms (self ):
@@ -511,7 +514,7 @@ def test_calls_generator_for_multiple_atoms(self):
511514 atoms = atoms_from_structure (self .structure , "Li" )
512515
513516 with patch .object (self .collection , '_get_priority_sites' , return_value = []):
514- self .collection .assign_site_occupations (atoms , self .structure )
517+ self .collection .assign_site_occupations (atoms , self .lattice . matrix )
515518 self .assertEqual (self .collection ._get_priority_sites .call_count , 2 )
516519
517520 def test_checks_sites_in_generator_order (self ):
@@ -523,7 +526,7 @@ def test_checks_sites_in_generator_order(self):
523526 with patch .object (self .collection , '_get_priority_sites' ) as mock_gen :
524527 mock_gen .return_value = [self .site2 , self .site1 ] # site2 first
525528
526- self .collection .assign_site_occupations (self .atoms , self .structure )
529+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
527530
528531 self .assertEqual (call_order , [2 ]) # Only site2 checked (found there)
529532
@@ -535,7 +538,7 @@ def test_stops_checking_when_atom_found(self):
535538 with patch .object (self .collection , '_get_priority_sites' ) as mock_gen :
536539 mock_gen .return_value = [self .site1 , self .site2 ]
537540
538- self .collection .assign_site_occupations (self .atoms , self .structure )
541+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
539542
540543 self .site1 .contains_atom .assert_called_once ()
541544 self .site2 .contains_atom .assert_not_called ()
@@ -546,7 +549,7 @@ def test_calls_update_occupation_when_found(self):
546549
547550 with patch .object (self .collection , '_get_priority_sites' , return_value = [self .site1 ]):
548551 with patch .object (self .collection , 'update_occupation' ) as mock_update :
549- self .collection .assign_site_occupations (self .atoms , self .structure )
552+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
550553 mock_update .assert_called_once_with (self .site1 , self .atom )
551554
552555 def test_handles_atom_not_found (self ):
@@ -555,7 +558,7 @@ def test_handles_atom_not_found(self):
555558
556559 with patch .object (self .collection , '_get_priority_sites' , return_value = [self .site1 ]):
557560 with patch .object (self .collection , 'update_occupation' ) as mock_update :
558- self .collection .assign_site_occupations (self .atoms , self .structure )
561+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
559562
560563 mock_update .assert_not_called ()
561564 self .assertIsNone (self .atom .in_site )
@@ -564,15 +567,15 @@ def test_resets_site_occupations(self):
564567 """Test that reset_site_occupations is called at start."""
565568 with patch .object (self .collection , 'reset_site_occupations' ) as mock_reset :
566569 with patch .object (self .collection , '_get_priority_sites' , return_value = []):
567- self .collection .assign_site_occupations (self .atoms , self .structure )
570+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
568571 mock_reset .assert_called_once ()
569572
570573 def test_resets_atom_in_site (self ):
571574 """Test that atom.in_site is reset to None."""
572575 self .atom .in_site = 999 # Set to some previous value
573576
574577 with patch .object (self .collection , '_get_priority_sites' , return_value = []):
575- self .collection .assign_site_occupations (self .atoms , self .structure )
578+ self .collection .assign_site_occupations (self .atoms , self .lattice . matrix )
576579 self .assertIsNone (self .atom .in_site )
577580
578581
0 commit comments