original_docstring: Check the equivalence of two mathematical expressions.
docstring: Check the equivalence of two mathematical expressions.
docstring_tokens: Check the equivalence of two mathematical expressions .
code: def check_maths():
      """Check the equivalence of two mathematical expressions."""
      body = request.get_json(force=True)
  
      if not (("test" in body) and ("target" in body)):
          print("=" * 50)
          print("ERROR: Ill-formed request!")
          print(body)
          print("=" * 50)
          abort(400)  # Probably want to just abort with a '400 BAD REQUEST'
  
      target_str = body.get("target")
      test_str = body.get("test")
      description = body.get("description")
  
      _empty_input = (target_str == "") or (test_str == "")
      _unprintable_input = not (target_str.isprintable() and test_str.isprintable())
      if _empty_input or _unprintable_input:
          print("=" * 50)
          if description is not None:
              print(description)
              print("=" * 50)
          print("ERROR: {} string in request!".format("Unprintable" if _unprintable_input else "Empty"))
          print("=" * 50)
          abort(400)  # Probably want to just abort with a '400 BAD REQUEST'
  
      symbols = body.get("symbols")
      check_symbols = str(body.get("check_symbols", "true")).lower() == "true"
  
      # To reduce computation issues on single-threaded server, institute a timeout
      # for requests. If it takes longer than this to process, return an error.
      # This cannot interrupt numpy's computation, so care must be taken in selecting
      # a value for MAX_REQUEST_COMPUTATION_TIME.
      try:
          with TimeoutProtection(MAX_REQUEST_COMPUTATION_TIME):
              response_dict = maths.check(test_str, target_str, symbols=symbols, check_symbols=check_symbols, description=description)
              return jsonify(**response_dict)
      except TimeoutException as e:
          print("ERROR: {} - Request took too long to process, aborting!".format(type(e).__name__))
          print("=" * 50)
          error_dict = dict(
              target=target_str,
              test=test_str,
              error="Request took too long to process!",
              )
          return jsonify(**error_dict)
code_tokens: def check_maths ( ) : body = request . get_json ( force = True ) if not ( ( "test" in body ) and ( "target" in body ) ) : print ( "=" * 50 ) print ( "ERROR: Ill-formed request!" ) print ( body ) print ( "=" * 50 ) abort ( 400 ) target_str = body . get ( "target" ) test_str = body . get ( "test" ) description = body . get ( "description" ) _empty_input = ( target_str == "" ) or ( test_str == "" ) _unprintable_input = not ( target_str . isprintable ( ) and test_str . isprintable ( ) ) if _empty_input or _unprintable_input : print ( "=" * 50 ) if description is not None : print ( description ) print ( "=" * 50 ) print ( "ERROR: {} string in request!" . format ( "Unprintable" if _unprintable_input else "Empty" ) ) print ( "=" * 50 ) abort ( 400 ) symbols = body . get ( "symbols" ) check_symbols = str ( body . get ( "check_symbols" , "true" ) ) . lower ( ) == "true" try : with TimeoutProtection ( MAX_REQUEST_COMPUTATION_TIME ) : response_dict = maths . check ( test_str , target_str , symbols = symbols , check_symbols = check_symbols , description = description ) return jsonify ( ** response_dict ) except TimeoutException as e : print ( "ERROR: {} - Request took too long to process, aborting!" . format ( type ( e ) . __name__ ) ) print ( "=" * 50 ) error_dict = dict ( target = target_str , test = test_str , error = "Request took too long to process!" , ) return jsonify ( ** error_dict )
short_docstring: Check the equivalence of two mathematical expressions.
short_docstring_tokens: Check the equivalence of two mathematical expressions .
comment: """Check the equivalence of two mathematical expressions."""$SEP$# Probably want to just abort with a '400 BAD REQUEST'$SEP$# Probably want to just abort with a '400 BAD REQUEST'$SEP$# To reduce computation issues on single-threaded server, institute a timeout$SEP$# for requests. If it takes longer than this to process, return an error.$SEP$# This cannot interrupt numpy's computation, so care must be taken in selecting$SEP$# a value for MAX_REQUEST_COMPUTATION_TIME.