This patch makes the following fixes:
- Make summary text appear on the same line as the ">" arrow marker;
prior to this patch, it was being pushed down to the next line because
there were nested block elements inside the <summary> element
- Style details element to visually delineate collapsible content with
dashed lines above and below the content
- Add syntax highlighting for code blocks in details disclosure elements
(some were missing syntax highlighting)
- Hide a cell that was meant to be hidden in the audio tutorial
The summary element looked ugly due to a block element being present
inside the <summary>. This was present in the rendered docs even though
it was not explicitly in the source. Even though our source (in a
Markdown cell in a Jupyter notebook) looked like:
<summary>Example text</summary>
The rendered docs had:
<summary><p>Example text</p></summary>
The easy fix was to leave this as-is and fix the styling with CSS,
making all elements inside the summary to be displayed as inline
elements.
Where was the extra <p> tag coming from? Different Markdown parsers
handle mixed Markdown/HTML differently. We are using nbsphinx, which
does something especially weird [1]: converting from Markdown ->
reStructuredText -> HTML.
For example, consider the following Markdown:
<details><summary>Summary</summary>
Body.
</details>
nbsphinx was first converting it to this reST:
.. raw:: html
<details>
.. raw:: html
<summary>
Summary
.. raw:: html
</summary>
Body.
.. raw:: html
</details>
And then this reST was being converted to HTML. This is where the extra
<p> was coming from.
One workaround for this behavior is to switch to raw HTML cells in the
notebook, rather than Markdown cells, and write pure HTML there. This
has the disadvantage that it's inconvenient when the content inside the
<details> has extra markup: Markdown is very convenient for that (e.g.,
for styling text), and having the contents being parsed as Markdown also
allows us to easily use syntax highlighting inside the body.
Another workaround is to use raw reST cells [2] and write the proper
reST directly (avoiding the bad Markdown -> reST conversion). This
preserves the ability to use convenient formatting (though with reST
instead of Markdown) as well as syntax-highlighted code blocks. For
example:
.. raw:: html
<details><summary>Summary</summary>
.. code-block:: python
def meaning_of_life():
return 42
.. raw:: html
</details>
The above snippet produces the expected HTML, with syntax-highlighted
code in the body, and without the extra <p> inside the <summary>.
Rather than either of these workarounds, the most convenient one for
developers is to fix the issue using CSS, so that the Markdown cells in
the tutorials can be left as-is and no special care is required when
writing details disclosure elements, which is what this patch does.
[1]: https://github.com/spatialaudio/nbsphinx/blob/fc79fd1ac5ab6df225b256ef4ca203c58c5ad92b/src/nbsphinx.py#L1309
[2]: https://nbsphinx.readthedocs.io/en/0.8.9/raw-cells.html#reST
* remove ineffective TF suppression lines
* suppress tensorflow logs in workflows tutorial
* formatting
* hidden cell comment
* move suppress code to hidden cell
* move suppression code to first hidden cell
* move suppression code to first cell
* supress tf logs in tabular tutorial
* optional code to hidden cells in audio tutorial
* suppress tf logs in multiannotator tutorial
* suppress tf logs in token tutorial
* move cross-val tutorial to appear last
* move cross-val tutorial to be last in main index
* move outlier before multiannotator in API list
* remove newline at end of cell
* docstring formatting
* add tiebreak info
* add example link to tutorial
* add missing backticks
* minor docstring text edits
* clarify "task"
Co-authored-by: Jonas Mueller <1390638+jwmueller@users.noreply.github.com>
* Added base structure outline for get_ood_scores()
Added base test for get_ood_scores()
* Added warning for illogical param combo
* Addressed PR comments
* Added better unit tests
* TODO: test for correctly identifying OOD example
* Moved logic from get_ood_scores to _subtract_confident_thresholds
* TODO: Is this a cleaner way of doing this? Minimal code repeat but strange change to _subtract function
* Addressed type issue
* Switched logic for getting confident thresholds
* Fixing typecheck issues wiht labels parameter being None
* Simplified helper function. Testing type
* Fixed mypy static typing issue
* Mypy typecheck logic test
* removed uncessesary imports in util file
* typechecker debugging (add assert)
* Fixed type logic and removed confident_thresholds=None return
* Added extra arg in helper func to end of func
* Added zero-index checking for label param
* Added ood examples to outlier score notebook
* Added skeleton file structure for implementing outliers
* Make adjust_pred_probs=True by default not false
* Added base Outlier class functionality
TODO:
* test_outlier.py
* Added logic tests for function
* Updated get_ood_scores to always return confident_thresholds
* Even if none were calculated (then return is None)
* Added warning for fit that doesn't calculate confident_thresholds
* Moved get_outlier_scores and get_ood_scores to outlier.py
* Changed param dicts to dicts
* Added docstring to outlier.py
* Added proper return types
* Fixed mypy typing issues
* Switched outliers -> features; ood -> predictions naming conv
* Switched docstring to stem from fit and score functions
* Changed return of helper functions
* Fixed tutorials notebook to use OutOfDistribution class
* Moved imports to top of file
* Added option for different knn objects, addressed pr comments
* Switched params arg to init only
* Addressed PR comment for notebook, cleared notebook
* Fixed PR comments, wording.
* Testing relative links on build
* Changed ood_pred_probs scores to reflect 0 = most ood 1 = least
* Added MLP for detection outliers with pred_probs
* Fixed typos
* Added MLP Import
* Improved warning when fit call unnecessary
* Changed referenced to params dict in warnings/errors
* Added bagging+MLP classifier into notebook
* Reverted tutorial wording
* OOD tutorial improvements
* cleanup OOD documentation
* adopting->using
Co-authored-by: Jonas Mueller <1390638+jwmueller@users.noreply.github.com>