33import numpy as np
44
55
6- def rdf (sys , sel_type = [ None , None ] , max_r = 5 , nbins = 100 ):
6+ def rdf (sys , sel_type = None , max_r = 5 , nbins = 100 ):
77 """Compute the rdf of a system.
88
99 Parameters
@@ -40,7 +40,12 @@ def rdf(sys, sel_type=[None, None], max_r=5, nbins=100):
4040 )
4141
4242
43- def compute_rdf (box , posis , atype , sel_type = [None , None ], max_r = 5 , nbins = 100 ):
43+ def compute_rdf (box , posis , atype , sel_type = None , max_r = 5 , nbins = 100 ):
44+ """Compute an RDF without mutating the caller's selection list."""
45+ if sel_type is None :
46+ sel_type = [None , None ]
47+ else :
48+ sel_type = list (sel_type )
4449 nframes = box .shape [0 ]
4550 xx = None
4651 all_rdf = []
@@ -58,7 +63,13 @@ def compute_rdf(box, posis, atype, sel_type=[None, None], max_r=5, nbins=100):
5863 return xx , all_rdf , all_cod
5964
6065
61- def _compute_rdf_1frame (box , posis , atype , sel_type = [None , None ], max_r = 5 , nbins = 100 ):
66+ def _compute_rdf_1frame (box , posis , atype , sel_type = None , max_r = 5 , nbins = 100 ):
67+ if sel_type is None :
68+ sel_type = [None , None ]
69+ else :
70+ # Normalise into a fresh list because the two ``None`` replacements
71+ # below must not leak into a caller-owned list or a function default.
72+ sel_type = list (sel_type )
6273 all_types = list (set (list (np .sort (atype , kind = "stable" ))))
6374 if sel_type [0 ] is None :
6475 sel_type [0 ] = all_types
0 commit comments