Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -236,4 +236,86 @@ print(df.dtypes)
|
|
| 236 |
|
| 237 |
fig = px.scatter(df, x='int_col', y='float_col', title='Data Types')
|
| 238 |
fig.show()
|
| 239 |
-
print("Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
fig = px.scatter(df, x='int_col', y='float_col', title='Data Types')
|
| 238 |
fig.show()
|
| 239 |
+
print("Data types test complete!")''',
|
| 240 |
+
|
| 241 |
+
"Compare Methods": '''# Compare DataFrame vs Direct
|
| 242 |
+
import plotly.express as px
|
| 243 |
+
import pandas as pd
|
| 244 |
+
|
| 245 |
+
print("=== Method 1: DataFrame ===")
|
| 246 |
+
df = pd.DataFrame({'x': [1, 2, 3], 'y': [1, 4, 9]})
|
| 247 |
+
fig1 = px.scatter(df, x='x', y='y', title='DataFrame Method')
|
| 248 |
+
fig1.show()
|
| 249 |
+
|
| 250 |
+
print("=== Method 2: Direct Arrays ===")
|
| 251 |
+
fig2 = px.scatter(x=[1, 2, 3], y=[1, 4, 9], title='Direct Method')
|
| 252 |
+
fig2.show()
|
| 253 |
+
|
| 254 |
+
print("Comparison complete!")'''
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
with gr.Blocks() as demo:
|
| 258 |
+
gr.Markdown("# π§ͺ Plotly Express Test Suite")
|
| 259 |
+
gr.Markdown("**Test different Express examples** to find what works and what doesn't")
|
| 260 |
+
|
| 261 |
+
pyodide_interface = gr.HTML(create_pyodide_interface())
|
| 262 |
+
|
| 263 |
+
with gr.Row():
|
| 264 |
+
with gr.Column(scale=2):
|
| 265 |
+
code_input = gr.Textbox(
|
| 266 |
+
value=examples["Minimal Test"],
|
| 267 |
+
lines=12,
|
| 268 |
+
label="Test Code"
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
run_btn = gr.Button("π Run Test", variant="primary", size="lg")
|
| 272 |
+
|
| 273 |
+
with gr.Column(scale=1):
|
| 274 |
+
gr.Markdown("### π Quick Tests")
|
| 275 |
+
|
| 276 |
+
example_buttons = []
|
| 277 |
+
for name, code in examples.items():
|
| 278 |
+
btn = gr.Button(f"π {name}", variant="secondary")
|
| 279 |
+
example_buttons.append((btn, code))
|
| 280 |
+
|
| 281 |
+
status_output = gr.Textbox(
|
| 282 |
+
label="Result",
|
| 283 |
+
interactive=False,
|
| 284 |
+
lines=3
|
| 285 |
+
)
|
| 286 |
+
|
| 287 |
+
gr.Markdown("""
|
| 288 |
+
### π― **Testing Strategy:**
|
| 289 |
+
|
| 290 |
+
1. **Start with "Minimal Test"** - absolute basics
|
| 291 |
+
2. **Try "Direct Arrays"** - no DataFrames involved
|
| 292 |
+
3. **Test "Simple DataFrame"** - basic DataFrame usage
|
| 293 |
+
4. **Run "Compare Methods"** - see DataFrame vs direct difference
|
| 294 |
+
5. **Check "Data Types"** - see if data type issues exist
|
| 295 |
+
|
| 296 |
+
### π **What to Watch:**
|
| 297 |
+
- β
**Data points visible** = Working correctly
|
| 298 |
+
- β **Only background/axes** = Data issue
|
| 299 |
+
- π **Check output messages** for clues
|
| 300 |
+
|
| 301 |
+
### π‘ **Expected Results:**
|
| 302 |
+
Based on your previous tests, some of these might work while others show only background.
|
| 303 |
+
""")
|
| 304 |
+
|
| 305 |
+
# Event handlers
|
| 306 |
+
run_btn.click(
|
| 307 |
+
fn=None,
|
| 308 |
+
inputs=[code_input],
|
| 309 |
+
outputs=[status_output],
|
| 310 |
+
js="(code) => window.runCode ? window.runCode(code) : 'Not ready'"
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
# Example button handlers
|
| 314 |
+
for btn, code in example_buttons:
|
| 315 |
+
btn.click(
|
| 316 |
+
fn=lambda c=code: c,
|
| 317 |
+
outputs=[code_input]
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
if __name__ == "__main__":
|
| 321 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|