Skip to content

Commit 7dd5587

Browse files
committed
Update examples to use lower case reactive.effect and .calc
1 parent 7a4911e commit 7dd5587

File tree

63 files changed

+107
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+107
-107
lines changed

examples/airmass/app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ def server(input: Inputs, output: Outputs, session: Session):
6161
loc = location_server("location")
6262
time_padding = datetime.timedelta(hours=1.5)
6363

64-
@reactive.Calc
64+
@reactive.calc
6565
def obj_names() -> List[str]:
6666
"""Returns a split and *slightly* cleaned-up list of object names"""
6767
req(input.objects())
6868
return [x.strip() for x in input.objects().split(",") if x.strip() != ""]
6969

70-
@reactive.Calc
70+
@reactive.calc
7171
def obj_coords() -> List[SkyCoord]:
7272
return [SkyCoord.from_name(name) for name in obj_names()]
7373

74-
@reactive.Calc
74+
@reactive.calc
7575
def times_utc() -> Tuple[datetime.datetime, datetime.datetime]:
7676
req(input.date())
7777
lat, long = loc()
@@ -81,18 +81,18 @@ def times_utc() -> Tuple[datetime.datetime, datetime.datetime]:
8181
sun.get_sunrise_time(input.date() + datetime.timedelta(days=1)),
8282
)
8383

84-
@reactive.Calc
84+
@reactive.calc
8585
def timezone() -> Optional[str]:
8686
lat, long = loc()
8787
return timezonefinder.TimezoneFinder().timezone_at(lat=lat, lng=long)
8888

89-
@reactive.Calc
89+
@reactive.calc
9090
def times_at_loc():
9191
start, end = times_utc()
9292
tz = pytz.timezone(timezone())
9393
return (start.astimezone(tz), end.astimezone(tz))
9494

95-
@reactive.Calc
95+
@reactive.calc
9696
def df() -> Dict[str, pd.DataFrame]:
9797
start, end = times_at_loc()
9898
times = pd.date_range(

examples/airmass/location.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,24 @@ def on_map_interaction(**kwargs):
100100

101101
register_widget("map", map)
102102

103-
@reactive.Effect
103+
@reactive.effect
104104
def _():
105105
coords = reactive_read(marker, "location")
106106
if coords:
107107
update_text_inputs(coords[0], coords[1])
108108

109-
@reactive.Effect
109+
@reactive.effect
110110
def sync_autolocate():
111111
coords = input.here()
112112
ui.notification_remove("searching")
113113
if coords and not input.lat() and not input.long():
114114
update_text_inputs(coords["latitude"], coords["longitude"])
115115

116-
@reactive.Effect
116+
@reactive.effect
117117
def sync_inputs_to_marker():
118118
update_marker(input.lat(), input.long())
119119

120-
@reactive.Calc
120+
@reactive.calc
121121
def location():
122122
"""Returns tuple of (lat,long) floats--or throws silent error if no lat/long is
123123
selected"""

examples/annotation-export/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
def server(input: Inputs, output: Outputs, session: Session):
4242
annotated_data = reactive.Value(weather_df)
4343

44-
@reactive.Calc
44+
@reactive.calc
4545
def selected_data():
4646
out = brushed_points(annotated_data(), input.time_series_brush(), xvar="date")
4747
return out
4848

49-
@reactive.Effect
49+
@reactive.effect
5050
@reactive.event(input.annotate_button)
5151
def _():
5252
selected = selected_data()

examples/brownian/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
def server(input, output, session):
4545
# BROWNIAN MOTION ====
4646

47-
@reactive.Calc
47+
@reactive.calc
4848
def random_walk():
4949
"""Generates brownian data whenever 'New Data' is clicked"""
5050
input.data_btn()
@@ -54,7 +54,7 @@ def random_walk():
5454
widget = brownian_widget(600, 600)
5555
register_widget("plot", widget)
5656

57-
@reactive.Effect
57+
@reactive.effect
5858
def update_plotly_data():
5959
walk = random_walk()
6060
layer = widget.data[0]
@@ -65,7 +65,7 @@ def update_plotly_data():
6565

6666
# HAND TRACKING ====
6767

68-
@reactive.Calc
68+
@reactive.calc
6969
def camera_eye():
7070
"""The eye position, as reflected by the hand input"""
7171
hand_val = input.hand()
@@ -78,7 +78,7 @@ def camera_eye():
7878
# The raw data is a little jittery. Smooth it out by averaging a few samples
7979
smooth_camera_eye = reactive_smooth(n_samples=5, smoother=xyz_mean)(camera_eye)
8080

81-
@reactive.Effect
81+
@reactive.effect
8282
def update_plotly_camera():
8383
"""Update Plotly camera using the hand tracking"""
8484
widget.layout.scene.camera.eye = smooth_camera_eye()
@@ -114,7 +114,7 @@ def wrapper(calc):
114114
buffer = [] # Ring buffer of capacity `n_samples`
115115
result = reactive.Value(None) # Holds the most recent smoothed result
116116

117-
@reactive.Effect
117+
@reactive.effect
118118
def _():
119119
# Get latest value. Because this is happening in a reactive Effect, we'll
120120
# automatically take a reactive dependency on whatever is happening in the

examples/cpuinfo/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
)
103103

