Skip to content

Commit ff6592e

Browse files
committed
Fix code block syntax
1 parent 83d151f commit ff6592e

File tree

2 files changed

+79
-80
lines changed

2 files changed

+79
-80
lines changed

src/ess/dream/data.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@ def simulated_diamond_sample(*, small: bool = False) -> str:
9797
If True, return a smaller version of the data file, with randomly selected rows.
9898
The small version of the file was created using the following code:
9999
100-
```python
101-
import numpy as np
102-
import pandas as pd
100+
.. code-block:: python
103101
104-
fname = dream.data.simulated_diamond_sample()
105-
df = pd.read_csv(fname, sep='\t')
106-
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
107-
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
108-
```
102+
import numpy as np
103+
import pandas as pd
109104
105+
fname = dream.data.simulated_diamond_sample()
106+
df = pd.read_csv(fname, sep='\t')
107+
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
108+
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
110109
"""
111110
prefix = "TEST_" if small else ""
112111
return get_path(
@@ -141,15 +140,15 @@ def simulated_vanadium_sample(*, small: bool = False) -> str:
141140
If True, return a smaller version of the data file, with randomly selected rows.
142141
The small version of the file was created using the following code:
143142
144-
```python
145-
import numpy as np
146-
import pandas as pd
143+
.. code-block:: python
147144
148-
fname = dream.data.simulated_vanadium_sample()
149-
df = pd.read_csv(fname, sep='\t')
150-
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
151-
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
152-
```
145+
import numpy as np
146+
import pandas as pd
147+
148+
fname = dream.data.simulated_vanadium_sample()
149+
df = pd.read_csv(fname, sep='\t')
150+
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
151+
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
153152
"""
154153
prefix = "TEST_" if small else ""
155154
return get_path(
@@ -177,15 +176,15 @@ def simulated_vanadium_sample_incoherent(*, small: bool = False) -> str:
177176
If True, return a smaller version of the data file, with randomly selected rows.
178177
The small version of the file was created using the following code:
179178
180-
```python
181-
import numpy as np
182-
import pandas as pd
179+
.. code-block:: python
180+
181+
import numpy as np
182+
import pandas as pd
183183
184-
fname = dream.data.simulated_vanadium_sample_incoherent()
185-
df = pd.read_csv(fname, sep='\t')
186-
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
187-
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
188-
```
184+
fname = dream.data.simulated_vanadium_sample_incoherent()
185+
df = pd.read_csv(fname, sep='\t')
186+
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
187+
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
189188
"""
190189
prefix = "TEST_" if small else ""
191190
return get_path(f"DREAM_simple_pwd_workflow/{prefix}data_dream_vanadium.csv.zip")
@@ -215,15 +214,15 @@ def simulated_empty_can(*, small: bool = False) -> str:
215214
If True, return a smaller version of the data file, with randomly selected rows.
216215
The small version of the file was created using the following code:
217216
218-
```python
219-
import numpy as np
220-
import pandas as pd
217+
.. code-block:: python
218+
219+
import numpy as np
220+
import pandas as pd
221221
222-
fname = dream.data.simulated_empty_can()
223-
df = pd.read_csv(fname, sep='\t')
224-
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
225-
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
226-
```
222+
fname = dream.data.simulated_empty_can()
223+
df = pd.read_csv(fname, sep='\t')
224+
inds = np.sort(np.random.choice(len(df), 10_000, replace=False))
225+
df.iloc[inds].to_csv('TEST_' + fname.split('/')[-1], sep='\t', index=False)
227226
"""
228227
prefix = "TEST_" if small else ""
229228
return get_path(

src/ess/snspowder/powgen/data.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ def powgen_tutorial_sample_file(*, small: bool = False) -> str:
9393
The small version of the file was created using the following code, which keeps
9494
only 7 columns out of 154 (154 / 7 = 22):
9595
96-
```python
97-
import scipp as sc
98-
99-
fname = 'PG3_4844_event.h5'
100-
dg = sc.io.load_hdf5(fname)
101-
102-
sizes = {"bank": 23, "column": 154, "row": 7}
103-
104-
def foldme(x, dim):
105-
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
106-
dims=list(sizes.keys()), to=dim)
107-
108-
small = sc.DataGroup({
109-
'data': foldme(dg['data'], 'spectrum'),
110-
'detector_info': sc.Dataset(
111-
coords={key: foldme(c, 'detector')
112-
for key, c in dg['detector_info'].coords.items()})
113-
})
114-
sc.io.save_hdf5(small, 'TEST_PG3_4844_event.h5')
115-
```
96+
.. code-block:: python
97+
98+
import scipp as sc
99+
100+
fname = 'PG3_4844_event.h5'
101+
dg = sc.io.load_hdf5(fname)
102+
103+
sizes = {"bank": 23, "column": 154, "row": 7}
104+
105+
def foldme(x, dim):
106+
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
107+
dims=list(sizes.keys()), to=dim)
108+
109+
small = sc.DataGroup({
110+
'data': foldme(dg['data'], 'spectrum'),
111+
'detector_info': sc.Dataset(
112+
coords={key: foldme(c, 'detector')
113+
for key, c in dg['detector_info'].coords.items()})
114+
})
115+
sc.io.save_hdf5(small, 'TEST_PG3_4844_event.h5')
116116
"""
117117
prefix = "TEST_" if small else ""
118118
ext = ".h5" if small else ".zip"
@@ -130,24 +130,24 @@ def powgen_tutorial_vanadium_file(*, small: bool = False) -> str:
130130
The small version of the file was created using the following code, which keeps
131131
only 7 columns out of 154 (154 / 7 = 22):
132132
133-
```python
134-
import scipp as sc
133+
.. code-block:: python
134+
135+
import scipp as sc
135136
136-
fname = 'PG3_4866_event.h5'
137-
dg = sc.io.load_hdf5(fname)
137+
fname = 'PG3_4866_event.h5'
138+
dg = sc.io.load_hdf5(fname)
138139
139-
sizes = {"bank": 23, "column": 154, "row": 7}
140+
sizes = {"bank": 23, "column": 154, "row": 7}
140141
141-
def foldme(x, dim):
142-
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
143-
dims=list(sizes.keys()), to=dim)
142+
def foldme(x, dim):
143+
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
144+
dims=list(sizes.keys()), to=dim)
144145
145-
small = sc.DataGroup({
146-
'data': foldme(dg['data'], 'spectrum'),
147-
'proton_charge': dg['proton_charge']['pulse_time', ::10]
148-
})
149-
sc.io.save_hdf5(small, 'TEST_PG3_4866_event.h5')
150-
```
146+
small = sc.DataGroup({
147+
'data': foldme(dg['data'], 'spectrum'),
148+
'proton_charge': dg['proton_charge']['pulse_time', ::10]
149+
})
150+
sc.io.save_hdf5(small, 'TEST_PG3_4866_event.h5')
151151
"""
152152
prefix = "TEST_" if small else ""
153153
ext = ".h5" if small else ".zip"
@@ -165,24 +165,24 @@ def powgen_tutorial_calibration_file(*, small: bool = False) -> str:
165165
The small version of the file was created using the following code, which keeps
166166
only 7 columns out of 154 (154 / 7 = 22):
167167
168-
```python
169-
import scipp as sc
168+
.. code-block:: python
169+
170+
import scipp as sc
170171
171-
fname = 'PG3_FERNS_d4832_2011_08_24_spectrum.h5'
172-
dg = sc.io.load_hdf5(fname)
172+
fname = 'PG3_FERNS_d4832_2011_08_24_spectrum.h5'
173+
dg = sc.io.load_hdf5(fname)
173174
174-
sizes = {"bank": 23, "column": 154, "row": 7}
175+
sizes = {"bank": 23, "column": 154, "row": 7}
175176
176-
def foldme(x, dim):
177-
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
178-
dims=list(sizes.keys()), to=dim)
177+
def foldme(x, dim):
178+
return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
179+
dims=list(sizes.keys()), to=dim)
179180
180-
small = sc.Dataset(
181-
data={k: foldme(a, 'spectrum') for k, a in ds.items()},
182-
coords={k: foldme(c, 'spectrum') for k, c in ds.coords.items()}
183-
)
184-
sc.io.save_hdf5(small, 'TEST_PG3_FERNS_d4832_2011_08_24_spectrum.h5')
185-
```
181+
small = sc.Dataset(
182+
data={k: foldme(a, 'spectrum') for k, a in ds.items()},
183+
coords={k: foldme(c, 'spectrum') for k, c in ds.coords.items()}
184+
)
185+
sc.io.save_hdf5(small, 'TEST_PG3_FERNS_d4832_2011_08_24_spectrum.h5')
186186
"""
187187
prefix = "TEST_" if small else ""
188188
return _get_path(f"{prefix}PG3_FERNS_d4832_2011_08_24_spectrum.h5")

0 commit comments

Comments
 (0)