Skip to content

Commit 6d8ee3a

Browse files
committed
Fix code completion
1 parent 5d0b79b commit 6d8ee3a

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

docs/examples/advanced.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"source": [
1818
"import numpy as np\n",
1919
"import pandas as pd\n",
20+
"import xarray as xr\n",
2021
"\n",
21-
"from xarray_plotly import DataArray # IDE completion for .plotly"
22+
"import xarray_plotly"
2223
]
2324
},
2425
{
@@ -36,7 +37,7 @@
3637
"metadata": {},
3738
"outputs": [],
3839
"source": [
39-
"da = DataArray(\n",
40+
"da = xr.DataArray(\n",
4041
" np.random.randn(30, 3).cumsum(axis=0) + 15,\n",
4142
" dims=[\"time\", \"station\"],\n",
4243
" coords={\n",
@@ -376,7 +377,7 @@
376377
"fig = monthly_mean.plotly.line(\n",
377378
" title=\"Monthly Climatology\",\n",
378379
")\n",
379-
"fig.update_xaxes(tickmode=\"array\", tickvals=list(range(1, 13)),\n",
380+
"fig.update_xaxes(tickmode=\"array\", tickvals=list(range(1, 13)), \n",
380381
" ticktext=[\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n",
381382
" \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"])\n",
382383
"fig"

docs/examples/plot-types.ipynb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"source": [
1818
"import numpy as np\n",
1919
"import pandas as pd\n",
20+
"import xarray as xr\n",
2021
"\n",
21-
"from xarray_plotly import DataArray # IDE completion for .plotly"
22+
"import xarray_plotly"
2223
]
2324
},
2425
{
@@ -39,7 +40,7 @@
3940
"np.random.seed(42)\n",
4041
"\n",
4142
"# Time series data\n",
42-
"da_ts = DataArray(\n",
43+
"da_ts = xr.DataArray(\n",
4344
" np.random.randn(30, 3).cumsum(axis=0),\n",
4445
" dims=[\"time\", \"category\"],\n",
4546
" coords={\n",
@@ -50,7 +51,7 @@
5051
")\n",
5152
"\n",
5253
"# 2D grid data\n",
53-
"da_2d = DataArray(\n",
54+
"da_2d = xr.DataArray(\n",
5455
" np.random.rand(20, 30),\n",
5556
" dims=[\"lat\", \"lon\"],\n",
5657
" coords={\n",
@@ -61,7 +62,7 @@
6162
")\n",
6263
"\n",
6364
"# Categorical data\n",
64-
"da_cat = DataArray(\n",
65+
"da_cat = xr.DataArray(\n",
6566
" np.random.rand(4, 3) * 100,\n",
6667
" dims=[\"product\", \"region\"],\n",
6768
" coords={\n",
@@ -160,7 +161,7 @@
160161
"outputs": [],
161162
"source": [
162163
"# Use absolute values for stacking to make sense\n",
163-
"da_positive = DataArray(\n",
164+
"da_positive = xr.DataArray(\n",
164165
" np.abs(np.random.randn(30, 3)) * 10,\n",
165166
" dims=[\"time\", \"source\"],\n",
166167
" coords={\n",
@@ -228,7 +229,7 @@
228229
"outputs": [],
229230
"source": [
230231
"# Create data with more samples\n",
231-
"da_dist = DataArray(\n",
232+
"da_dist = xr.DataArray(\n",
232233
" np.random.randn(100, 4) + np.array([0, 1, 2, 3]),\n",
233234
" dims=[\"sample\", \"group\"],\n",
234235
" coords={\"group\": [\"Control\", \"Treatment A\", \"Treatment B\", \"Treatment C\"]},\n",
@@ -294,7 +295,7 @@
294295
"outputs": [],
295296
"source": [
296297
"# 3D data for faceting\n",
297-
"da_3d = DataArray(\n",
298+
"da_3d = xr.DataArray(\n",
298299
" np.random.randn(30, 3, 2).cumsum(axis=0),\n",
299300
" dims=[\"time\", \"city\", \"scenario\"],\n",
300301
" coords={\n",
@@ -329,11 +330,11 @@
329330
"outputs": [],
330331
"source": [
331332
"# Create monthly data\n",
332-
"da_monthly = DataArray(\n",
333+
"da_monthly = xr.DataArray(\n",
333334
" np.random.rand(12, 4) * 100,\n",
334335
" dims=[\"month\", \"product\"],\n",
335336
" coords={\n",
336-
" \"month\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n",
337+
" \"month\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \n",
337338
" \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],\n",
338339
" \"product\": [\"A\", \"B\", \"C\", \"D\"],\n",
339340
" },\n",

docs/getting-started.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"source": [
3333
"## Basic Usage\n",
3434
"\n",
35-
"Import `DataArray` from xarray_plotly for IDE code completion:"
35+
"Import the package to register the `plotly` accessor:"
3636
]
3737
},
3838
{
@@ -45,7 +45,7 @@
4545
"import pandas as pd\n",
4646
"import xarray as xr\n",
4747
"\n",
48-
"import xarray_plotly"
48+
"import xarray_plotly # This registers the accessor"
4949
]
5050
},
5151
{
@@ -78,7 +78,7 @@
7878
" attrs={\"long_name\": \"Temperature Anomaly\", \"units\": \"°C\"},\n",
7979
")\n",
8080
"\n",
81-
"da.plotly."
81+
"da"
8282
]
8383
},
8484
{

xarray_plotly/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ from xarray_plotly.common import auto as auto
1010
__version__: str
1111

1212
# Augment xarray.DataArray with plotly accessor for IDE autocompletion
13-
class DataArray(_DataArray):
13+
class DataArray(_DataArray): # type: ignore[no-untyped-call]
1414
@property
1515
def plotly(self) -> DataArrayPlotlyAccessor: ...

0 commit comments

Comments
 (0)