Skip to content

Commit 5d0b79b

Browse files
committed
Fix code completion
1 parent 6101cdc commit 5d0b79b

10 files changed

Lines changed: 244 additions & 7025 deletions

File tree

docs/examples/advanced.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
"source": [
1818
"import numpy as np\n",
1919
"import pandas as pd\n",
20-
"import xarray as xr\n",
2120
"\n",
22-
"import xarray_plotly"
21+
"from xarray_plotly import DataArray # IDE completion for .plotly"
2322
]
2423
},
2524
{
@@ -37,7 +36,7 @@
3736
"metadata": {},
3837
"outputs": [],
3938
"source": [
40-
"da = xr.DataArray(\n",
39+
"da = DataArray(\n",
4140
" np.random.randn(30, 3).cumsum(axis=0) + 15,\n",
4241
" dims=[\"time\", \"station\"],\n",
4342
" coords={\n",
@@ -377,7 +376,7 @@
377376
"fig = monthly_mean.plotly.line(\n",
378377
" title=\"Monthly Climatology\",\n",
379378
")\n",
380-
"fig.update_xaxes(tickmode=\"array\", tickvals=list(range(1, 13)), \n",
379+
"fig.update_xaxes(tickmode=\"array\", tickvals=list(range(1, 13)),\n",
381380
" ticktext=[\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n",
382381
" \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"])\n",
383382
"fig"

docs/examples/plot-types.ipynb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
"source": [
1818
"import numpy as np\n",
1919
"import pandas as pd\n",
20-
"import xarray as xr\n",
2120
"\n",
22-
"import xarray_plotly"
21+
"from xarray_plotly import DataArray # IDE completion for .plotly"
2322
]
2423
},
2524
{
@@ -40,7 +39,7 @@
4039
"np.random.seed(42)\n",
4140
"\n",
4241
"# Time series data\n",
43-
"da_ts = xr.DataArray(\n",
42+
"da_ts = DataArray(\n",
4443
" np.random.randn(30, 3).cumsum(axis=0),\n",
4544
" dims=[\"time\", \"category\"],\n",
4645
" coords={\n",
@@ -51,7 +50,7 @@
5150
")\n",
5251
"\n",
5352
"# 2D grid data\n",
54-
"da_2d = xr.DataArray(\n",
53+
"da_2d = DataArray(\n",
5554
" np.random.rand(20, 30),\n",
5655
" dims=[\"lat\", \"lon\"],\n",
5756
" coords={\n",
@@ -62,7 +61,7 @@
6261
")\n",
6362
"\n",
6463
"# Categorical data\n",
65-
"da_cat = xr.DataArray(\n",
64+
"da_cat = DataArray(\n",
6665
" np.random.rand(4, 3) * 100,\n",
6766
" dims=[\"product\", \"region\"],\n",
6867
" coords={\n",
@@ -161,7 +160,7 @@
161160
"outputs": [],
162161
"source": [
163162
"# Use absolute values for stacking to make sense\n",
164-
"da_positive = xr.DataArray(\n",
163+
"da_positive = DataArray(\n",
165164
" np.abs(np.random.randn(30, 3)) * 10,\n",
166165
" dims=[\"time\", \"source\"],\n",
167166
" coords={\n",
@@ -229,7 +228,7 @@
229228
"outputs": [],
230229
"source": [
231230
"# Create data with more samples\n",
232-
"da_dist = xr.DataArray(\n",
231+
"da_dist = DataArray(\n",
233232
" np.random.randn(100, 4) + np.array([0, 1, 2, 3]),\n",
234233
" dims=[\"sample\", \"group\"],\n",
235234
" coords={\"group\": [\"Control\", \"Treatment A\", \"Treatment B\", \"Treatment C\"]},\n",
@@ -295,7 +294,7 @@
295294
"outputs": [],
296295
"source": [
297296
"# 3D data for faceting\n",
298-
"da_3d = xr.DataArray(\n",
297+
"da_3d = DataArray(\n",
299298
" np.random.randn(30, 3, 2).cumsum(axis=0),\n",
300299
" dims=[\"time\", \"city\", \"scenario\"],\n",
301300
" coords={\n",
@@ -330,11 +329,11 @@
330329
"outputs": [],
331330
"source": [
332331
"# Create monthly data\n",
333-
"da_monthly = xr.DataArray(\n",
332+
"da_monthly = DataArray(\n",
334333
" np.random.rand(12, 4) * 100,\n",
335334
" dims=[\"month\", \"product\"],\n",
336335
" coords={\n",
337-
" \"month\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \n",
336+
" \"month\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n",
338337
" \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],\n",
339338
" \"product\": [\"A\", \"B\", \"C\", \"D\"],\n",
340339
" },\n",

0 commit comments

Comments
 (0)