Example #1
0
 def wolfram_cloud_call(**args):
     arguments = dict([(key, arg) for key, arg in args.items()])
     try:
         result = urlopen("http://www.wolframcloud.com/objects/724d6409-5efb-4bcb-907a-6897aad95193",
                          urlencode(arguments).encode("ascii"))
     except:
         raise Failure("Cannot connect to servers")
     return result.read()
Example #2
0
 def wolfram_cloud_call(**args):
     arguments = dict([(key, arg) for key, arg in args.items()])
     try:
         result = urlopen("http://www.wolframcloud.com/objects/5c991864-3fbd-4b30-8200-d1a398aee0e2",
                          urlencode(arguments).encode("ascii"))
     except:
         raise Failure("Cannot connect to servers")
     return result.read()
Example #3
0
    def __cmp__(self, other):
        """
        Compares with another value. Used by >, <, ==, and !=

        :param other:
        :return:

         >>> Infinity(True) > 5
         True
         >>> Infinity(True) < 5
         False
         >>> Infinity(False) > Infinity(True)
         False
         >>> Infinity(None) == 0
         Traceback (most recent call last):
            ...
         Failure: Cannot be compared
         >>> Infinity(True) == float("inf")
         True
         >>> float("inf") > Infinity(None)
         Traceback (most recent call last):
            ...
         Failure: Cannot be compared
         >>>
        """
        from amath.testing.types import isinf
        if isinf(other):
            if isinstance(other, Infinity):
                if other.n is None:
                    raise

                elif other.n < self.n:
                    return 1
                else:
                    return -1
            if other == float("inf"):
                if self.n:
                    return 0
                elif self.n is False:
                    return -1
            elif other == float("-inf"):
                if self.n:
                    return 1
                elif self.n is False:
                    return 0
        if self.n:
            return 1
        elif self.n is False:
            return -1
        else:
            raise Failure("Cannot be compared")
Example #4
0
def tolong(x):
    try:
        return long(x)
    except NameError:
        from amath.Errors import Failure
        raise Failure("Long is not supported")