104104

105-
@reactive.Calc
105+
@reactive.calc
106106
def cpu_current():
107107
reactive.invalidate_later(SAMPLE_PERIOD)
108108
return cpu_percent(percpu=True)
@@ -111,7 +111,7 @@ def cpu_current():
111111
def server(input: Inputs, output: Outputs, session: Session):
112112
cpu_history = reactive.Value(None)
113113

114-
@reactive.Calc
114+
@reactive.calc
115115
def cpu_history_with_hold():
116116
# If "hold" is on, grab an isolated snapshot of cpu_history; if not, then do a
117117
# regular read
@@ -123,7 +123,7 @@ def cpu_history_with_hold():
123123
with reactive.isolate():
124124
return cpu_history()
125125

126-
@reactive.Effect
126+
@reactive.effect
127127
def collect_cpu_samples():
128128
"""cpu_percent() reports just the current CPU usage sample; this Effect gathers
129129
them up and stores them in the cpu_history reactive value, in a numpy 2D array

examples/dataframe/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def light_dark_switcher(dark):
5757
def server(input: Inputs, output: Outputs, session: Session):
5858
df: reactive.Value[pd.DataFrame] = reactive.Value()
5959

60-
@reactive.Effect
60+
@reactive.effect
6161
def update_df():
6262
return df.set(sns.load_dataset(req(input.dataset())))
6363

@@ -82,7 +82,7 @@ def grid():
8282
row_selection_mode=input.selection_mode(),
8383
)
8484

85-
@reactive.Effect
85+
@reactive.effect
8686
@reactive.event(input.grid_cell_edit)
8787
def handle_edit():
8888
edit = input.grid_cell_edit()

examples/duckdb/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def server(input, output, session):
7171

7272
query_output_server("initial_query", con=con, remove_id="initial_query")
7373

74-
@reactive.Effect
74+
@reactive.effect
7575
@reactive.event(input.add_query)
7676
def _():
7777
counter = mod_counter.get() + 1
@@ -84,7 +84,7 @@ def _():
8484
)
8585
query_output_server(id, con=con, remove_id=id)
8686

87-
@reactive.Effect
87+
@reactive.effect
8888
@reactive.event(input.show_meta)
8989
def _():
9090
counter = mod_counter.get() + 1
@@ -99,7 +99,7 @@ def _():
9999
)
100100
query_output_server(id, con=con, remove_id=id)
101101

102-
@reactive.Effect
102+
@reactive.effect
103103
@reactive.event(input.rmv)
104104
def _():
105105
ui.remove_ui(selector="div:has(> #txt)")

examples/duckdb/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def results():
5757

5858
return result
5959

60-
@reactive.Effect
60+
@reactive.effect
6161
@reactive.event(input.rmv)
6262
def _():
6363
ui.remove_ui(selector=f"div#{remove_id}")

examples/event/app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727

2828

2929
def server(input: Inputs, output: Outputs, session: Session):
30-
@reactive.Effect
30+
@reactive.effect
3131
@reactive.event(input.btn)
3232
def _():
3333
print("@effect() event: ", str(input.btn()))
3434

35-
@reactive.Calc
35+
@reactive.calc
3636
@reactive.event(input.btn)
3737
def btn() -> int:
3838
return input.btn()
3939

40-
@reactive.Effect
40+
@reactive.effect
4141
def _():
4242
print("@calc() event: ", str(btn()))
4343

@@ -49,19 +49,19 @@ def btn_value():
4949
# -----------------------------------------------------------------------------
5050
# Async
5151
# -----------------------------------------------------------------------------
52-
@reactive.Effect
52+
@reactive.effect
5353
@reactive.event(input.btn_async)
5454
async def _():
5555
await asyncio.sleep(0)
5656
print("async @effect() event: ", str(input.btn_async()))
5757

58-
@reactive.Calc
58+
@reactive.calc
5959
@reactive.event(input.btn_async)
6060
async def btn_async_r() -> int:
6161
await asyncio.sleep(0)
6262
return input.btn_async()
6363

64-
@reactive.Effect
64+
@reactive.effect
6565
async def _():
6666
val = await btn_async_r()
6767
print("async @calc() event: ", str(val))

examples/express/shared_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def histogram():
2020
ui.input_slider("n", "N", 1, 100, 50)
2121

2222

23-
@reactive.Effect
23+
@reactive.effect
2424
def _():
2525
shared.rv.set(input.n())
2626

0 commit comments

Comments
 (0)