Skip to content

Commit f281893

Browse files
authored
Merge pull request #161 from scipp/deprecation_warnings
Remove deprecation warnings from docs notebooks
2 parents 3110bdb + 933af60 commit f281893

File tree

11 files changed

+46
-43
lines changed

11 files changed

+46
-43
lines changed

docs/buildconfig/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
plot:
2+
use_plopp: true

docs/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import doctest
55
import os
6+
import pathlib
67
import sys
78
from datetime import date
89
from typing import Any, Dict, Optional
@@ -264,3 +265,7 @@ def add_buttons(
264265
# Specific lines in Github blobs cannot be found by linkcheck.
265266
r'https?://github\.com/.*?/blob/[a-f0-9]+/.+?#',
266267
]
268+
269+
# Set env variable to enable plopp
270+
docs_dir = pathlib.Path(__file__).parent.absolute()
271+
os.environ["SCIPPDIR"] = os.path.join(docs_dir, 'buildconfig')

docs/instruments/external/powgen/powgen_reduction.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"%matplotlib widget\n",
3333
"import scipp as sc\n",
3434
"import scippneutron as scn\n",
35+
"import plopp as pp\n",
3536
"\n",
3637
"import ess\n",
3738
"from ess.diffraction.external import load_calibration\n",
@@ -131,7 +132,7 @@
131132
},
132133
"outputs": [],
133134
"source": [
134-
"sample.plot()"
135+
"sample.hist(spectrum=500, tof=400).plot()"
135136
]
136137
},
137138
{
@@ -151,7 +152,7 @@
151152
},
152153
"outputs": [],
153154
"source": [
154-
"powgen.instrument_view(sample)"
155+
"scn.instrument_view(sample.hist())"
155156
]
156157
},
157158
{
@@ -486,7 +487,7 @@
486487
},
487488
"outputs": [],
488489
"source": [
489-
"sc.histogram(all_spectra, bins=dspacing_edges).plot()"
490+
"all_spectra.hist(dspacing=dspacing_edges).plot()"
490491
]
491492
},
492493
{
@@ -557,7 +558,7 @@
557558
},
558559
"outputs": [],
559560
"source": [
560-
"normalized = sc.histogram(normalized, bins=dspacing_edges)"
561+
"normalized = normalized.hist(dspacing=dspacing_edges)"
561562
]
562563
},
563564
{
@@ -623,7 +624,7 @@
623624
},
624625
"outputs": [],
625626
"source": [
626-
"normalized.plot(projection='1d')"
627+
"pp.superplot(normalized)"
627628
]
628629
}
629630
],

