-
Notifications
You must be signed in to change notification settings - Fork 357
chore: Remove Mypy errors from examples. #2171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 21 commits
d2bbe72
9a40415
d72ffc7
38bb1a4
d7bfe8a
88de9ca
4814d4b
f61f5a3
6bc5306
ae312d2
52b091c
2f9ef2f
bf46c85
4406a29
c8a487c
a40b748
74a7251
6a9c039
74653c8
6e7d9ab
f6e4d0d
a1f1f4d
db2ca2c
28d1e8f
13b772e
36da80e
bd12dad
e9788b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,11 @@ | |
| # Use the #graphics module to render splines. | ||
| # --- | ||
|
|
||
| import random | ||
7460m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import random | ||
| from h2o_wave import site, ui, graphics as g | ||
|
|
||
| x = [i * 20 for i in range(50)] | ||
| x = [i * 20.0 for i in range(50)] # Convert x to a list of floats | ||
| y = [ | ||
| 88, 100, 116, 128, 126, 128, 118, 108, 121, 120, 99, 113, 117, 103, 98, 90, 104, 98, 82, 102, 104, 89, 87, 69, | ||
| 88, 97, 91, 105, 98, 86, 90, 107, 97, 107, 108, 128, 144, 148, 126, 106, 89, 99, 78, 70, 69, 64, 45, 29, 27, 38 | ||
|
|
@@ -17,47 +18,59 @@ | |
|
|
||
| splines = [ | ||
| # Lines | ||
| g.spline(x=x, y=y, **line_style), # same as curve='linear' | ||
| g.spline(x=x, y=y, curve='basis', **line_style), | ||
| g.spline(x=x, y=y, curve='basis-closed', **line_style), | ||
| g.spline(x=x, y=y, curve='basis-open', **line_style), | ||
| g.spline(x=x, y=y, curve='cardinal', **line_style), | ||
| g.spline(x=x, y=y, curve='cardinal-closed', **line_style), | ||
| g.spline(x=x, y=y, curve='cardinal-open', **line_style), | ||
| g.spline(x=x, y=y, curve='smooth', **line_style), | ||
| g.spline(x=x, y=y, curve='smooth-closed', **line_style), | ||
| g.spline(x=x, y=y, curve='smooth-open', **line_style), | ||
| g.spline(x=x, y=y, curve='linear', **line_style), | ||
| g.spline(x=x, y=y, curve='linear-closed', **line_style), | ||
| g.spline(x=x, y=y, curve='monotone-x', **line_style), | ||
| g.spline(x=x, y=y, curve='monotone-y', **line_style), | ||
| g.spline(x=x, y=y, curve='natural', **line_style), | ||
| g.spline(x=x, y=y, curve='step', **line_style), | ||
| g.spline(x=x, y=y, curve='step-after', **line_style), | ||
| g.spline(x=x, y=y, curve='step-before', **line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='linear', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='basis', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='basis-closed', style=line_style), | ||
|
||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='basis-open', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='cardinal', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='cardinal-closed', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='cardinal-open', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='smooth', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='smooth-closed', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='smooth-open', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='linear-closed', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='monotone-x', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='monotone-y', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='natural', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='step', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='step-after', style=line_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], curve='step-before', style=line_style), | ||
| # Areas | ||
| g.spline(x=x, y=y, y0=y0, **area_style), # same as curve='linear' | ||
| g.spline(x=x, y=y, y0=y0, curve='basis', **area_style), | ||
| g.spline(x=x, y=y, y0=[], curve='basis', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='basis-open', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='cardinal', **area_style), | ||
| g.spline(x=x, y=y, y0=[], curve='cardinal', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='cardinal-open', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='smooth', **area_style), | ||
| g.spline(x=x, y=y, y0=[], curve='smooth', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='smooth-open', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='linear', **area_style), | ||
| g.spline(x=x, y=y, y0=[], curve='linear', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='monotone-x', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='monotone-y', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='natural', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='step', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='step-after', **area_style), | ||
| g.spline(x=x, y=y, y0=y0, curve='step-before', **area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='linear', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='basis', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[], curve='basis', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='basis-open', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='cardinal', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[], curve='cardinal', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='cardinal-open', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='smooth', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[], curve='smooth', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='smooth-open', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='linear', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[], curve='linear', style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='monotone-x', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='monotone-y', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='natural', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='step', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='step-after', | ||
| style=area_style), | ||
| g.spline(x=[float(v) for v in x], y=[float(v) for v in y], y0=[float(v) for v in y0], curve='step-before', | ||
| style=area_style), | ||
| ] | ||
|
|
||
| page = site['/demo'] | ||
| row, col = 1, 1 | ||
|
|
||
| for spline in splines: | ||
| page[f'spline_{col}_{row}'] = ui.graphics_card( | ||
| box=f'{col} {row} 3 1', view_box='0 0 1000 150', width='100%', height='100%', | ||
|
|
@@ -71,3 +84,16 @@ | |
| row, col = row + 1, 1 | ||
|
|
||
| page.save() | ||
| for spline in splines: | ||
| page[f'spline_{col}_{row}'] = ui.graphics_card( | ||
| box=f'{col} {row} 3 1', view_box='0 0 1000 150', width='100%', height='100%', | ||
| stage=g.stage( | ||
| text=g.text(text=spline.curve or '', y=40, font_size=40), | ||
| spline=spline, | ||
| ), | ||
| ) | ||
| col += 3 | ||
| if col > 11: | ||
| row, col = row + 1, 1 | ||
|
|
||
| page.save() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,11 +26,11 @@ | |
| 0.76648938, 0.89679732, 0.77222302, 0.92717429, 0.61465203, 0.60906377, | ||
| 0.68468487, 0.25101297, 0.83783764, 0.11861562, 0.79723474, 0.94900427, | ||
| 0.14806288])) ** 2, | ||
| c=[0.90687198, 0.78837333, 0.76840584, 0.59849648, 0.44214562, 0.72303802, | ||
| 0.41661825, 0.2268104, 0.45422734, 0.84794375, 0.93665595, 0.95603618, | ||
| 0.39209432, 0.70832467, 0.12951583, 0.35379639, 0.40427152, 0.6485339, | ||
| 0.03307097, 0.53800936, 0.13171312, 0.52093493, 0.10248479, 0.15798038, | ||
| 0.92002965], | ||
| c=[(0.90687198, 0.0, 0.0), (0.78837333, 0.0, 0.0), (0.76840584, 0.0, 0.0), (0.59849648, 0.0, 0.0), (0.44214562, 0.0, 0.0), (0.72303802, 0.0, 0.0), | ||
| (0.41661825, 0.0, 0.0), (0.2268104, 0.0, 0.0), (0.45422734, 0.0, 0.0), (0.84794375, 0.0, 0.0), (0.93665595, 0.0, 0.0), (0.95603618, 0.0, 0.0), | ||
| (0.39209432, 0.0, 0.0), (0.70832467, 0.0, 0.0), (0.12951583, 0.0, 0.0), (0.35379639, 0.0, 0.0), (0.40427152, 0.0, 0.0), (0.6485339, 0.0, 0.0), | ||
| (0.03307097, 0.0, 0.0), (0.53800936, 0.0, 0.0), (0.13171312, 0.0, 0.0), (0.52093493, 0.0, 0.0), (0.10248479, 0.0, 0.0), (0.15798038, 0.0, 0.0), | ||
| (0.92002965, 0.0, 0.0)], | ||
|
||
| alpha=0.5, | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,9 @@ def df_to_rows(df: pd.DataFrame): | |
|
|
||
|
|
||
| def search_df(df: pd.DataFrame, term: str): | ||
| str_cols = df.select_dtypes(include=[object]) | ||
| return df[str_cols.apply(lambda column: column.str.contains(term, case=False, na=False)).any(axis=1)] | ||
| str_cols = df.select_dtypes(include=['object']).columns | ||
| return df[df[str_cols].apply(lambda column: column.str.contains(term, case=False, na=False)).any(axis=1)] | ||
|
Comment on lines
+31
to
+32
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What mypy err does this resolve?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. table_filter_backend.py:31: error: List item 0 has incompatible type "type[object]"; expected "str" [list-item]
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The visual effect looks the same |
||
|
|
||
|
|
||
|
|
||
| @app('/demo') | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.