bryan-stearns commited on
Commit
9bedfdd
1 Parent(s): 9a7eb03

Fixing print for prim-exists obj class

Browse files
Files changed (2) hide show
  1. Inspect_Logic.py +4 -2
  2. smem_obj.py +23 -10
Inspect_Logic.py CHANGED
@@ -51,9 +51,10 @@ def get_filter_features_dict(root_obj):
51
  # Get the content to filter on
52
  features_dict = get_filter_features_dict(st.session_state.col_obj_list[0])
53
  filters_expander = st.expander(label="Filters")
54
- filters_cols = filters_expander.columns(len(features_dict))
55
  filters_dict = {}
56
- for key, col in zip(features_dict, filters_cols):
 
57
  filters_dict[key] = col.multiselect(label=key, options=["(none)"]+sorted(features_dict[key]))
58
 
59
 
@@ -102,6 +103,7 @@ for i,col in enumerate(cols):
102
  obj = st.session_state.col_obj_list[i]
103
  obj_str,obj_label,obj_desc = obj.to_string()
104
  sub_objs = list(obj.get_child_objects(compact=True))
 
105
  # print(obj.obj_type)
106
  if len(sub_objs) > 0:
107
  col.markdown("**"+get_header_str(sub_objs[0].obj_type)+"**",)
 
51
  # Get the content to filter on
52
  features_dict = get_filter_features_dict(st.session_state.col_obj_list[0])
53
  filters_expander = st.expander(label="Filters")
54
+ filters_cols = filters_expander.columns(min(len(features_dict), 5)) # Show 5 filters per row
55
  filters_dict = {}
56
+ for i,key in enumerate(features_dict):
57
+ col = filters_cols[i % len(filters_cols)]
58
  filters_dict[key] = col.multiselect(label=key, options=["(none)"]+sorted(features_dict[key]))
59
 
60
 
 
103
  obj = st.session_state.col_obj_list[i]
104
  obj_str,obj_label,obj_desc = obj.to_string()
105
  sub_objs = list(obj.get_child_objects(compact=True))
106
+ sub_objs.sort(key=lambda x:x.to_string()[1])
107
  # print(obj.obj_type)
108
  if len(sub_objs) > 0:
109
  col.markdown("**"+get_header_str(sub_objs[0].obj_type)+"**",)
smem_obj.py CHANGED
@@ -43,17 +43,24 @@ class SMEM_Obj():
43
  for child in children:
44
  _, short_label, desc = child.to_string()
45
  # Trim the label based on the object type
46
- if child.obj_type == ObjType.COND_PRIM:
47
  if desc and desc != "()":
48
  str_to_use = desc
 
 
 
 
 
 
49
  else:
50
  str_to_use = short_label
51
- try:
52
- ind = str_to_use.index(" is ")
53
- feature, value = str_to_use.replace("(","").replace(")","").split(" is ",maxsplit=1)
54
- dict_of_values[feature].add(value)
55
- except:
56
- print("ERROR: str_to_use missing 'is'. Value was: '"+str(str_to_use)+"'")
 
57
  # Merge this dict of sets with results from each branch of children
58
  child_dict = child.get_referenced_features(dict_of_values)
59
  for key, val in child_dict.items():
@@ -156,14 +163,20 @@ class SMEM_Obj():
156
  if len(self.wme_list) == 0:
157
  return "", ""
158
  if negate:
159
- op_join_str = " is not "
 
 
 
160
  else:
161
- op_join_str = " is "
 
 
 
162
  if self.class_str == None:
163
  self.get_class()
164
 
165
  retval_long, retval_short, retval_desc = ["(", "(", None]
166
- if self.class_str == "prim":
167
  group_str, attr_str, val_str = ["","",""]
168
  for (attr,val) in self.wme_list:
169
  if attr == "^group":
 
43
  for child in children:
44
  _, short_label, desc = child.to_string()
45
  # Trim the label based on the object type
46
+ if child.get_class() == "prim":
47
  if desc and desc != "()":
48
  str_to_use = desc
49
+ try:
50
+ ind = str_to_use.index(" is ")
51
+ feature, value = str_to_use.replace("(","").replace(")","").split(" is ",maxsplit=1)
52
+ dict_of_values[feature].add(value)
53
+ except:
54
+ print("ERROR: str_to_use missing 'is'. Value was: '"+str(str_to_use)+"'")
55
  else:
56
  str_to_use = short_label
57
+ try:
58
+ ind = str_to_use.index(" = ")
59
+ feature, value = str_to_use.replace("(","").replace(")","").split(" = ",maxsplit=1)
60
+ dict_of_values[feature].add(value)
61
+ except:
62
+ print("ERROR: str_to_use missing '='. Value was: '"+str(str_to_use)+"'")
63
+
64
  # Merge this dict of sets with results from each branch of children
65
  child_dict = child.get_referenced_features(dict_of_values)
66
  for key, val in child_dict.items():
 
163
  if len(self.wme_list) == 0:
164
  return "", ""
165
  if negate:
166
+ if self.class_str == "prim-exists":
167
+ op_join_str = " not provided"
168
+ else:
169
+ op_join_str = " is not "
170
  else:
171
+ if self.class_str == "prim-exists":
172
+ op_join_str = " provided"
173
+ else:
174
+ op_join_str = " is "
175
  if self.class_str == None:
176
  self.get_class()
177
 
178
  retval_long, retval_short, retval_desc = ["(", "(", None]
179
+ if self.class_str == "prim" or self.class_str == "prim-exists":
180
  group_str, attr_str, val_str = ["","",""]
181
  for (attr,val) in self.wme_list:
182
  if attr == "^group":