@@ -76,6 +76,8 @@ def __init__(self, **kwargs):
7676 self .center = (0 , 0 )
7777
7878 # axes
79+ if 'area' in kwargs :
80+ kwargs ['size' ] = 2 * np .sqrt (kwargs ['area' ] / np .pi )
7981 if ('a' in kwargs ) and ('b' in kwargs ):
8082 assert kwargs ['a' ] > 0
8183 assert kwargs ['b' ] > 0
@@ -369,10 +371,17 @@ def area_expectation(cls, **kwargs):
369371
370372 if type (s_dist ) in (float , int ):
371373 return 0.25 * np .pi * s_dist * s_dist
372- else :
373- return 0.25 * np .pi * s_dist .moment (2 )
374+ return 0.25 * np .pi * s_dist .moment (2 )
375+
376+ if 'area' in kwargs :
377+ a_dist = kwargs ['area' ]
378+ try :
379+ a_exp = a_dist .moment (1 )
380+ except AttributeError :
381+ a_exp = a_dist
382+ return a_exp
374383
375- elif ('a' in kwargs ) and ('b' in kwargs ):
384+ if ('a' in kwargs ) and ('b' in kwargs ):
376385 exp = np .pi
377386 for kw in ('a' , 'b' ):
378387 dist = kwargs [kw ]
@@ -382,7 +391,8 @@ def area_expectation(cls, **kwargs):
382391 mu = dist .moment (1 )
383392 exp *= mu
384393 return exp
385- elif ('b' in kwargs ) and ('aspect_ratio' in kwargs ):
394+
395+ if ('b' in kwargs ) and ('aspect_ratio' in kwargs ):
386396 exp = np .pi
387397 try :
388398 exp *= kwargs ['b' ].moment (2 )
@@ -394,7 +404,8 @@ def area_expectation(cls, **kwargs):
394404 except AttributeError :
395405 exp *= kwargs ['aspect_ratio' ]
396406 return exp
397- elif ('a' in kwargs ) and ('aspect_ratio' in kwargs ):
407+
408+ if ('a' in kwargs ) and ('aspect_ratio' in kwargs ):
398409 n = 1000
399410 try :
400411 a = kwargs ['a' ].rvs (size = n )
@@ -406,10 +417,10 @@ def area_expectation(cls, **kwargs):
406417 except AttributeError :
407418 k = np .full (n , kwargs ['aspect_ratio' ])
408419 return np .pi * np .mean ((a * a ) / k )
409- else :
410- e_str = 'Could not calculate expected area from keywords '
411- e_str += str (kwargs .keys ()) + '.'
412- raise KeyError (e_str )
420+
421+ e_str = 'Could not calculate expected area from keywords '
422+ e_str += str (kwargs .keys ()) + '.'
423+ raise KeyError (e_str )
413424
414425 # ----------------------------------------------------------------------- #
415426 # Bounding Circles #
0 commit comments