Mark Febrizio commited on
Commit
a99e6cc
·
1 Parent(s): eb08e90

Revert ""change significance filtering""

Browse files

This reverts commit eb08e9024b8b6e702e8bbbbaf9a3c9b99c3d9000.

Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -51,6 +51,7 @@ ui.include_css( Path(__file__).parent.joinpath("www") / "style.css")
51
  # this text appears in the browser tab
52
  TITLE = "CRA Window Tracker - GW Regulatory Studies Center"
53
 
 
54
  # page header above main content
55
  HEADER = "Rules in the Congressional Review Act (CRA) Window"
56
  page_header = ui.HTML(
@@ -93,7 +94,6 @@ FOOTER = f"""
93
 
94
 
95
  ui.tags.title(TITLE)
96
-
97
  # footer at the bottom of the page
98
  FOOTER = f"""
99
  -----
@@ -109,6 +109,7 @@ ui.tags.title(TITLE)
109
 
110
  page_header
111
 
 
112
  # sidebar settings
113
  with ui.sidebar(open={"desktop": "open", "mobile": "closed"}):
114
  sidebar_logo
@@ -126,8 +127,10 @@ with ui.sidebar(open={"desktop": "open", "mobile": "closed"}):
126
 
127
  #ui.input_switch("switch", "Stack significant rules in plots", False)
128
 
 
129
  # value boxes with summary data
130
  with ui.layout_column_wrap():
 
131
  with ui.value_box():
132
  "All final rules"
133
  @render.text
@@ -136,6 +139,7 @@ with ui.layout_column_wrap():
136
  ui.input_action_button("filter_all", "Clear Filters", class_="btn-filter", icon=icon_svg("book"))
137
  ui.input_action_button("filter_all", "Clear Filters", class_="btn-filter", icon=icon_svg("book"))
138
 
 
139
  with ui.value_box():
140
  "Section 3(f)(1) Significant rules *"
141
  @render.text
@@ -147,6 +151,7 @@ with ui.layout_column_wrap():
147
  ui.input_action_button("filter_3f1", "Filter", class_="btn-filter", icon=icon_svg("book"))
148
  ui.input_action_button("filter_3f1", "Filter", class_="btn-filter", icon=icon_svg("book"))
149
 
 
150
  with ui.value_box():
151
  "Other Significant rules *"
152
  @render.text
@@ -158,6 +163,7 @@ with ui.layout_column_wrap():
158
  ui.input_action_button("filter_other", "Filter", class_="btn-filter", icon=icon_svg("book"))
159
  ui.input_action_button("filter_other", "Filter", class_="btn-filter", icon=icon_svg("book"))
160
 
 
161
  # documentation note on significance data
162
  ui.markdown(
163
  f"""
@@ -165,6 +171,7 @@ ui.markdown(
165
  """
166
  )
167
 
 
168
  # main content
169
  with ui.navset_card_underline(title=""):
170
 
@@ -199,11 +206,14 @@ with ui.navset_card_underline(title=""):
199
  max_val = max(values, default=0)
200
  if (max_val < 2) or (count_gte_zero < 2):
201
  return plot_NA()
 
202
  else:
203
  return plot_tf(
204
  grouped,
205
  input.frequency(),
206
  rule_type=filter_value.get(),
 
 
207
  )
208
 
209
  with ui.card(full_screen=True):
@@ -248,6 +258,14 @@ with ui.navset_card_underline(title=""):
248
  rule_type=filter_value.get(),
249
  )
250
  return plot
 
 
 
 
 
 
 
 
251
 
252
  with ui.card(full_screen=True):
253
  @render.data_frame
@@ -262,6 +280,7 @@ with ui.navset_card_underline(title=""):
262
  ]
263
  return render.DataTable(grouped.loc[:, [c for c in cols if c in grouped.columns]])
264
 
 
265
  # download data
266
  with ui.accordion(open=False):
267
 
@@ -296,6 +315,7 @@ with ui.accordion(open=False):
296
  await asyncio.sleep(0.25)
297
  yield filtered_df().loc[:, output_cols].to_csv(index=False)
298
 
 
299
  # notes
300
  with ui.accordion(open=False):
301
 
