@@ -641,17 +641,20 @@ public PTuple frexpO(Object value) {
641641 }
642642
643643 @ Builtin (name = "isnan" , fixedNumOfArguments = 1 )
644+ @ TypeSystemReference (PythonArithmeticTypes .class )
645+ @ ImportStatic (MathGuards .class )
644646 @ GenerateNodeFactory
645- @ SuppressWarnings ("unused" )
646647 public abstract static class IsNanNode extends PythonBuiltinNode {
647648
649+ public abstract boolean execute (Object value );
650+
648651 @ Specialization
649- public boolean isNan (int value ) {
652+ public boolean isNan (@ SuppressWarnings ( "unused" ) long value ) {
650653 return false ;
651654 }
652655
653656 @ Specialization
654- public boolean isNan (long value ) {
657+ public boolean isNan (@ SuppressWarnings ( "unused" ) PInt value ) {
655658 return false ;
656659 }
657660
@@ -660,24 +663,19 @@ public boolean isNan(double value) {
660663 return Double .isNaN (value );
661664 }
662665
663- @ Specialization
664- public boolean isNan (PInt value ) {
665- return false ;
666- }
667-
668- @ Specialization
669- public boolean isNan (PFloat value ) {
670- return Double .isNaN (value .getValue ());
666+ @ Specialization (guards = "!isNumber(value)" )
667+ public boolean isinf (Object value ,
668+ @ Cached ("create(__FLOAT__)" ) LookupAndCallUnaryNode dispatchFloat ,
669+ @ Cached ("create()" ) IsNanNode isNanNode ) {
670+ Object result = dispatchFloat .executeObject (value );
671+ if (result == PNone .NO_VALUE ) {
672+ throw raise (TypeError , "must be real number, not %p" , value );
673+ }
674+ return isNanNode .execute (result );
671675 }
672676
673- @ Specialization
674- public boolean isNan (boolean value ) {
675- return false ;
676- }
677-
678- @ Fallback
679- public boolean isNan (Object value ) {
680- throw raise (TypeError , "must be real number, not %p" , value );
677+ protected IsNanNode create () {
678+ return MathModuleBuiltinsFactory .IsNanNodeFactory .create (new PNode [0 ]);
681679 }
682680 }
683681
@@ -837,7 +835,7 @@ public abstract static class AcosNode extends PythonBuiltinNode {
837835 public abstract double execute (Object value );
838836
839837 @ Specialization
840- public double acos (int value ,
838+ public double acos (long value ,
841839 @ Cached ("createBinaryProfile()" ) ConditionProfile doNotFit ) {
842840 if (doNotFit .profile (value > 1 || value < -1 )) {
843841 throw raise (ValueError , "math domain error" );
@@ -906,6 +904,84 @@ public double sin(double value) {
906904 }
907905 }
908906
907+ @ Builtin (name = "isfinite" , fixedNumOfArguments = 1 )
908+ @ TypeSystemReference (PythonArithmeticTypes .class )
909+ @ ImportStatic (MathGuards .class )
910+ @ GenerateNodeFactory
911+ public abstract static class IsFiniteNode extends PythonBuiltinNode {
912+
913+ public abstract boolean execute (Object value );
914+
915+ @ Specialization
916+ public boolean isfinite (@ SuppressWarnings ("unused" ) long value ) {
917+ return true ;
918+ }
919+
920+ @ Specialization
921+ public boolean isfinite (@ SuppressWarnings ("unused" ) PInt value ) {
922+ return true ;
923+ }
924+
925+ @ Specialization
926+ public boolean isfinite (double value ) {
927+ return Double .isFinite (value );
928+ }
929+
930+ @ Specialization (guards = "!isNumber(value)" )
931+ public boolean isinf (Object value ,
932+ @ Cached ("create(__FLOAT__)" ) LookupAndCallUnaryNode dispatchFloat ,
933+ @ Cached ("create()" ) IsFiniteNode isFiniteNode ) {
934+ Object result = dispatchFloat .executeObject (value );
935+ if (result == PNone .NO_VALUE ) {
936+ throw raise (TypeError , "must be real number, not %p" , value );
937+ }
938+ return isFiniteNode .execute (result );
939+ }
940+
941+ protected IsFiniteNode create () {
942+ return MathModuleBuiltinsFactory .IsFiniteNodeFactory .create (new PNode [0 ]);
943+ }
944+ }
945+
946+ @ Builtin (name = "isinf" , fixedNumOfArguments = 1 )
947+ @ TypeSystemReference (PythonArithmeticTypes .class )
948+ @ ImportStatic (MathGuards .class )
949+ @ GenerateNodeFactory
950+ public abstract static class IsInfNode extends PythonBuiltinNode {
951+
952+ public abstract boolean execute (Object value );
953+
954+ @ Specialization
955+ public boolean isinf (@ SuppressWarnings ("unused" ) long value ) {
956+ return false ;
957+ }
958+
959+ @ Specialization
960+ public boolean isfinite (@ SuppressWarnings ("unused" ) PInt value ) {
961+ return false ;
962+ }
963+
964+ @ Specialization
965+ public boolean isinf (double value ) {
966+ return Double .isInfinite (value );
967+ }
968+
969+ @ Specialization (guards = "!isNumber(value)" )
970+ public boolean isinf (Object value ,
971+ @ Cached ("create(__FLOAT__)" ) LookupAndCallUnaryNode dispatchFloat ,
972+ @ Cached ("create()" ) IsInfNode isInfNode ) {
973+ Object result = dispatchFloat .executeObject (value );
974+ if (result == PNone .NO_VALUE ) {
975+ throw raise (TypeError , "must be real number, not %p" , value );
976+ }
977+ return isInfNode .execute (result );
978+ }
979+
980+ protected IsInfNode create () {
981+ return MathModuleBuiltinsFactory .IsInfNodeFactory .create (new PNode [0 ]);
982+ }
983+ }
984+
909985 @ Builtin (name = "log" , minNumOfArguments = 1 , maxNumOfArguments = 2 )
910986 @ GenerateNodeFactory
911987 public abstract static class LogNode extends PythonBuiltinNode {
0 commit comments