diff --git a/docs/_modules/index.html b/docs/_modules/index.html index f5f5d05c..771642af 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -1,18 +1,15 @@ - - Overview: module code — monty 2023.4.10 documentation + Overview: module code — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/bisect.html b/docs/_modules/monty/bisect.html index d0f40b96..b133c0ed 100644 --- a/docs/_modules/monty/bisect.html +++ b/docs/_modules/monty/bisect.html @@ -1,18 +1,15 @@ - - monty.bisect — monty 2023.4.10 documentation + monty.bisect — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/collections.html b/docs/_modules/monty/collections.html index 740f81b1..f7bd43f2 100644 --- a/docs/_modules/monty/collections.html +++ b/docs/_modules/monty/collections.html @@ -1,18 +1,15 @@ - - monty.collections — monty 2023.4.10 documentation + monty.collections — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/design_patterns.html b/docs/_modules/monty/design_patterns.html index 99ec61be..6c97f8d1 100644 --- a/docs/_modules/monty/design_patterns.html +++ b/docs/_modules/monty/design_patterns.html @@ -1,18 +1,15 @@ - - monty.design_patterns — monty 2023.4.10 documentation + monty.design_patterns — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/dev.html b/docs/_modules/monty/dev.html index c242661e..340982dd 100644 --- a/docs/_modules/monty/dev.html +++ b/docs/_modules/monty/dev.html @@ -1,18 +1,15 @@ - - monty.dev — monty 2023.4.10 documentation + monty.dev — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/fnmatch.html b/docs/_modules/monty/fnmatch.html index 96a05eeb..f442f6a8 100644 --- a/docs/_modules/monty/fnmatch.html +++ b/docs/_modules/monty/fnmatch.html @@ -1,18 +1,15 @@ - - monty.fnmatch — monty 2023.4.10 documentation + monty.fnmatch — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/fractions.html b/docs/_modules/monty/fractions.html index c8589119..efe5344b 100644 --- a/docs/_modules/monty/fractions.html +++ b/docs/_modules/monty/fractions.html @@ -1,18 +1,15 @@ - - monty.fractions — monty 2023.4.10 documentation + monty.fractions — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/functools.html b/docs/_modules/monty/functools.html index dde572f4..0d6faf4f 100644 --- a/docs/_modules/monty/functools.html +++ b/docs/_modules/monty/functools.html @@ -1,18 +1,15 @@ - - monty.functools — monty 2023.4.10 documentation + monty.functools — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/inspect.html b/docs/_modules/monty/inspect.html index abdd8982..9aa0481f 100644 --- a/docs/_modules/monty/inspect.html +++ b/docs/_modules/monty/inspect.html @@ -1,18 +1,15 @@ - - monty.inspect — monty 2023.4.10 documentation + monty.inspect — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/io.html b/docs/_modules/monty/io.html index 6591ba1c..70ebc115 100644 --- a/docs/_modules/monty/io.html +++ b/docs/_modules/monty/io.html @@ -1,18 +1,15 @@ - - monty.io — monty 2023.4.10 documentation + monty.io — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/itertools.html b/docs/_modules/monty/itertools.html index 717af42e..c1e45b33 100644 --- a/docs/_modules/monty/itertools.html +++ b/docs/_modules/monty/itertools.html @@ -1,18 +1,15 @@ - - monty.itertools — monty 2023.4.10 documentation + monty.itertools — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/json.html b/docs/_modules/monty/json.html index 6c3c0251..466bdb64 100644 --- a/docs/_modules/monty/json.html +++ b/docs/_modules/monty/json.html @@ -1,18 +1,15 @@ - - monty.json — monty 2023.4.10 documentation + monty.json — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + @@ -95,6 +92,10 @@

    Source code for monty.json

     except ImportError:
         dataclasses = None  # type: ignore
     
    +try:
    +    import torch
    +except ImportError:
    +    torch = None  # type: ignore
     
     __version__ = "3.0.0"
     
    @@ -332,6 +333,15 @@ 

    Source code for monty.json

             if isinstance(o, UUID):
                 return {"@module": "uuid", "@class": "UUID", "string": str(o)}
     
    +        if isinstance(o, torch.Tensor):
    +            # Support for Pytorch Tensors.
    +            return {
    +                        "@module": "torch",
    +                        "@class": "Tensor",
    +                        "dtype": str(o.dtype),
    +                        "data": o.cpu().detach().numpy().tolist(),
    +                    }
    +
             if np is not None:
                 if isinstance(o, np.ndarray):
                     if str(o.dtype).startswith("complex"):
    @@ -453,7 +463,7 @@ 

    Source code for monty.json

                     classname = None
     
                 if classname:
    -                if modname and modname not in ["bson.objectid", "numpy", "pandas"]:
    +                if modname and modname not in ["bson.objectid", "numpy", "pandas", "torch"]:
                         if modname == "datetime" and classname == "datetime":
                             try:
                                 dt = datetime.datetime.strptime(d["string"], "%Y-%m-%d %H:%M:%S.%f")
    @@ -479,6 +489,8 @@ 

    Source code for monty.json

                             ):
                                 d = {k: self.process_decoded(v) for k, v in data.items()}
                                 return cls_(**d)
    +                elif torch is not None and modname == "torch" and classname == "Tensor":
    +                    return torch.tensor(d["data"])
                     elif np is not None and modname == "numpy" and classname == "array":
                         if d["dtype"].startswith("complex"):
                             return np.array(
    diff --git a/docs/_modules/monty/logging.html b/docs/_modules/monty/logging.html
    index 9da17541..5f2f46d0 100644
    --- a/docs/_modules/monty/logging.html
    +++ b/docs/_modules/monty/logging.html
    @@ -1,18 +1,15 @@
    -
     
     
     
       
         
         
    -    monty.logging — monty 2023.4.10 documentation
    +    monty.logging — monty 2023.5.7 documentation
         
         
         
    -    
    -    
    -    
         
    +    
         
         
     
    @@ -32,7 +29,7 @@ 

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/math.html b/docs/_modules/monty/math.html index 44a907a0..f7892303 100644 --- a/docs/_modules/monty/math.html +++ b/docs/_modules/monty/math.html @@ -1,18 +1,15 @@ - - monty.math — monty 2023.4.10 documentation + monty.math — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/msgpack.html b/docs/_modules/monty/msgpack.html index 41737646..46388139 100644 --- a/docs/_modules/monty/msgpack.html +++ b/docs/_modules/monty/msgpack.html @@ -1,18 +1,15 @@ - - monty.msgpack — monty 2023.4.10 documentation + monty.msgpack — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/multiprocessing.html b/docs/_modules/monty/multiprocessing.html index 77c0575e..cd0307b2 100644 --- a/docs/_modules/monty/multiprocessing.html +++ b/docs/_modules/monty/multiprocessing.html @@ -1,18 +1,15 @@ - - monty.multiprocessing — monty 2023.4.10 documentation + monty.multiprocessing — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/operator.html b/docs/_modules/monty/operator.html index 6cee71f5..d4016611 100644 --- a/docs/_modules/monty/operator.html +++ b/docs/_modules/monty/operator.html @@ -1,18 +1,15 @@ - - monty.operator — monty 2023.4.10 documentation + monty.operator — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/os.html b/docs/_modules/monty/os.html index 8a06a886..dbcb57a6 100644 --- a/docs/_modules/monty/os.html +++ b/docs/_modules/monty/os.html @@ -1,18 +1,15 @@ - - monty.os — monty 2023.4.10 documentation + monty.os — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/os/path.html b/docs/_modules/monty/os/path.html index eacb7b4d..7d636f47 100644 --- a/docs/_modules/monty/os/path.html +++ b/docs/_modules/monty/os/path.html @@ -1,18 +1,15 @@ - - monty.os.path — monty 2023.4.10 documentation + monty.os.path — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/pprint.html b/docs/_modules/monty/pprint.html index 5aa1fab7..1cc8dd51 100644 --- a/docs/_modules/monty/pprint.html +++ b/docs/_modules/monty/pprint.html @@ -1,18 +1,15 @@ - - monty.pprint — monty 2023.4.10 documentation + monty.pprint — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/re.html b/docs/_modules/monty/re.html index de3a1daa..06069c4f 100644 --- a/docs/_modules/monty/re.html +++ b/docs/_modules/monty/re.html @@ -1,18 +1,15 @@ - - monty.re — monty 2023.4.10 documentation + monty.re — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/serialization.html b/docs/_modules/monty/serialization.html index a01db2e0..50822974 100644 --- a/docs/_modules/monty/serialization.html +++ b/docs/_modules/monty/serialization.html @@ -1,18 +1,15 @@ - - monty.serialization — monty 2023.4.10 documentation + monty.serialization — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/shutil.html b/docs/_modules/monty/shutil.html index aee031e6..c0a35197 100644 --- a/docs/_modules/monty/shutil.html +++ b/docs/_modules/monty/shutil.html @@ -1,18 +1,15 @@ - - monty.shutil — monty 2023.4.10 documentation + monty.shutil — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/string.html b/docs/_modules/monty/string.html index 1c77491c..988d51ce 100644 --- a/docs/_modules/monty/string.html +++ b/docs/_modules/monty/string.html @@ -1,18 +1,15 @@ - - monty.string — monty 2023.4.10 documentation + monty.string — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/subprocess.html b/docs/_modules/monty/subprocess.html index 2486f588..866d4628 100644 --- a/docs/_modules/monty/subprocess.html +++ b/docs/_modules/monty/subprocess.html @@ -1,18 +1,15 @@ - - monty.subprocess — monty 2023.4.10 documentation + monty.subprocess — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/tempfile.html b/docs/_modules/monty/tempfile.html index db0fabc7..fc2aedd7 100644 --- a/docs/_modules/monty/tempfile.html +++ b/docs/_modules/monty/tempfile.html @@ -1,18 +1,15 @@ - - monty.tempfile — monty 2023.4.10 documentation + monty.tempfile — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_modules/monty/termcolor.html b/docs/_modules/monty/termcolor.html index 46553dfe..caa7b048 100644 --- a/docs/_modules/monty/termcolor.html +++ b/docs/_modules/monty/termcolor.html @@ -1,18 +1,15 @@ - - monty.termcolor — monty 2023.4.10 documentation + monty.termcolor — monty 2023.5.7 documentation - - - + @@ -32,7 +29,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/_static/basic.css b/docs/_static/basic.css index 08896771..7577acb1 100644 --- a/docs/_static/basic.css +++ b/docs/_static/basic.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- basic theme. * - * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -324,17 +324,17 @@ aside.sidebar { p.sidebar-title { font-weight: bold; } + nav.contents, aside.topic, - div.admonition, div.topic, blockquote { clear: left; } /* -- topics ---------------------------------------------------------------- */ + nav.contents, aside.topic, - div.topic { border: 1px solid #ccc; padding: 7px; @@ -375,7 +375,6 @@ div.sidebar > :last-child, aside.sidebar > :last-child, nav.contents > :last-child, aside.topic > :last-child, - div.topic > :last-child, div.admonition > :last-child { margin-bottom: 0; @@ -385,7 +384,6 @@ div.sidebar::after, aside.sidebar::after, nav.contents::after, aside.topic::after, - div.topic::after, div.admonition::after, blockquote::after { @@ -611,25 +609,6 @@ ul.simple p { margin-bottom: 0; } -/* Docutils 0.17 and older (footnotes & citations) */ -dl.footnote > dt, -dl.citation > dt { - float: left; - margin-right: 0.5em; -} - -dl.footnote > dd, -dl.citation > dd { - margin-bottom: 0em; -} - -dl.footnote > dd:after, -dl.citation > dd:after { - content: ""; - clear: both; -} - -/* Docutils 0.18+ (footnotes & citations) */ aside.footnote > span, div.citation > span { float: left; @@ -654,8 +633,6 @@ div.citation > p:last-of-type:after { clear: both; } -/* Footnotes & citations ends */ - dl.field-list { display: grid; grid-template-columns: fit-content(30%) auto; @@ -668,10 +645,6 @@ dl.field-list > dt { padding-right: 5px; } -dl.field-list > dt:after { - content: ":"; -} - dl.field-list > dd { padding-left: 0.5em; margin-top: 0em; diff --git a/docs/_static/doctools.js b/docs/_static/doctools.js index c3db08d1..d06a71d7 100644 --- a/docs/_static/doctools.js +++ b/docs/_static/doctools.js @@ -4,12 +4,19 @@ * * Base JavaScript utilities for all Sphinx HTML documentation. * - * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ "use strict"; +const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ + "TEXTAREA", + "INPUT", + "SELECT", + "BUTTON", +]); + const _ready = (callback) => { if (document.readyState !== "loading") { callback(); @@ -18,73 +25,11 @@ const _ready = (callback) => { } }; -/** - * highlight a given string on a node by wrapping it in - * span elements with the given class name. - */ -const _highlight = (node, addItems, text, className) => { - if (node.nodeType === Node.TEXT_NODE) { - const val = node.nodeValue; - const parent = node.parentNode; - const pos = val.toLowerCase().indexOf(text); - if ( - pos >= 0 && - !parent.classList.contains(className) && - !parent.classList.contains("nohighlight") - ) { - let span; - - const closestNode = parent.closest("body, svg, foreignObject"); - const isInSVG = closestNode && closestNode.matches("svg"); - if (isInSVG) { - span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); - } else { - span = document.createElement("span"); - span.classList.add(className); - } - - span.appendChild(document.createTextNode(val.substr(pos, text.length))); - parent.insertBefore( - span, - parent.insertBefore( - document.createTextNode(val.substr(pos + text.length)), - node.nextSibling - ) - ); - node.nodeValue = val.substr(0, pos); - - if (isInSVG) { - const rect = document.createElementNS( - "http://www.w3.org/2000/svg", - "rect" - ); - const bbox = parent.getBBox(); - rect.x.baseVal.value = bbox.x; - rect.y.baseVal.value = bbox.y; - rect.width.baseVal.value = bbox.width; - rect.height.baseVal.value = bbox.height; - rect.setAttribute("class", className); - addItems.push({ parent: parent, target: rect }); - } - } - } else if (node.matches && !node.matches("button, select, textarea")) { - node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); - } -}; -const _highlightText = (thisNode, text, className) => { - let addItems = []; - _highlight(thisNode, addItems, text, className); - addItems.forEach((obj) => - obj.parent.insertAdjacentElement("beforebegin", obj.target) - ); -}; - /** * Small JavaScript module for the documentation. */ const Documentation = { init: () => { - Documentation.highlightSearchWords(); Documentation.initDomainIndexTable(); Documentation.initOnKeyListeners(); }, @@ -126,51 +71,6 @@ const Documentation = { Documentation.LOCALE = catalog.locale; }, - /** - * highlight the search words provided in the url in the text - */ - highlightSearchWords: () => { - const highlight = - new URLSearchParams(window.location.search).get("highlight") || ""; - const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); - if (terms.length === 0) return; // nothing to do - - // There should never be more than one element matching "div.body" - const divBody = document.querySelectorAll("div.body"); - const body = divBody.length ? divBody[0] : document.querySelector("body"); - window.setTimeout(() => { - terms.forEach((term) => _highlightText(body, term, "highlighted")); - }, 10); - - const searchBox = document.getElementById("searchbox"); - if (searchBox === null) return; - searchBox.appendChild( - document - .createRange() - .createContextualFragment( - '" - ) - ); - }, - - /** - * helper function to hide the search marks again - */ - hideSearchWords: () => { - document - .querySelectorAll("#searchbox .highlight-link") - .forEach((el) => el.remove()); - document - .querySelectorAll("span.highlighted") - .forEach((el) => el.classList.remove("highlighted")); - const url = new URL(window.location); - url.searchParams.delete("highlight"); - window.history.replaceState({}, "", url); - }, - /** * helper function to focus on search bar */ @@ -210,15 +110,11 @@ const Documentation = { ) return; - const blacklistedElements = new Set([ - "TEXTAREA", - "INPUT", - "SELECT", - "BUTTON", - ]); document.addEventListener("keydown", (event) => { - if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements - if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.altKey || event.ctrlKey || event.metaKey) return; if (!event.shiftKey) { switch (event.key) { @@ -240,10 +136,6 @@ const Documentation = { event.preventDefault(); } break; - case "Escape": - if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; - Documentation.hideSearchWords(); - event.preventDefault(); } } diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 092d404b..d54add02 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '2023.4.10', + VERSION: '2023.5.7', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', @@ -10,5 +10,5 @@ var DOCUMENTATION_OPTIONS = { SOURCELINK_SUFFIX: '.txt', NAVIGATION_WITH_KEYS: false, SHOW_SEARCH_SUMMARY: true, - ENABLE_SEARCH_SHORTCUTS: false, + ENABLE_SEARCH_SHORTCUTS: true, }; \ No newline at end of file diff --git a/docs/_static/language_data.js b/docs/_static/language_data.js index 2e22b06a..250f5665 100644 --- a/docs/_static/language_data.js +++ b/docs/_static/language_data.js @@ -5,7 +5,7 @@ * This script contains the language-specific data used by searchtools.js, * namely the list of stopwords, stemmer, scorer and splitter. * - * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js index ac4d5861..97d56a74 100644 --- a/docs/_static/searchtools.js +++ b/docs/_static/searchtools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -57,14 +57,14 @@ const _removeChildren = (element) => { const _escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string -const _displayItem = (item, highlightTerms, searchTerms) => { +const _displayItem = (item, searchTerms) => { const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT; const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; - const [docName, title, anchor, descr] = item; + const [docName, title, anchor, descr, score, _filename] = item; let listItem = document.createElement("li"); let requestUrl; @@ -82,13 +82,12 @@ const _displayItem = (item, highlightTerms, searchTerms) => { requestUrl = docUrlRoot + docName + docFileSuffix; linkUrl = docName + docLinkSuffix; } - const params = new URLSearchParams(); - params.set("highlight", [...highlightTerms].join(" ")); let linkEl = listItem.appendChild(document.createElement("a")); - linkEl.href = linkUrl + "?" + params.toString() + anchor; + linkEl.href = linkUrl + anchor; + linkEl.dataset.score = score; linkEl.innerHTML = title; if (descr) - listItem.appendChild(document.createElement("span")).innerText = + listItem.appendChild(document.createElement("span")).innerHTML = " (" + descr + ")"; else if (showSearchSummary) fetch(requestUrl) @@ -96,7 +95,7 @@ const _displayItem = (item, highlightTerms, searchTerms) => { .then((data) => { if (data) listItem.appendChild( - Search.makeSearchSummary(data, searchTerms, highlightTerms) + Search.makeSearchSummary(data, searchTerms) ); }); Search.output.appendChild(listItem); @@ -116,15 +115,14 @@ const _finishSearch = (resultCount) => { const _displayNextItem = ( results, resultCount, - highlightTerms, searchTerms ) => { // results left, load the summary and display it // this is intended to be dynamic (don't sub resultsCount) if (results.length) { - _displayItem(results.pop(), highlightTerms, searchTerms); + _displayItem(results.pop(), searchTerms); setTimeout( - () => _displayNextItem(results, resultCount, highlightTerms, searchTerms), + () => _displayNextItem(results, resultCount, searchTerms), 5 ); } @@ -155,10 +153,8 @@ const Search = { _pulse_status: -1, htmlToText: (htmlString) => { - const htmlElement = document - .createRange() - .createContextualFragment(htmlString); - _removeChildren(htmlElement.querySelectorAll(".headerlink")); + const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); + htmlElement.querySelectorAll(".headerlink").forEach((el) => { el.remove() }); const docContent = htmlElement.querySelector('[role="main"]'); if (docContent !== undefined) return docContent.textContent; console.warn( @@ -239,6 +235,12 @@ const Search = { * execute search (requires search index to be loaded) */ query: (query) => { + const filenames = Search._index.filenames; + const docNames = Search._index.docnames; + const titles = Search._index.titles; + const allTitles = Search._index.alltitles; + const indexEntries = Search._index.indexentries; + // stem the search terms and add them to the correct list const stemmer = new Stemmer(); const searchTerms = new Set(); @@ -266,6 +268,10 @@ const Search = { } }); + if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js + localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" ")) + } + // console.debug("SEARCH: searching for:"); // console.info("required: ", [...searchTerms]); // console.info("excluded: ", [...excludedTerms]); @@ -274,6 +280,40 @@ const Search = { let results = []; _removeChildren(document.getElementById("search-progress")); + const queryLower = query.toLowerCase(); + for (const [title, foundTitles] of Object.entries(allTitles)) { + if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) { + for (const [file, id] of foundTitles) { + let score = Math.round(100 * queryLower.length / title.length) + results.push([ + docNames[file], + titles[file] !== title ? `${titles[file]} > ${title}` : title, + id !== null ? "#" + id : "", + null, + score, + filenames[file], + ]); + } + } + } + + // search for explicit entries in index directives + for (const [entry, foundEntries] of Object.entries(indexEntries)) { + if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) { + for (const [file, id] of foundEntries) { + let score = Math.round(100 * queryLower.length / entry.length) + results.push([ + docNames[file], + titles[file], + id ? "#" + id : "", + null, + score, + filenames[file], + ]); + } + } + } + // lookup as object objectTerms.forEach((term) => results.push(...Search.performObjectSearch(term, objectTerms)) @@ -320,7 +360,7 @@ const Search = { // console.info("search results:", Search.lastresults); // print the results - _displayNextItem(results, results.length, highlightTerms, searchTerms); + _displayNextItem(results, results.length, searchTerms); }, /** @@ -401,8 +441,8 @@ const Search = { // prepare search const terms = Search._index.terms; const titleTerms = Search._index.titleterms; - const docNames = Search._index.docnames; const filenames = Search._index.filenames; + const docNames = Search._index.docnames; const titles = Search._index.titles; const scoreMap = new Map(); @@ -499,16 +539,15 @@ const Search = { /** * helper function to return a node containing the * search summary for a given text. keywords is a list - * of stemmed words, highlightWords is the list of normal, unstemmed - * words. the first one is used to find the occurrence, the - * latter for highlighting it. + * of stemmed words. */ - makeSearchSummary: (htmlText, keywords, highlightWords) => { - const text = Search.htmlToText(htmlText).toLowerCase(); + makeSearchSummary: (htmlText, keywords) => { + const text = Search.htmlToText(htmlText); if (text === "") return null; + const textLower = text.toLowerCase(); const actualStartPosition = [...keywords] - .map((k) => text.indexOf(k.toLowerCase())) + .map((k) => textLower.indexOf(k.toLowerCase())) .filter((i) => i > -1) .slice(-1)[0]; const startWithContext = Math.max(actualStartPosition - 120, 0); @@ -516,13 +555,9 @@ const Search = { const top = startWithContext === 0 ? "" : "..."; const tail = startWithContext + 240 < text.length ? "..." : ""; - let summary = document.createElement("div"); + let summary = document.createElement("p"); summary.classList.add("context"); - summary.innerText = top + text.substr(startWithContext, 240).trim() + tail; - - highlightWords.forEach((highlightWord) => - _highlightText(summary, highlightWord, "highlighted") - ); + summary.textContent = top + text.substr(startWithContext, 240).trim() + tail; return summary; }, diff --git a/docs/_themes/README.html b/docs/_themes/README.html index 7ce6cba0..0dae2029 100644 --- a/docs/_themes/README.html +++ b/docs/_themes/README.html @@ -1,4 +1,3 @@ - @@ -6,14 +5,12 @@ - krTheme Sphinx Style — monty 2023.4.10 documentation + krTheme Sphinx Style — monty 2023.5.7 documentation - - - + @@ -33,7 +30,7 @@

    Navigation

  • modules |
  • - +
    diff --git a/docs/changelog.html b/docs/changelog.html index abd68f3f..c122af50 100644 --- a/docs/changelog.html +++ b/docs/changelog.html @@ -1,4 +1,3 @@ - @@ -6,14 +5,12 @@ - Change log — monty 2023.4.10 documentation + Change log — monty 2023.5.7 documentation - - - + @@ -33,7 +30,7 @@

    Navigation

  • modules |
  • - +
    @@ -45,6 +42,12 @@

    Navigation

    Change log¶

    +
    +

    v2023.5.7¶

    +
      +
    • Pytorch tensor support for MontyEncoder/Decoder.

    • +
    +

    v2023.4.10¶

    diff --git a/docs/index.html b/docs/index.html index 16267ae3..79c802fe 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,3 @@ - @@ -6,14 +5,12 @@ - Monty: Python Made Even Easier — monty 2023.4.10 documentation + Monty: Python Made Even Easier — monty 2023.5.7 documentation - - - + @@ -37,7 +34,7 @@

    Navigation

  • next |
  • - +
    @@ -157,39 +154,234 @@

    API docsSubpackages
  • Submodules
  • Module contents
  • diff --git a/docs/modules.html b/docs/modules.html index 107fb719..0c44d20e 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,4 +1,3 @@ - @@ -6,14 +5,12 @@ - monty — monty 2023.4.10 documentation + monty — monty 2023.5.7 documentation - - - + @@ -33,7 +30,7 @@

    Navigation

  • modules |
  • - + @@ -51,39 +48,234 @@

    monty
  • Subpackages
  • Submodules
  • Module contents
  • diff --git a/docs/monty.bisect.html b/docs/monty.bisect.html index 3f74126e..f462fd81 100644 --- a/docs/monty.bisect.html +++ b/docs/monty.bisect.html @@ -1,4 +1,3 @@ - @@ -6,14 +5,12 @@ - monty.bisect module — monty 2023.4.10 documentation + monty.bisect module — monty 2023.5.7 documentation - - - + @@ -41,7 +38,7 @@

    Navigation

  • previous |
  • - + @@ -98,7 +95,21 @@

    Navigation