@@ -161,6 +161,24 @@ def _conclude(self, ):
161161 rdf = self .count / (density * vol * self .nf )
162162 self .rdf = rdf
163163
164+ @property
165+ def cdf (self ):
166+ """Calculate the cumulative distribution functions (CDF).
167+ Note that this is the actual count within a given radius, i.e.,
168+ :math:`N(r)`.
169+
170+ Returns
171+ -------
172+ cdf : numpy array
173+ a numpy array with the same structure as :attr:`rdf`
174+
175+
176+ .. versionadded:: 0.3.0
177+ """
178+ cdf = np .cumsum (self .count ) / self .nf
179+
180+ return cdf
181+
164182 @staticmethod
165183 def _reduce (res , result_single_frame ):
166184 """ 'add' action for an accumulator"""
@@ -318,7 +336,8 @@ def _conclude(self):
318336
319337 self .rdf = rdf
320338
321- def get_cdf (self ):
339+ @property
340+ def cdf (self ):
322341 """Calculate the cumulative distribution functions (CDF) for all sites.
323342 Note that this is the actual count within a given radius, i.e.,
324343 :math:`N(r)`.
@@ -327,18 +346,20 @@ def get_cdf(self):
327346 -------
328347 cdf : list
329348 list of arrays with the same structure as :attr:`rdf`
349+
350+
351+ .. versionadded:: 0.3.0
352+ Method ``get_cdf()`` was removed and :attr:`cdf` is now a managed
353+ attribute that computes the CDF when accessed.
330354 """
331355 # Calculate cumulative distribution function
332356 # Empty list to restore CDF
333357 cdf = []
334358
359+ # cdf is a list of cdf between pairs of AtomGroups in ags
335360 for count in self .count :
336361 cdf .append (np .cumsum (count , axis = 2 ) / self .nf )
337362
338- # Results stored in self.cdf
339- # self.cdf is a list of cdf between pairs of AtomGroups in ags
340- self .cdf = cdf
341-
342363 return cdf
343364
344365 @staticmethod
0 commit comments