Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 5, 2023
1 parent 1e961b8 commit c70431a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions doc/how_to/apis/callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ color = pn.widgets.ColorPicker(name='Color', value='#880588')
layout = pn.Row(
pn.Column('## MPG Explorer', x, y, color),
autompg_plot(x.value, y.value, color.value))
autompg.hvplot.scatter(x.value, y.value, c=color.value, padding=0.1)
)
def update(event):
layout[1].object = autompg_plot(x.value, y.value, color.value)
layout[1].object = autompg.hvplot.scatter(x.value, y.value, c=color.value, padding=0.1)
x.param.watch(update, 'value')
y.param.watch(update, 'value')
Expand Down
2 changes: 1 addition & 1 deletion doc/how_to/caching/memoization.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ select = pn.widgets.Select(options={
'Penguins': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv',
'Diamonds': 'https://raw.githucbusercontent.com/mwaskom/seaborn-data/master/diamonds.csv',
'Titanic': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv',
'MPG': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/mpg.csv'
'MPG': 'https://raw.githubusercontent.com/mwaskom/seaborn-data/mastser/mpg.csv'
})
@pn.cache
Expand Down
2 changes: 1 addition & 1 deletion doc/how_to/concurrency/manual_threading.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def callback():
c.acquire()
for i, event in enumerate(queue):
text.value = f'Processing item {i+1} of {len(queue)} items in queue.'
... # Do something with the event
... # Do something with the event
time.sleep(2)
queue.clear()
text.value = "Queue empty"
Expand Down
8 changes: 6 additions & 2 deletions doc/how_to/export/bokeh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

Since Panel is built on top of Bokeh, all Panel objects can easily be converted to a Bokeh model. The ``get_root`` method returns a model representing the contents of a Panel:

```python
```{pyodide}
import panel as pn
model = pn.Column('# Some markdown').get_root()
model
```

By default this model will be associated with Bokeh's ``curdoc()``, so if you want to associate the model with some other ``Document`` ensure you supply it explictly as the first argument. Once you have access to the underlying bokeh model you can use all the usual bokeh utilities such as ``components``, ``file_html``, or ``show``

```python
```{pyodide}
from bokeh.embed import components, file_html
from bokeh.io import show
script, html = components(model)
print(html)
```
2 changes: 1 addition & 1 deletion doc/how_to/param/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ However it is also possible to explicitly construct a widget from a parameter us


```{pyodide}
pn.widgets.IntSlider.from_param(Example.param.unbounded_int, start=0, end=100)
pn.widgets.RadioBoxGroup.from_param(CustomExample.param.select_string, inline=True)
```

## Custom name
Expand Down
3 changes: 2 additions & 1 deletion doc/how_to/param/subobjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
``Parameterized`` objects often have parameter values which are themselves ``Parameterized`` objects, forming a tree-like structure. Panel allows you to edit not just the main object's parameters but also lets you drill down to the subobject. Let us first define some classes declaring a hierarchy of Shape classes which draw a Bokeh plot of the selected shape:

```{pyodide}
import panel
import numpy as np
import panel as pn
import param
from bokeh.plotting import figure
Expand Down
6 changes: 3 additions & 3 deletions doc/how_to/state/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ By default the current [query parameters](https://en.wikipedia.org/wiki/Query_st

We will start by defining a `Parameterized` class:

```{pyodide}
```python
import param
import panel as pn

Expand All @@ -42,13 +42,13 @@ class QueryExample(param.Parameterized):

Now we will use the `pn.state.location` object to sync it with the URL query string (note that in a notebook environment `pn.state.location` is not initialized until the first plot has been displayed). The sync method takes the Parameterized object or instance to sync with as the first argument and a list or dictionary of the parameters as the second argument. If a dictionary is provided it should map from the Parameterized object's parameters to the query parameter name in the URL:

```{pyodide}
```python
pn.state.location.sync(QueryExample, {'integer': 'int', 'string': 'str'})
```

Now the Parameterized object is bi-directionally linked to the URL query parameter, if we set a query parameter in Python it will update the URL bar and when we specify a URL with a query parameter that will be set on the Parameterized, e.g. let us set the 'integer' parameter and watch the URL in your browser update:

```{pyodide}
```python
QueryExample.integer = 5
```

Expand Down
4 changes: 2 additions & 2 deletions panel/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def is_panel_pane(attr):
def test_markdown_codeblocks(file, tmp_path):
from markdown_it import MarkdownIt

exceptions = ("await", "pn.serve", "django")
exceptions = ("await", "pn.serve", "django", "raise", "display(")

md_ast = MarkdownIt().parse(file.read_text(encoding="utf-8"))
lines = ""
for n in md_ast:
if n.tag == "code" and n.info is not None:
if "pyodide" in n.info.lower() or "python" in n.info.lower():
if "pyodide" in n.info.lower():
if ">>>" not in n.content:
lines += n.content
if not lines:
Expand Down

0 comments on commit c70431a

Please sign in to comment.