示例#1
0
 def from_json_str(cls, json_str: str, instruction_set: InstructionSet):
     """Create a PushSolution from a JSON string."""
     solution_dict = json.loads(json_str)
     return cls(
         CodeBlock.from_json_str(
             json.dumps(solution_dict["program"], separators=(',', ':')),
             instruction_set), solution_dict["output_types"])
示例#2
0
文件: estimators.py 项目: erp12/Pysh
 def from_json_str(cls, json_str: str, instruction_set: InstructionSet):
     """Create a PushSolution from a JSON string."""
     solution_dict = json.loads(json_str)
     return cls(
         CodeBlock.from_json_str(
             json.dumps(solution_dict["program"], separators=(',', ':')),
             instruction_set
         ),
         solution_dict["output_types"]
     )
def load_program(name: str) -> CodeBlock:
    with open("tests/resources/programs/" + name + ".json") as f:
        return CodeBlock.from_json_str(f.read(), i_set)
示例#4
0
def load_program(name, interpreter) -> CodeBlock:
    with open("tests/resources/programs/" + name + ".json") as f:
        return CodeBlock.from_json_str(f.read(), interpreter.instruction_set)