@@ -309,6 +329,7 @@ with ui.accordion(open=False):
309
  """
310
  )
311
 
 
312
  # footer citation
313
  ui.markdown(
314
  FOOTER
@@ -333,6 +354,7 @@ def filtered_df():
333
  bool_agency = [True if sum(selected in agency for selected in input.menu_agency()) > 0 else False for agency in filt_df["parent_slug"]]
334
  filt_df = filt_df.loc[bool_agency]
335
 
 
336
  # filter significance
337
  bool_ = []
338
  if (input.menu_significant() is not None) and ("all" not in input.menu_significant()):
 
51
  # this text appears in the browser tab
52
  TITLE = "CRA Window Tracker - GW Regulatory Studies Center"
53
 
54
+ # page header above main content
55
  # page header above main content
56
  HEADER = "Rules in the Congressional Review Act (CRA) Window"
57
  page_header = ui.HTML(
 
94
 
95
 
96
  ui.tags.title(TITLE)
 
97
  # footer at the bottom of the page
98
  FOOTER = f"""
99
  -----
 
109
 
110
  page_header
111
 
112
+ # sidebar settings
113
  # sidebar settings
114
  with ui.sidebar(open={"desktop": "open", "mobile": "closed"}):
115
  sidebar_logo
 
127
 
128
  #ui.input_switch("switch", "Stack significant rules in plots", False)
129
 
130
+ # value boxes with summary data
131
  # value boxes with summary data
132
  with ui.layout_column_wrap():
133
+ with ui.value_box():
134
  with ui.value_box():
135
  "All final rules"
136
  @render.text
 
139
  ui.input_action_button("filter_all", "Clear Filters", class_="btn-filter", icon=icon_svg("book"))
140
  ui.input_action_button("filter_all", "Clear Filters", class_="btn-filter", icon=icon_svg("book"))
141
 
142
+ with ui.value_box():
143
  with ui.value_box():
144
  "Section 3(f)(1) Significant rules *"
145
  @render.text
 
151
  ui.input_action_button("filter_3f1", "Filter", class_="btn-filter", icon=icon_svg("book"))
152
  ui.input_action_button("filter_3f1", "Filter", class_="btn-filter", icon=icon_svg("book"))
153
 
154
+ with ui.value_box():
155
  with ui.value_box():
156
  "Other Significant rules *"
157
  @render.text
 
163
  ui.input_action_button("filter_other", "Filter", class_="btn-filter", icon=icon_svg("book"))
164
  ui.input_action_button("filter_other", "Filter", class_="btn-filter", icon=icon_svg("book"))
165
 
166
+ # documentation note on significance data
167
  # documentation note on significance data
168
  ui.markdown(
169
  f"""
 
171
  """
172
  )
173
 
174
+ # main content
175
  # main content
176
  with ui.navset_card_underline(title=""):
177
 
 
206
  max_val = max(values, default=0)
207
  if (max_val < 2) or (count_gte_zero < 2):
208
  return plot_NA()
209
+ return plot_NA()
210
  else:
211
  return plot_tf(
212
  grouped,
213
  input.frequency(),
214
  rule_type=filter_value.get(),
215
+ input.frequency(),
216
+ rule_type=filter_value.get(),
217
  )
218
 
219
  with ui.card(full_screen=True):
 
258
  rule_type=filter_value.get(),
259
  )
260
  return plot
261
+ if len(grouped) < 2:
262
+ return plot_NA()
263
+ else:
264
+ plot = plot_agency(
265
+ grouped.head(10),
266
+ rule_type=filter_value.get(),
267
+ )
268
+ return plot
269
 
270
  with ui.card(full_screen=True):
271
  @render.data_frame
 
280
  ]
281
  return render.DataTable(grouped.loc[:, [c for c in cols if c in grouped.columns]])
282
 
283
+ # download data
284
  # download data
285
  with ui.accordion(open=False):
286
 
 
315
  await asyncio.sleep(0.25)
316
  yield filtered_df().loc[:, output_cols].to_csv(index=False)
317
 
318
+ # notes
319
  # notes
320
  with ui.accordion(open=False):
321
 
 
329
  """
330
  )
331
 
332
+ # footer citation
333
  # footer citation
334
  ui.markdown(
335
  FOOTER
 
354
  bool_agency = [True if sum(selected in agency for selected in input.menu_agency()) > 0 else False for agency in filt_df["parent_slug"]]
355
  filt_df = filt_df.loc[bool_agency]
356
 
357
+ print(input.menu_significant())
358
  # filter significance
359
  bool_ = []
360
  if (input.menu_significant() is not None) and ("all" not in input.menu_significant()):