black formatting
This commit is contained in:
@@ -4,14 +4,13 @@ from enum import Enum
|
||||
from logics.bags import *
|
||||
|
||||
rsLTL_form_type = Enum(
|
||||
'rsLTL_form_type',
|
||||
'bag l_and l_or l_not l_implies t_globally t_finally t_next t_until t_release')
|
||||
"rsLTL_form_type",
|
||||
"bag l_and l_or l_not l_implies t_globally t_finally t_next t_until t_release",
|
||||
)
|
||||
|
||||
|
||||
class Formula_rsLTL(object):
|
||||
|
||||
def __init__(
|
||||
self, f_type, L_oper=None, R_oper=None, sub_oper=None, bag=None):
|
||||
def __init__(self, f_type, L_oper=None, R_oper=None, sub_oper=None, bag=None):
|
||||
self.f_type = f_type
|
||||
self.left_operand = L_oper
|
||||
self.right_operand = R_oper
|
||||
@@ -21,7 +20,10 @@ class Formula_rsLTL(object):
|
||||
# it's silly, but it's a frequent mistake
|
||||
if callable(sub_oper):
|
||||
raise RuntimeError(
|
||||
"sub_oper should not be a function. Missing () for {0}?".format(sub_oper))
|
||||
"sub_oper should not be a function. Missing () for {0}?".format(
|
||||
sub_oper
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(self.left_operand, BagDescription):
|
||||
self.left_operand = Formula_rsLTL.f_bag(self.left_operand)
|
||||
@@ -43,21 +45,37 @@ class Formula_rsLTL(object):
|
||||
if self.f_type == rsLTL_form_type.t_next:
|
||||
return "X[" + repr(self.sub_operand) + "](" + repr(self.left_operand) + ")"
|
||||
if self.f_type == rsLTL_form_type.l_and:
|
||||
return "(" + repr(self.left_operand) + " & " + repr(self.right_operand) + ")"
|
||||
return (
|
||||
"(" + repr(self.left_operand) + " & " + repr(self.right_operand) + ")"
|
||||
)
|
||||
if self.f_type == rsLTL_form_type.l_or:
|
||||
return "(" + repr(self.left_operand) + " | " + repr(self.right_operand) + ")"
|
||||
return (
|
||||
"(" + repr(self.left_operand) + " | " + repr(self.right_operand) + ")"
|
||||
)
|
||||
if self.f_type == rsLTL_form_type.l_implies:
|
||||
return "(" + repr(self.left_operand) + " => " + repr(self.right_operand) + ")"
|
||||
return (
|
||||
"(" + repr(self.left_operand) + " => " + repr(self.right_operand) + ")"
|
||||
)
|
||||
if self.f_type == rsLTL_form_type.t_until:
|
||||
return "(" + repr(
|
||||
self.left_operand) + " U[" + repr(
|
||||
self.sub_operand) + "] " + repr(
|
||||
self.right_operand) + ")"
|
||||
return (
|
||||
"("
|
||||
+ repr(self.left_operand)
|
||||
+ " U["
|
||||
+ repr(self.sub_operand)
|
||||
+ "] "
|
||||
+ repr(self.right_operand)
|
||||
+ ")"
|
||||
)
|
||||
if self.f_type == rsLTL_form_type.t_release:
|
||||
return "(" + repr(
|
||||
self.left_operand) + " R[" + repr(
|
||||
self.sub_operand) + "] " + repr(
|
||||
self.right_operand) + ")"
|
||||
return (
|
||||
"("
|
||||
+ repr(self.left_operand)
|
||||
+ " R["
|
||||
+ repr(self.sub_operand)
|
||||
+ "] "
|
||||
+ repr(self.right_operand)
|
||||
+ ")"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_bag(self):
|
||||
@@ -93,8 +111,7 @@ class Formula_rsLTL(object):
|
||||
|
||||
@classmethod
|
||||
def f_U(cls, sub, arg_L, arg_R):
|
||||
return cls(
|
||||
rsLTL_form_type.t_until, L_oper=arg_L, R_oper=arg_R, sub_oper=sub)
|
||||
return cls(rsLTL_form_type.t_until, L_oper=arg_L, R_oper=arg_R, sub_oper=sub)
|
||||
|
||||
@classmethod
|
||||
def f_F(cls, sub, arg_L):
|
||||
@@ -102,9 +119,7 @@ class Formula_rsLTL(object):
|
||||
|
||||
@classmethod
|
||||
def f_R(cls, sub, arg_L, arg_R):
|
||||
return cls(
|
||||
rsLTL_form_type.t_release, L_oper=arg_L, R_oper=arg_R,
|
||||
sub_oper=sub)
|
||||
return cls(rsLTL_form_type.t_release, L_oper=arg_L, R_oper=arg_R, sub_oper=sub)
|
||||
|
||||
def __and__(self, other):
|
||||
return Formula_rsLTL(rsLTL_form_type.l_and, L_oper=self, R_oper=other)
|
||||
|
||||
Reference in New Issue
Block a user