docs/instruments/loki/sans2d_reduction.ipynb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"import scipp as sc\n",
3636
"from ess import loki, sans\n",
3737
"from ess.logging import configure_workflow\n",
38-
"import scippneutron as scn"
38+
"import scippneutron as scn\n",
39+
"import plopp as pp"
3940
]
4041
},
4142
{
@@ -233,7 +234,7 @@
233234
"metadata": {},
234235
"outputs": [],
235236
"source": [
236-
"scn.instrument_view(ds['sample'], pixel_size=0.0075)"
237+
"scn.instrument_view(ds['sample'].hist(), pixel_size=0.0075)"
237238
]
238239
},
239240
{
@@ -327,7 +328,7 @@
327328
" q_bins=q_bins,\n",
328329
" gravity=gravity,\n",
329330
" monitor_non_background_range=monitor_non_background_range)\n",
330-
"sample_q.plot()"
331+
"sample_q.hist().plot()"
331332
]
332333
},
333334
{
@@ -345,7 +346,7 @@
345346
" q_bins=q_bins,\n",
346347
" gravity=gravity,\n",
347348
" monitor_non_background_range=monitor_non_background_range)\n",
348-
"background_q.plot()"
349+
"background_q.hist().plot()"
349350
]
350351
},
351352
{
@@ -376,8 +377,7 @@
376377
"source": [
377378
"fig1, ax1 = plt.subplots(1, 2, figsize=(10, 4))\n",
378379
"sc.plot(result, ax=ax1[0])\n",
379-
"sc.plot(result, norm='log', ax=ax1[1])\n",
380-
"fig1"
380+
"sc.plot(result, norm='log', ax=ax1[1])"
381381
]
382382
},
383383
{
@@ -456,8 +456,7 @@
456456
"\n",
457457
"fig2, ax2 = plt.subplots(1, 2, figsize=(10, 4))\n",
458458
"sc.plot(collapsed, ax=ax2[0])\n",
459-
"sc.plot(collapsed, norm='log', legend=False, ax=ax2[1])\n",
460-
"fig2"
459+
"sc.plot(collapsed, norm='log', ax=ax2[1])"
461460
]
462461
},
463462
{

docs/instruments/loki/sans2d_to_I_of_Q.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
"metadata": {},
259259
"outputs": [],
260260
"source": [
261-
"scn.instrument_view(sample, pixel_size=0.0075)"
261+
"scn.instrument_view(sample.hist(), pixel_size=0.0075)"
262262
]
263263
},
264264
{
@@ -301,7 +301,7 @@
301301
"metadata": {},
302302
"outputs": [],
303303
"source": [
304-
"sc.plot(sample)"
304+
"sc.plot(sample.hist(tof=200).sum('spectrum'))"
305305
]
306306
},
307307
{
@@ -428,9 +428,9 @@
428428
"metadata": {},
429429
"outputs": [],
430430
"source": [
431-
"p = sc.plot(monitors['sample'], norm='log')\n",
432-
"sc.plot(monitors['direct'], norm='log', ax=p.ax, color=['C2', 'C3'])\n",
433-
"p"
431+
"sc.plot({**{f'sample-{key}': val for key, val in monitors['sample'].items()},\n",
432+
" **{f'direct-{key}': val for key, val in monitors['direct'].items()}}\n",
433+
" , norm='log')"
434434
]
435435
},
436436
{
@@ -646,7 +646,7 @@
646646
"metadata": {},
647647
"outputs": [],
648648
"source": [
649-
"sc.plot(sample_q, norm='log')"
649+
"sc.plot(sample_q.hist(), norm='log')"
650650
]
651651
},
652652
{
@@ -706,7 +706,7 @@
706706
"metadata": {},
707707
"outputs": [],
708708
"source": [
709-
"sc.plot(sample_normalized)"
709+
"sc.plot(sample_normalized.hist())"
710710
]
711711
},
712712
{

docs/techniques/wfm/introduction-to-wfm.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@
10561056
"metadata": {},
10571057
"outputs": [],
10581058
"source": [
1059-
"del ax6.texts[3:]\n",
1059+
"for t in ax6.texts[3:]:\n",
1060+
" t.remove()\n",
10601061
"ax6.set_xlim(-1.0e3, 2.0e4)\n",
10611062
"ax6.set_ylim(-1.5, 10.0)\n",
10621063
"fig6.canvas.draw_idle()\n",
@@ -1100,9 +1101,10 @@
11001101
" ax7.plot([(coords['source_pulse_t_0'] + (0.5 * coords['source_pulse_length'])).value,\n",
11011102
" arrival_times['wavelength', i].value],\n",
11021103
" [0.0, sc.norm(coords['position']).value], color='r')\n",
1103-
"del ax7.texts[3:]\n",
11041104
"ax7.set_xlim(-1.0e3, 2.0e4)\n",
1105-
"ax7.set_ylim(-1.5, 10.0)"
1105+
"ax7.set_ylim(-1.5, 10.0)\n",
1106+
"for t in ax7.texts[3:]:\n",
1107+
" t.remove()"
11061108
]
11071109
},
11081110
{

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies:
2424
- pytest=7.2.1
2525
- python-graphviz=0.20.1
2626
- pythreejs=2.4.1
27+
- scipp==22.11.0
2728
- scippneutron==22.12.4
2829
- sphinx=4.5.0
2930
- sphinx-book-theme=0.3.3

src/ess/diffraction/corrections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def normalize_by_vanadium(data: sc.DataArray, *, vanadium: sc.DataArray,
7878
:
7979
`data` normalized by `vanadium`.
8080
"""
81-
norm = sc.lookup(sc.histogram(vanadium, bins=edges), dim=edges.dim)
81+
norm = sc.lookup(vanadium.hist({edges.dim: edges}), dim=edges.dim)
8282
# Converting to unit 'one' because the division might produce a unit
8383
# with a large scale if the proton charges in data and vanadium were
8484
# measured with different units.

src/ess/diffraction/grouping.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
from scippneutron.conversion.graph import beamline
55

66

7-
def group_by_two_theta(data: sc.DataArray,
8-
*,
9-
edges: sc.Variable,
10-
replace_dim: str = 'spectrum') -> sc.DataArray:
7+
def group_by_two_theta(data: sc.DataArray, *, edges: sc.Variable) -> sc.DataArray:
118
"""
129
Group data into two_theta bins.
1310
@@ -18,17 +15,11 @@ def group_by_two_theta(data: sc.DataArray,
1815
or coords or attrs that can be used to compute it.
1916
edges:
2017
Bin edges in two_theta. `data` is grouped into those bins.
21-
replace_dim:
22-
Dimension that is replaced by two_theta.
23-
All events are concatenated along this dimension.
2418
2519
Returns
2620
-------
2721
:
2822
`data` grouped into two_theta bins.
2923
"""
30-
data = data.transform_coords('two_theta', graph=beamline.beamline(scatter=True))
31-
return sc.groupby(data,
32-
'two_theta',
33-
bins=edges.to(unit=data.coords['two_theta'].unit,
34-
copy=False)).bins.concat(replace_dim)
24+
out = data.transform_coords('two_theta', graph=beamline.beamline(scatter=True))
25+
return out.bin(two_theta=edges.to(unit=out.coords['two_theta'].unit, copy=False))

src/ess/external/powgen/instrument_view.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ def instrument_view(da: sc.DataArray,
2828
kwargs:
2929
See :func:`scippneutron.instrument_view`
3030
"""
31-
if 'camera' not in kwargs:
32-
kwargs = {
33-
**kwargs, 'camera': {
34-
'position': sc.vector(value=[-3, 3, 3], unit=da.coords[positions].unit)
35-
}
36-
}
31+
# TODO: the camera argument does not work with the Plopp instrument view
32+
# if 'camera' not in kwargs:
33+
# kwargs = {
34+
# **kwargs, 'camera': {
35+
# 'position': sc.vector(value=[-3, 3, 3],
36+
# unit=da.coords[positions].unit)
37+
# }
38+
# }
3739
return scn.instrument_view(da,
3840
positions=positions,
3941
components=components,

src/ess/sans/i_of_q.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _convert_dense_to_q_and_merge_spectra(
169169
data_q.coords['wavelength'] = data_q.attrs.pop('wavelength')
170170
for i in range(wavelength_bands.sizes['wavelength'] - 1):
171171
band = data_q['wavelength', wavelength_bands[i]:wavelength_bands[i + 1]]
172-
bands.append(sc.histogram(band, bins=q_bins).sum('spectrum'))
172+
bands.append(band.hist({q_bins.dim: q_bins}).sum('spectrum'))
173173
q_summed = sc.concat(bands, 'wavelength')
174174
return q_summed
175175

0 commit comments

Comments
 (0)