22// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information.
44
5+ #nullable enable
6+
57using System ;
68using System . Collections ;
79using System . Collections . Generic ;
810using System . Diagnostics ;
911using System . Linq ;
1012using System . Numerics ;
1113
12- using Microsoft . Scripting ;
13- using Microsoft . Scripting . Utils ;
14-
1514using IronPython . Runtime ;
1615using IronPython . Runtime . Operations ;
17- using IronPython . Runtime . Types ;
16+
17+ using Microsoft . Scripting . Utils ;
1818
1919[ assembly: PythonModule ( "math" , typeof ( IronPython . Modules . PythonMath ) ) ]
2020namespace IronPython . Modules {
@@ -78,7 +78,7 @@ private static double sum(List<double> partials) {
7878 return hi ;
7979 }
8080
81- public static double fsum ( IEnumerable e ) {
81+ public static double fsum ( [ NotNone ] IEnumerable e ) {
8282 // msum from https://code.activestate.com/recipes/393090/
8383 var partials = new List < double > ( ) ;
8484 foreach ( var v in e . Cast < object > ( ) . Select ( o => Converter . ConvertToDouble ( o ) ) ) {
@@ -205,7 +205,7 @@ public static double log(BigInteger value) {
205205 return value . Log ( ) ;
206206 }
207207
208- public static double log ( object value ) {
208+ public static double log ( object ? value ) {
209209 // CPython tries float first, then double, so we need
210210 // an explicit overload which properly matches the order here
211211 double val ;
@@ -227,7 +227,7 @@ public static double log(BigInteger value, double newBase) {
227227 return Check ( value . Log ( newBase ) ) ;
228228 }
229229
230- public static double log ( object value , double newBase ) {
230+ public static double log ( object ? value , double newBase ) {
231231 // CPython tries float first, then double, so we need
232232 // an explicit overload which properly matches the order here
233233 double val ;
@@ -287,7 +287,7 @@ public static double log10(BigInteger value) {
287287 return value . Log10 ( ) ;
288288 }
289289
290- public static double log10 ( object value ) {
290+ public static double log10 ( object ? value ) {
291291 // CPython tries float first, then double, so we need
292292 // an explicit overload which properly matches the order here
293293 double val ;
@@ -320,7 +320,7 @@ public static double log1p(BigInteger value) {
320320 return log ( value + BigInteger . One ) ;
321321 }
322322
323- public static double log1p ( object value ) {
323+ public static double log1p ( object ? value ) {
324324 // CPython tries float first, then double, so we need
325325 // an explicit overload which properly matches the order here
326326 double val ;
@@ -353,7 +353,7 @@ public static double asinh(double x) {
353353#endif
354354 }
355355
356- public static double asinh ( object value ) {
356+ public static double asinh ( object ? value ) {
357357 // CPython tries float first, then double, so we need
358358 // an explicit overload which properly matches the order here
359359 double val ;
@@ -385,7 +385,7 @@ public static double acosh(double x) {
385385#endif
386386 }
387387
388- public static double acosh ( object value ) {
388+ public static double acosh ( object ? value ) {
389389 // CPython tries float first, then double, so we need
390390 // an explicit overload which properly matches the order here
391391 double val ;
@@ -420,7 +420,7 @@ public static double atanh(BigInteger value) {
420420 }
421421 }
422422
423- public static double atanh ( object value ) {
423+ public static double atanh ( object ? value ) {
424424 // CPython tries float first, then double, so we need
425425 // an explicit overload which properly matches the order here
426426 double val ;
@@ -448,7 +448,7 @@ public static double atan2(double v0, double v1) {
448448 return Math . Atan2 ( v0 , v1 ) ;
449449 }
450450
451- public static object ceil ( CodeContext context , object x ) {
451+ public static object ceil ( CodeContext context , object ? x ) {
452452 object val ;
453453 if ( PythonTypeOps . TryInvokeUnaryOperator ( context , x , "__ceil__" , out val ) ) {
454454 return val ;
@@ -508,7 +508,7 @@ public static object factorial(BigInteger value) {
508508 return ( int ) val ;
509509 }
510510
511- public static object factorial ( object value ) {
511+ public static object factorial ( object ? value ) {
512512 // CPython tries float first, then double, so we need
513513 // an explicit overload which properly matches the order here
514514 double val ;
@@ -519,7 +519,7 @@ public static object factorial(object value) {
519519 }
520520 }
521521
522- public static object floor ( CodeContext context , object x ) {
522+ public static object floor ( CodeContext context , object ? x ) {
523523 object val ;
524524 if ( PythonTypeOps . TryInvokeUnaryOperator ( context , x , "__floor__" , out val ) ) {
525525 return val ;
@@ -553,8 +553,8 @@ public static double lgamma(double v0) {
553553 return Check ( v0 , MathUtils . LogGamma ( v0 ) ) ;
554554 }
555555
556- public static object trunc ( CodeContext /*!*/ context , object value ) {
557- object func ;
556+ public static object ? trunc ( CodeContext /*!*/ context , object ? value ) {
557+ object ? func ;
558558 if ( PythonOps . TryGetBoundAttr ( value , "__trunc__" , out func ) ) {
559559 return PythonOps . CallWithContext ( context , func ) ;
560560 } else {
@@ -574,7 +574,7 @@ public static bool isinf(BigInteger value) {
574574 return false ;
575575 }
576576
577- public static bool isinf ( object value ) {
577+ public static bool isinf ( object ? value ) {
578578 // CPython tries float first, then double, so we need
579579 // an explicit overload which properly matches the order here
580580 double val ;
@@ -592,7 +592,7 @@ public static bool isnan(BigInteger value) {
592592 return false ;
593593 }
594594
595- public static bool isnan ( object value ) {
595+ public static bool isnan ( object ? value ) {
596596 // CPython tries float first, then double, so we need
597597 // an explicit overload which properly matches the order here
598598 double val ;
@@ -606,7 +606,7 @@ public static double copysign(double x, double y) {
606606 return DoubleOps . CopySign ( x , y ) ;
607607 }
608608
609- public static double copysign ( object x , object y ) {
609+ public static double copysign ( object ? x , object ? y ) {
610610 double val , sign ;
611611 if ( ! Converter . TryConvertToDouble ( x , out val ) ||
612612 ! Converter . TryConvertToDouble ( y , out sign ) ) {
@@ -623,10 +623,10 @@ public static object gcd(BigInteger x, BigInteger y) {
623623 return res ;
624624 }
625625
626- public static object gcd ( object x , object y ) {
626+ public static object gcd ( object ? x , object ? y ) {
627627 return gcd ( ObjectToBigInteger ( x ) , ObjectToBigInteger ( y ) ) ;
628628
629- static BigInteger ObjectToBigInteger ( object x ) {
629+ static BigInteger ObjectToBigInteger ( object ? x ) {
630630 BigInteger a ;
631631 switch ( PythonOps . Index ( x ) ) {
632632 case int i :
0 commit comments