You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update glue docs to mention NumPy 2.0 changes (#615)
Changes to the text/plain representation of NumPy objects for NumPy >= 2.0 mean that we need a workaround for formatting.
Co-authored-by: Brigitta Sipőcz <bsipocz@gmail.com>
Copy file name to clipboardExpand all lines: docs/render/glue.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ To glue keys from other notebooks, see {ref}`glue/crossdoc`.
25
25
## Save variables in code cells
26
26
27
27
You can use `myst_nb.glue()` to assign the output of a variable to a key of your choice.
28
-
`glue` will store all of the information that is normally used to display that variable (ie, whatever happens when you display the variable by putting it at the end of a cell).
28
+
`glue` will store all of the information that is normally used to display that variable (that is, whatever happens when you display the variable by putting it at the end of a cell).
29
29
Choose a key that you will remember, as you will use it later.
30
30
31
31
The following code glues a variable inside the notebook:
@@ -137,12 +137,12 @@ These variables can be pasted using one of the roles or directives in the `glue:
137
137
138
138
### The `glue` role/directive
139
139
140
-
The simplest role and directive are `glue` (a.k.a.`glue:any`),
140
+
The simplest role and directive are `glue` (also known as`glue:any`),
141
141
which paste the glued output inline or as a block respectively,
142
142
with no additional formatting.
143
143
Simply add:
144
144
145
-
````
145
+
````md
146
146
```{glue} your-key
147
147
```
148
148
````
@@ -219,6 +219,27 @@ For example, the following: ``My rounded mean: {glue:text}`boot_mean:.2f` `` wil
219
219
220
220
My rounded mean: {glue:text}`boot_mean:.2f` (95% CI: {glue:text}`boot_clo:.2f`/{glue:text}`boot_chi:.2f`).
221
221
222
+
````{warning}
223
+
As of NumPy 2.0, the `text/plain` representation of [NumPy objects has changed](https://numpy.org/devdocs/release/2.0.0-notes.html#representation-of-numpy-scalars-changed).
224
+
Using text formatting with NumPy>=2.0 will give warnings like:
225
+
226
+
```
227
+
sphinx.errors.SphinxWarning: <filename>:257:Failed to format text/plain data: could not convert string to float: 'np.float64(0.9643970836113095)' [mystnb.glue]
228
+
```
229
+
230
+
This can be resolved by either formatting the number before glueing or by setting NumPy to use legacy print options, as shown below.
0 commit comments