From effe33ba89c46c20925dfc8f4ac2c2c8ce984748 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 3 Mar 2024 13:26:16 +0000 Subject: [PATCH] build based on 8d9baeb --- dev/.documenter-siteinfo.json | 2 +- dev/assets/Manifest.toml | 57 +- dev/assets/documenter.js | 923 ++++++++++++--------- dev/assets/themes/documenter-dark.css | 2 +- dev/index.html | 30 +- dev/interface/index.html | 2 +- dev/manual/index.html | 2 +- dev/methods/{60c73e3c.svg => 0ee619ea.svg} | 96 +-- dev/methods/{26f02551.svg => 1ea6fd6b.svg} | 82 +- dev/methods/{35055978.svg => 22bc1a27.svg} | 78 +- dev/methods/{1f1e599f.svg => 282724fa.svg} | 262 +++--- dev/methods/{6e2c9c33.svg => 324cdddb.svg} | 82 +- dev/methods/{bc52c47f.svg => 38755eb8.svg} | 82 +- dev/methods/{110bf474.svg => 4aff0433.svg} | 82 +- dev/methods/{3bf96f41.svg => 4d81b965.svg} | 90 +- dev/methods/{3498931a.svg => 5bea7e53.svg} | 262 +++--- dev/methods/{7d713435.svg => b34baedf.svg} | 86 +- dev/methods/{43f8af8c.svg => c5023ff3.svg} | 82 +- dev/methods/{d8d65d27.svg => d7c1d846.svg} | 86 +- dev/methods/{b088b4b5.svg => fd86fc62.svg} | 468 +++++------ dev/methods/index.html | 28 +- dev/objects.inv | Bin 0 -> 639 bytes 22 files changed, 1522 insertions(+), 1362 deletions(-) rename dev/methods/{60c73e3c.svg => 0ee619ea.svg} (86%) rename dev/methods/{26f02551.svg => 1ea6fd6b.svg} (97%) rename dev/methods/{35055978.svg => 22bc1a27.svg} (97%) rename dev/methods/{1f1e599f.svg => 282724fa.svg} (95%) rename dev/methods/{6e2c9c33.svg => 324cdddb.svg} (97%) rename dev/methods/{bc52c47f.svg => 38755eb8.svg} (97%) rename dev/methods/{110bf474.svg => 4aff0433.svg} (97%) rename dev/methods/{3bf96f41.svg => 4d81b965.svg} (97%) rename dev/methods/{3498931a.svg => 5bea7e53.svg} (95%) rename dev/methods/{7d713435.svg => b34baedf.svg} (97%) rename dev/methods/{43f8af8c.svg => c5023ff3.svg} (97%) rename dev/methods/{d8d65d27.svg => d7c1d846.svg} (97%) rename dev/methods/{b088b4b5.svg => fd86fc62.svg} (80%) create mode 100644 dev/objects.inv diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 754d8dc6..d6ae8825 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-25T20:52:13","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-03T13:26:11","documenter_version":"1.3.0"}} \ No newline at end of file diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index c072dd4b..389972b5 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.1" +julia_version = "1.10.2" manifest_format = "2.0" project_hash = "efcfd71a0d3e42af1f180f3d4f358bd06f40b3d9" @@ -60,9 +60,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.BenchmarkTools]] deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] -git-tree-sha1 = "f1f03a9fa24271160ed7e73051fba3c1a759b53f" +git-tree-sha1 = "f1dff6729bc61f4d49e140da1af55dcd1ac97b2f" uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -version = "1.4.0" +version = "1.5.0" [[deps.BitFlags]] git-tree-sha1 = "2dc09997850d68179b69dafb58ae806167a32b1b" @@ -246,10 +246,10 @@ uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" version = "0.9.3" [[deps.Documenter]] -deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "Test", "Unicode"] -git-tree-sha1 = "2613dbec8f4748273bbe30ba71fd5cb369966bac" +deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"] +git-tree-sha1 = "4a40af50e8b24333b9ec6892546d9ca5724228eb" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "1.2.1" +version = "1.3.0" [[deps.Downloads]] deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] @@ -333,11 +333,10 @@ git-tree-sha1 = "21efd19106a55620a188615da6d3d06cd7f6ee03" uuid = "a3f928ae-7b40-5064-980b-68af3947d34b" version = "2.13.93+0" -[[deps.Formatting]] -deps = ["Printf"] -git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" -uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" -version = "0.4.2" +[[deps.Format]] +git-tree-sha1 = "f3cf88025f6d03c194d73f5d13fee9004a108329" +uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8" +version = "1.3.6" [[deps.ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"] @@ -393,15 +392,15 @@ version = "0.21.0+0" [[deps.Git]] deps = ["Git_jll"] -git-tree-sha1 = "51764e6c2e84c37055e846c516e9015b4a291c7d" +git-tree-sha1 = "04eff47b1354d702c3a85e8ab23d539bb7d5957e" uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" -version = "1.3.0" +version = "1.3.1" [[deps.Git_jll]] deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] -git-tree-sha1 = "99f27817475017260f1ff24c771a5efef5765e34" +git-tree-sha1 = "12945451c5d0e2d0dca0724c3a8d6448b46bbdf9" uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" -version = "2.44.0+0" +version = "2.44.0+1" [[deps.Glib_jll]] deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"] @@ -506,10 +505,10 @@ uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" version = "1.3.1" [[deps.Latexify]] -deps = ["Formatting", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Printf", "Requires"] -git-tree-sha1 = "f428ae552340899a935973270b8d98e5a31c49fe" +deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] +git-tree-sha1 = "cad560042a7cc108f5a4c24ea1431a9221f22c1b" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.1" +version = "0.16.2" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -606,10 +605,10 @@ uuid = "89763e89-9b03-5906-acba-b20f662cd828" version = "4.5.1+1" [[deps.Libuuid_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "7f3efec06033682db852f8b3bc3c1d2b0a0ab066" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "e5edc369a598dfde567269dc6add5812cfa10cd5" uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700" -version = "2.36.0+0" +version = "2.39.3+0" [[deps.LineSearches]] deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"] @@ -669,9 +668,9 @@ version = "0.1.2" [[deps.MathOptInterface]] deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"] -git-tree-sha1 = "e8b98c868029d007102dc5f98986c81f33b0ec37" +git-tree-sha1 = "679c1aec6934d322783bd15db4d18f898653be4f" uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" -version = "1.26.0" +version = "1.27.0" [[deps.MbedTLS]] deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"] @@ -860,9 +859,9 @@ version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" +git-tree-sha1 = "9e8fed0505b0c15b4c1295fd59ea47b411c019cf" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.1" +version = "1.4.2" [[deps.PrettyTables]] deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] @@ -1146,9 +1145,9 @@ version = "1.31.0+0" [[deps.XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] -git-tree-sha1 = "801cbe47eae69adc50f36c3caec4758d2650741b" +git-tree-sha1 = "07e470dabc5a6a4254ffebc29a1b3fc01464e105" uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" -version = "2.12.2+0" +version = "2.12.5+0" [[deps.XSLT_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"] @@ -1372,9 +1371,9 @@ version = "1.18.0+0" [[deps.libpng_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"] -git-tree-sha1 = "873b4f805771d3e4bafe63af759a26ea8ca84d14" +git-tree-sha1 = "1ea2ebe8ffa31f9c324e8c1d6e86b4165b84a024" uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f" -version = "1.6.42+0" +version = "1.6.43+0" [[deps.libvorbis_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"] diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index f5311607..c6562b55 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -4,7 +4,6 @@ requirejs.config({ 'highlight-julia': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/julia.min', 'headroom': 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.12.0/headroom.min', 'jqueryui': 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min', - 'minisearch': 'https://cdn.jsdelivr.net/npm/minisearch@6.1.0/dist/umd/index.min', 'katex-auto-render': 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/contrib/auto-render.min', 'jquery': 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min', 'headroom-jquery': 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.12.0/jQuery.headroom.min', @@ -103,9 +102,10 @@ $(document).on("click", ".docstring header", function () { }); }); -$(document).on("click", ".docs-article-toggle-button", function () { +$(document).on("click", ".docs-article-toggle-button", function (event) { let articleToggleTitle = "Expand docstring"; let navArticleToggleTitle = "Expand all docstrings"; + let animationSpeed = event.noToggleAnimation ? 0 : 400; debounce(() => { if (isExpanded) { @@ -116,7 +116,7 @@ $(document).on("click", ".docs-article-toggle-button", function () { isExpanded = false; - $(".docstring section").slideUp(); + $(".docstring section").slideUp(animationSpeed); } else { $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); $(".docstring-article-toggle-button") @@ -127,7 +127,7 @@ $(document).on("click", ".docs-article-toggle-button", function () { articleToggleTitle = "Collapse docstring"; navArticleToggleTitle = "Collapse all docstrings"; - $(".docstring section").slideDown(); + $(".docstring section").slideDown(animationSpeed); } $(this).prop("title", navArticleToggleTitle); @@ -224,224 +224,465 @@ $(document).ready(function () { }) //////////////////////////////////////////////////////////////////////////////// -require(['jquery', 'minisearch'], function($, minisearch) { - -// In general, most search related things will have "search" as a prefix. -// To get an in-depth about the thought process you can refer: https://hetarth02.hashnode.dev/series/gsoc +require(['jquery'], function($) { -let results = []; -let timer = undefined; +$(document).ready(function () { + let meta = $("div[data-docstringscollapsed]").data(); -let data = documenterSearchIndex["docs"].map((x, key) => { - x["id"] = key; // minisearch requires a unique for each object - return x; + if (meta?.docstringscollapsed) { + $("#documenter-article-toggle-button").trigger({ + type: "click", + noToggleAnimation: true, + }); + } }); -// list below is the lunr 2.1.3 list minus the intersect with names(Base) -// (all, any, get, in, is, only, which) and (do, else, for, let, where, while, with) -// ideally we'd just filter the original list but it's not available as a variable -const stopWords = new Set([ - "a", - "able", - "about", - "across", - "after", - "almost", - "also", - "am", - "among", - "an", - "and", - "are", - "as", - "at", - "be", - "because", - "been", - "but", - "by", - "can", - "cannot", - "could", - "dear", - "did", - "does", - "either", - "ever", - "every", - "from", - "got", - "had", - "has", - "have", - "he", - "her", - "hers", - "him", - "his", - "how", - "however", - "i", - "if", - "into", - "it", - "its", - "just", - "least", - "like", - "likely", - "may", - "me", - "might", - "most", - "must", - "my", - "neither", - "no", - "nor", - "not", - "of", - "off", - "often", - "on", - "or", - "other", - "our", - "own", - "rather", - "said", - "say", - "says", - "she", - "should", - "since", - "so", - "some", - "than", - "that", - "the", - "their", - "them", - "then", - "there", - "these", - "they", - "this", - "tis", - "to", - "too", - "twas", - "us", - "wants", - "was", - "we", - "were", - "what", - "when", - "who", - "whom", - "why", - "will", - "would", - "yet", - "you", - "your", -]); - -let index = new minisearch({ - fields: ["title", "text"], // fields to index for full-text search - storeFields: ["location", "title", "text", "category", "page"], // fields to return with search results - processTerm: (term) => { - let word = stopWords.has(term) ? null : term; - if (word) { - // custom trimmer that doesn't strip @ and !, which are used in julia macro and function names - word = word - .replace(/^[^a-zA-Z0-9@!]+/, "") - .replace(/[^a-zA-Z0-9@!]+$/, ""); - } +}) +//////////////////////////////////////////////////////////////////////////////// +require(['jquery'], function($) { - return word ?? null; - }, - // add . as a separator, because otherwise "title": "Documenter.Anchors.add!", would not find anything if searching for "add!", only for the entire qualification - tokenize: (string) => string.split(/[\s\-\.]+/), - // options which will be applied during the search - searchOptions: { - boost: { title: 100 }, - fuzzy: 2, +/* +To get an in-depth about the thought process you can refer: https://hetarth02.hashnode.dev/series/gsoc + +PSEUDOCODE: + +Searching happens automatically as the user types or adjusts the selected filters. +To preserve responsiveness, as much as possible of the slow parts of the search are done +in a web worker. Searching and result generation are done in the worker, and filtering and +DOM updates are done in the main thread. The filters are in the main thread as they should +be very quick to apply. This lets filters be changed without re-searching with minisearch +(which is possible even if filtering is on the worker thread) and also lets filters be +changed _while_ the worker is searching and without message passing (neither of which are +possible if filtering is on the worker thread) + +SEARCH WORKER: + +Import minisearch + +Build index + +On message from main thread + run search + find the first 200 unique results from each category, and compute their divs for display + note that this is necessary and sufficient information for the main thread to find the + first 200 unique results from any given filter set + post results to main thread + +MAIN: + +Launch worker + +Declare nonconstant globals (worker_is_running, last_search_text, unfiltered_results) + +On text update + if worker is not running, launch_search() + +launch_search + set worker_is_running to true, set last_search_text to the search text + post the search query to worker + +on message from worker + if last_search_text is not the same as the text in the search field, + the latest search result is not reflective of the latest search query, so update again + launch_search() + otherwise + set worker_is_running to false + + regardless, display the new search results to the user + save the unfiltered_results as a global + update_search() + +on filter click + adjust the filter selection + update_search() + +update_search + apply search filters by looping through the unfiltered_results and finding the first 200 + unique results that match the filters + + Update the DOM +*/ + +/////// SEARCH WORKER /////// + +function worker_function(documenterSearchIndex, documenterBaseURL, filters) { + importScripts( + "https://cdn.jsdelivr.net/npm/minisearch@6.1.0/dist/umd/index.min.js" + ); + + let data = documenterSearchIndex.map((x, key) => { + x["id"] = key; // minisearch requires a unique for each object + return x; + }); + + // list below is the lunr 2.1.3 list minus the intersect with names(Base) + // (all, any, get, in, is, only, which) and (do, else, for, let, where, while, with) + // ideally we'd just filter the original list but it's not available as a variable + const stopWords = new Set([ + "a", + "able", + "about", + "across", + "after", + "almost", + "also", + "am", + "among", + "an", + "and", + "are", + "as", + "at", + "be", + "because", + "been", + "but", + "by", + "can", + "cannot", + "could", + "dear", + "did", + "does", + "either", + "ever", + "every", + "from", + "got", + "had", + "has", + "have", + "he", + "her", + "hers", + "him", + "his", + "how", + "however", + "i", + "if", + "into", + "it", + "its", + "just", + "least", + "like", + "likely", + "may", + "me", + "might", + "most", + "must", + "my", + "neither", + "no", + "nor", + "not", + "of", + "off", + "often", + "on", + "or", + "other", + "our", + "own", + "rather", + "said", + "say", + "says", + "she", + "should", + "since", + "so", + "some", + "than", + "that", + "the", + "their", + "them", + "then", + "there", + "these", + "they", + "this", + "tis", + "to", + "too", + "twas", + "us", + "wants", + "was", + "we", + "were", + "what", + "when", + "who", + "whom", + "why", + "will", + "would", + "yet", + "you", + "your", + ]); + + let index = new MiniSearch({ + fields: ["title", "text"], // fields to index for full-text search + storeFields: ["location", "title", "text", "category", "page"], // fields to return with results processTerm: (term) => { let word = stopWords.has(term) ? null : term; if (word) { + // custom trimmer that doesn't strip @ and !, which are used in julia macro and function names word = word .replace(/^[^a-zA-Z0-9@!]+/, "") .replace(/[^a-zA-Z0-9@!]+$/, ""); + + word = word.toLowerCase(); } return word ?? null; }, + // add . as a separator, because otherwise "title": "Documenter.Anchors.add!", would not + // find anything if searching for "add!", only for the entire qualification tokenize: (string) => string.split(/[\s\-\.]+/), - }, -}); + // options which will be applied during the search + searchOptions: { + prefix: true, + boost: { title: 100 }, + fuzzy: 2, + }, + }); -index.addAll(data); + index.addAll(data); + + /** + * Used to map characters to HTML entities. + * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts + */ + const htmlEscapes = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + }; + + /** + * Used to match HTML entities and HTML characters. + * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts + */ + const reUnescapedHtml = /[&<>"']/g; + const reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + + /** + * Escape function from lodash + * Refer: https://github.com/lodash/lodash/blob/main/src/escape.ts + */ + function escape(string) { + return string && reHasUnescapedHtml.test(string) + ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) + : string || ""; + } -let filters = [...new Set(data.map((x) => x.category))]; -var modal_filters = make_modal_body_filters(filters); -var filter_results = []; + /** + * Make the result component given a minisearch result data object and the value + * of the search input as queryString. To view the result object structure, refer: + * https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchresult + * + * @param {object} result + * @param {string} querystring + * @returns string + */ + function make_search_result(result, querystring) { + let search_divider = `
`; + let display_link = + result.location.slice(Math.max(0), Math.min(50, result.location.length)) + + (result.location.length > 30 ? "..." : ""); // To cut-off the link because it messes with the overflow of the whole div + + if (result.page !== "") { + display_link += ` (${result.page})`; + } -$(document).on("keyup", ".documenter-search-input", function (event) { - // Adding a debounce to prevent disruptions from super-speed typing! - debounce(() => update_search(filter_results), 300); + let textindex = new RegExp(`${querystring}`, "i").exec(result.text); + let text = + textindex !== null + ? result.text.slice( + Math.max(textindex.index - 100, 0), + Math.min( + textindex.index + querystring.length + 100, + result.text.length + ) + ) + : ""; // cut-off text before and after from the match + + text = text.length ? escape(text) : ""; + + let display_result = text.length + ? "..." + + text.replace( + new RegExp(`${escape(querystring)}`, "i"), // For first occurrence + '$&' + ) + + "..." + : ""; // highlights the match + + let in_code = false; + if (!["page", "section"].includes(result.category.toLowerCase())) { + in_code = true; + } + + // We encode the full url to escape some special characters which can lead to broken links + let result_div = ` + +
+
${escape(result.title)}
+
${result.category}
+
+

+ ${display_result} +

+
+ ${display_link} +
+
+ ${search_divider} + `; + + return result_div; + } + + self.onmessage = function (e) { + let query = e.data; + let results = index.search(query, { + filter: (result) => { + // Only return relevant results + return result.score >= 1; + }, + }); + + // Pre-filter to deduplicate and limit to 200 per category to the extent + // possible without knowing what the filters are. + let filtered_results = []; + let counts = {}; + for (let filter of filters) { + counts[filter] = 0; + } + let present = {}; + + for (let result of results) { + cat = result.category; + cnt = counts[cat]; + if (cnt < 200) { + id = cat + "---" + result.location; + if (present[id]) { + continue; + } + present[id] = true; + filtered_results.push({ + location: result.location, + category: cat, + div: make_search_result(result, query), + }); + } + } + + postMessage(filtered_results); + }; +} + +// `worker = Threads.@spawn worker_function(documenterSearchIndex)`, but in JavaScript! +const filters = [ + ...new Set(documenterSearchIndex["docs"].map((x) => x.category)), +]; +const worker_str = + "(" + + worker_function.toString() + + ")(" + + JSON.stringify(documenterSearchIndex["docs"]) + + "," + + JSON.stringify(documenterBaseURL) + + "," + + JSON.stringify(filters) + + ")"; +const worker_blob = new Blob([worker_str], { type: "text/javascript" }); +const worker = new Worker(URL.createObjectURL(worker_blob)); + +/////// SEARCH MAIN /////// + +// Whether the worker is currently handling a search. This is a boolean +// as the worker only ever handles 1 or 0 searches at a time. +var worker_is_running = false; + +// The last search text that was sent to the worker. This is used to determine +// if the worker should be launched again when it reports back results. +var last_search_text = ""; + +// The results of the last search. This, in combination with the state of the filters +// in the DOM, is used compute the results to display on calls to update_search. +var unfiltered_results = []; + +// Which filter is currently selected +var selected_filter = ""; + +$(document).on("input", ".documenter-search-input", function (event) { + if (!worker_is_running) { + launch_search(); + } }); +function launch_search() { + worker_is_running = true; + last_search_text = $(".documenter-search-input").val(); + worker.postMessage(last_search_text); +} + +worker.onmessage = function (e) { + if (last_search_text !== $(".documenter-search-input").val()) { + launch_search(); + } else { + worker_is_running = false; + } + + unfiltered_results = e.data; + update_search(); +}; + $(document).on("click", ".search-filter", function () { if ($(this).hasClass("search-filter-selected")) { - $(this).removeClass("search-filter-selected"); + selected_filter = ""; } else { - $(this).addClass("search-filter-selected"); + selected_filter = $(this).text().toLowerCase(); } - // Adding a debounce to prevent disruptions from crazy clicking! - debounce(() => get_filters(), 300); + // This updates search results and toggles classes for UI: + update_search(); }); -/** - * A debounce function, takes a function and an optional timeout in milliseconds - * - * @function callback - * @param {number} timeout - */ -function debounce(callback, timeout = 300) { - clearTimeout(timer); - timer = setTimeout(callback, timeout); -} - /** * Make/Update the search component - * - * @param {string[]} selected_filters */ -function update_search(selected_filters = []) { - let initial_search_body = ` -
Type something to get started!
- `; - +function update_search() { let querystring = $(".documenter-search-input").val(); if (querystring.trim()) { - results = index.search(querystring, { - filter: (result) => { - // Filtering results - if (selected_filters.length === 0) { - return result.score >= 1; - } else { - return ( - result.score >= 1 && selected_filters.includes(result.category) - ); - } - }, - }); + if (selected_filter == "") { + results = unfiltered_results; + } else { + results = unfiltered_results.filter((result) => { + return selected_filter == result.category.toLowerCase(); + }); + } let search_result_container = ``; + let modal_filters = make_modal_body_filters(); let search_divider = `
`; if (results.length) { @@ -449,19 +690,23 @@ function update_search(selected_filters = []) { let count = 0; let search_results = ""; - results.forEach(function (result) { - if (result.location) { - // Checking for duplication of results for the same page - if (!links.includes(result.location)) { - search_results += make_search_result(result, querystring); - count++; - } - + for (var i = 0, n = results.length; i < n && count < 200; ++i) { + let result = results[i]; + if (result.location && !links.includes(result.location)) { + search_results += result.div; + count++; links.push(result.location); } - }); + } - let result_count = `
${count} result(s)
`; + if (count == 1) { + count_str = "1 result"; + } else if (count == 200) { + count_str = "200+ results"; + } else { + count_str = count + " results"; + } + let result_count = `
${count_str}
`; search_result_container = `
@@ -490,125 +735,37 @@ function update_search(selected_filters = []) { $(".search-modal-card-body").html(search_result_container); } else { - filter_results = []; - modal_filters = make_modal_body_filters(filters, filter_results); - if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { $(".search-modal-card-body").addClass("is-justify-content-center"); } - $(".search-modal-card-body").html(initial_search_body); + $(".search-modal-card-body").html(` +
Type something to get started!
+ `); } } /** * Make the modal filter html * - * @param {string[]} filters - * @param {string[]} selected_filters * @returns string */ -function make_modal_body_filters(filters, selected_filters = []) { - let str = ``; - - filters.forEach((val) => { - if (selected_filters.includes(val)) { - str += `${val}`; - } else { - str += `${val}`; - } - }); +function make_modal_body_filters() { + let str = filters + .map((val) => { + if (selected_filter == val.toLowerCase()) { + return `${val}`; + } else { + return `${val}`; + } + }) + .join(""); - let filter_html = ` + return `
Filters: ${str} -
- `; - - return filter_html; -} - -/** - * Make the result component given a minisearch result data object and the value of the search input as queryString. - * To view the result object structure, refer: https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchresult - * - * @param {object} result - * @param {string} querystring - * @returns string - */ -function make_search_result(result, querystring) { - let search_divider = `
`; - let display_link = - result.location.slice(Math.max(0), Math.min(50, result.location.length)) + - (result.location.length > 30 ? "..." : ""); // To cut-off the link because it messes with the overflow of the whole div - - if (result.page !== "") { - display_link += ` (${result.page})`; - } - - let textindex = new RegExp(`\\b${querystring}\\b`, "i").exec(result.text); - let text = - textindex !== null - ? result.text.slice( - Math.max(textindex.index - 100, 0), - Math.min( - textindex.index + querystring.length + 100, - result.text.length - ) - ) - : ""; // cut-off text before and after from the match - - let display_result = text.length - ? "..." + - text.replace( - new RegExp(`\\b${querystring}\\b`, "i"), // For first occurrence - '$&' - ) + - "..." - : ""; // highlights the match - - let in_code = false; - if (!["page", "section"].includes(result.category.toLowerCase())) { - in_code = true; - } - - // We encode the full url to escape some special characters which can lead to broken links - let result_div = ` - -
-
${result.title}
-
${result.category}
-
-

- ${display_result} -

-
- ${display_link} -
-
- ${search_divider} - `; - - return result_div; -} - -/** - * Get selected filters, remake the filter html and lastly update the search modal - */ -function get_filters() { - let ele = $(".search-filters .search-filter-selected").get(); - filter_results = ele.map((x) => $(x).text().toLowerCase()); - modal_filters = make_modal_body_filters(filters, filter_results); - update_search(filter_results); +
`; } }) @@ -635,103 +792,107 @@ $(document).ready(function () { //////////////////////////////////////////////////////////////////////////////// require(['jquery'], function($) { -let search_modal_header = ` - -`; - -let initial_search_body = ` -
Type something to get started!
-`; - -let search_modal_footer = ` - -`; - -$(document.body).append( - ` - diff --git a/dev/interface/index.html b/dev/interface/index.html index 54e4a803..502ebbf4 100644 --- a/dev/interface/index.html +++ b/dev/interface/index.html @@ -26,4 +26,4 @@ DataInterpolations.derivative(A2, 300.0)
-0.23144961208831108

Integrals

Integrals of the interpolated curves can also be computed easily.

Note

Integrals for LagrangeInterpolation, BSplineInterpolation, BSplineApprox, Curvefit will error as there are no simple analytical solutions available. Please use numerical methods instead, such as Integrals.jl.

To compute the integrals from the start of time points provided during interpolation to any point, we can do:

# integral(A, t)
 DataInterpolations.integral(A1, 5.0)
129.64386171415265

If we want to compute integrals between two points, we can do:

# integral(A, t1, t2)
 DataInterpolations.integral(A1, 1.0, 5.0)
114.9694509973317

Again, if the interpolation is defined with extrapolate=true, the integral can be computed beyond the range of the timepoints.

# integral(A, t1, t2)
-DataInterpolations.integral(A2, 200.0, 300.0)
1065.2015077631368
Note

If the times provided in the integral go beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values, and hence the integral can be misrepsentative and might not reflect the true nature of the data.

+DataInterpolations.integral(A2, 200.0, 300.0)
1065.2015077631368
Note

If the times provided in the integral go beyond the range of the time points provided during interpolation, it uses extrapolation methods to compute the values, and hence the integral can be misrepsentative and might not reflect the true nature of the data.

diff --git a/dev/manual/index.html b/dev/manual/index.html index 726b373f..7fb87f62 100644 --- a/dev/manual/index.html +++ b/dev/manual/index.html @@ -1,2 +1,2 @@ -Manual · DataInterpolations.jl

Methods

DataInterpolations.LinearInterpolationType
LinearInterpolation(u, t; extrapolate = false)

It is the method of interpolating between the data points using a linear polynomial. For any point, two data points one each side are chosen and connected with a line. Extrapolation extends the last linear polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticInterpolationType
QuadraticInterpolation(u, t, mode = :Forward; extrapolate = false)

It is the method of interpolating between the data points using quadratic polynomials. For any point, three data points nearby are taken to fit a quadratic polynomial. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.
  • mode: :Forward or :Backward. If :Forward, two data points ahead of the point and one data point behind is taken for interpolation. If :Backward, two data points behind and one ahead is taken for interpolation.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.LagrangeInterpolationType
LagrangeInterpolation(u, t, n = length(t) - 1; extrapolate = false)

It is the method of interpolation using Lagrange polynomials of (k-1)th order passing through all the data points where k is the number of data points.

Arguments

  • u: data points.
  • t: time points.
  • n: order of the polynomial. Currently only (k-1)th order where k is the number of data points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.AkimaInterpolationType
AkimaInterpolation(u, t; extrapolate = false)

It is a spline interpolation built from cubic polynomials. It forms a continuously differentiable function. For more details, refer: https://en.wikipedia.org/wiki/Akima_spline. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.ConstantInterpolationType
ConstantInterpolation(u, t; dir = :left, extrapolate = false)

It is the method of interpolating using a constant polynomial. For any point, two adjacent data points are found on either side (left and right). The value at that point depends on dir. If it is :left, then the value at the left point is chosen and if it is :right, the value at the right point is chosen. Extrapolation extends the last constant polynomial at the end points on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • dir: indicates which value should be used for interpolation (:left or :right).
  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise quadratic polynomials between each pair of data points. Its first derivative is also continuous. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.CubicSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise cubic polynomials between each pair of data points. Its first and second derivative is also continuous. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineInterpolationType
BSplineInterpolation(u, t, d, pVecType, knotVecType; extrapolate = false)

It is a curve defined by the linear combination of n basis functions of degree d where n is the number of data points. For more information, refer https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineApproxType
BSplineApprox(u, t, d, h, pVecType, knotVecType; extrapolate = false)

It is a regression based B-spline. The argument choices are the same as the BSplineInterpolation, with the additional parameter h < length(t) which is the number of control points to use, with smaller h indicating more smoothing. For more information, refer http://www.cad.zju.edu.cn/home/zhx/GM/009/00-bsia.pdf. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • h: number of control points to use.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source

Utility Functions

DataInterpolations.bracketstrictlymontonicFunction
bracketstrictlymontonic(v, x, guess; lt=<comparison>, by=<transform>, rev=false)

Starting from an initial guess index, find indices (lo, hi) such that v[lo] ≤ x ≤ v[hi] according to the specified order, assuming that x is actually within the range of values found in v. If x is outside that range, either lo will be firstindex(v) or hi will be lastindex(v).

Note that the results will not typically satisfy lo ≤ guess ≤ hi. If x is precisely equal to a value that is not unique in the input v, there is no guarantee that (lo, hi) will encompass all indices corresponding to that value.

This algorithm is essentially an expanding binary search, which can be used as a precursor to searchsorted and related functions, which can take lo and hi as arguments. The purpose of using this function first would be to accelerate convergence in those functions by using correlated guesses for repeated calls. The best guess for the next call of this function would be the index returned by the previous call to searchsorted.

See sort! for an explanation of the keyword arguments by, lt and rev.

source
+Manual · DataInterpolations.jl

Methods

DataInterpolations.LinearInterpolationType
LinearInterpolation(u, t; extrapolate = false)

It is the method of interpolating between the data points using a linear polynomial. For any point, two data points one each side are chosen and connected with a line. Extrapolation extends the last linear polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticInterpolationType
QuadraticInterpolation(u, t, mode = :Forward; extrapolate = false)

It is the method of interpolating between the data points using quadratic polynomials. For any point, three data points nearby are taken to fit a quadratic polynomial. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.
  • mode: :Forward or :Backward. If :Forward, two data points ahead of the point and one data point behind is taken for interpolation. If :Backward, two data points behind and one ahead is taken for interpolation.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.LagrangeInterpolationType
LagrangeInterpolation(u, t, n = length(t) - 1; extrapolate = false)

It is the method of interpolation using Lagrange polynomials of (k-1)th order passing through all the data points where k is the number of data points.

Arguments

  • u: data points.
  • t: time points.
  • n: order of the polynomial. Currently only (k-1)th order where k is the number of data points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.AkimaInterpolationType
AkimaInterpolation(u, t; extrapolate = false)

It is a spline interpolation built from cubic polynomials. It forms a continuously differentiable function. For more details, refer: https://en.wikipedia.org/wiki/Akima_spline. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.ConstantInterpolationType
ConstantInterpolation(u, t; dir = :left, extrapolate = false)

It is the method of interpolating using a constant polynomial. For any point, two adjacent data points are found on either side (left and right). The value at that point depends on dir. If it is :left, then the value at the left point is chosen and if it is :right, the value at the right point is chosen. Extrapolation extends the last constant polynomial at the end points on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • dir: indicates which value should be used for interpolation (:left or :right).
  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.QuadraticSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise quadratic polynomials between each pair of data points. Its first derivative is also continuous. Extrapolation extends the last quadratic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.CubicSplineType
QuadraticSpline(u, t; extrapolate = false)

It is a spline interpolation using piecewise cubic polynomials between each pair of data points. Its first and second derivative is also continuous. Extrapolation extends the last cubic polynomial on each side.

Arguments

  • u: data points.
  • t: time points.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineInterpolationType
BSplineInterpolation(u, t, d, pVecType, knotVecType; extrapolate = false)

It is a curve defined by the linear combination of n basis functions of degree d where n is the number of data points. For more information, refer https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source
DataInterpolations.BSplineApproxType
BSplineApprox(u, t, d, h, pVecType, knotVecType; extrapolate = false)

It is a regression based B-spline. The argument choices are the same as the BSplineInterpolation, with the additional parameter h < length(t) which is the number of control points to use, with smaller h indicating more smoothing. For more information, refer http://www.cad.zju.edu.cn/home/zhx/GM/009/00-bsia.pdf. Extrapolation is a constant polynomial of the end points on each side.

Arguments

  • u: data points.
  • t: time points.
  • d: degree of the piecewise polynomial.
  • h: number of control points to use.
  • pVecType: symbol to parameters vector, :Uniform for uniform spaced parameters and :ArcLen for parameters generated by chord length method.
  • knotVecType: symbol to knot vector, :Uniform for uniform knot vector, :Average for average spaced knot vector.

Keyword Arguments

  • extrapolate: boolean value to allow extrapolation. Defaults to false.
source

Utility Functions

DataInterpolations.bracketstrictlymontonicFunction
bracketstrictlymontonic(v, x, guess; lt=<comparison>, by=<transform>, rev=false)

Starting from an initial guess index, find indices (lo, hi) such that v[lo] ≤ x ≤ v[hi] according to the specified order, assuming that x is actually within the range of values found in v. If x is outside that range, either lo will be firstindex(v) or hi will be lastindex(v).

Note that the results will not typically satisfy lo ≤ guess ≤ hi. If x is precisely equal to a value that is not unique in the input v, there is no guarantee that (lo, hi) will encompass all indices corresponding to that value.

This algorithm is essentially an expanding binary search, which can be used as a precursor to searchsorted and related functions, which can take lo and hi as arguments. The purpose of using this function first would be to accelerate convergence in those functions by using correlated guesses for repeated calls. The best guess for the next call of this function would be the index returned by the previous call to searchsorted.

See sort! for an explanation of the keyword arguments by, lt and rev.

source
diff --git a/dev/methods/60c73e3c.svg b/dev/methods/0ee619ea.svg similarity index 86% rename from dev/methods/60c73e3c.svg rename to dev/methods/0ee619ea.svg index 83d05b3e..0414c0ff 100644 --- a/dev/methods/60c73e3c.svg +++ b/dev/methods/0ee619ea.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/26f02551.svg b/dev/methods/1ea6fd6b.svg similarity index 97% rename from dev/methods/26f02551.svg rename to dev/methods/1ea6fd6b.svg index 02f04423..1f4f168d 100644 --- a/dev/methods/26f02551.svg +++ b/dev/methods/1ea6fd6b.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/35055978.svg b/dev/methods/22bc1a27.svg similarity index 97% rename from dev/methods/35055978.svg rename to dev/methods/22bc1a27.svg index b9a68ed8..5ab33a4b 100644 --- a/dev/methods/35055978.svg +++ b/dev/methods/22bc1a27.svg @@ -1,53 +1,53 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/1f1e599f.svg b/dev/methods/282724fa.svg similarity index 95% rename from dev/methods/1f1e599f.svg rename to dev/methods/282724fa.svg index 12e02518..c16f1309 100644 --- a/dev/methods/1f1e599f.svg +++ b/dev/methods/282724fa.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/6e2c9c33.svg b/dev/methods/324cdddb.svg similarity index 97% rename from dev/methods/6e2c9c33.svg rename to dev/methods/324cdddb.svg index 5f10245d..315085fe 100644 --- a/dev/methods/6e2c9c33.svg +++ b/dev/methods/324cdddb.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/bc52c47f.svg b/dev/methods/38755eb8.svg similarity index 97% rename from dev/methods/bc52c47f.svg rename to dev/methods/38755eb8.svg index 7a33fbf6..0d73a81c 100644 --- a/dev/methods/bc52c47f.svg +++ b/dev/methods/38755eb8.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/110bf474.svg b/dev/methods/4aff0433.svg similarity index 97% rename from dev/methods/110bf474.svg rename to dev/methods/4aff0433.svg index 77493a52..24d54136 100644 --- a/dev/methods/110bf474.svg +++ b/dev/methods/4aff0433.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/3bf96f41.svg b/dev/methods/4d81b965.svg similarity index 97% rename from dev/methods/3bf96f41.svg rename to dev/methods/4d81b965.svg index feee5969..32ffbb28 100644 --- a/dev/methods/3bf96f41.svg +++ b/dev/methods/4d81b965.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/3498931a.svg b/dev/methods/5bea7e53.svg similarity index 95% rename from dev/methods/3498931a.svg rename to dev/methods/5bea7e53.svg index f7a263f3..e6fb23d2 100644 --- a/dev/methods/3498931a.svg +++ b/dev/methods/5bea7e53.svg @@ -1,145 +1,145 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/7d713435.svg b/dev/methods/b34baedf.svg similarity index 97% rename from dev/methods/7d713435.svg rename to dev/methods/b34baedf.svg index b5490d8e..fb95a9ff 100644 --- a/dev/methods/7d713435.svg +++ b/dev/methods/b34baedf.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/43f8af8c.svg b/dev/methods/c5023ff3.svg similarity index 97% rename from dev/methods/43f8af8c.svg rename to dev/methods/c5023ff3.svg index 23e60b1a..b9fd7771 100644 --- a/dev/methods/43f8af8c.svg +++ b/dev/methods/c5023ff3.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/d8d65d27.svg b/dev/methods/d7c1d846.svg similarity index 97% rename from dev/methods/d8d65d27.svg rename to dev/methods/d7c1d846.svg index 5237ce3e..95ba7a0e 100644 --- a/dev/methods/d8d65d27.svg +++ b/dev/methods/d7c1d846.svg @@ -1,57 +1,57 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/b088b4b5.svg b/dev/methods/fd86fc62.svg similarity index 80% rename from dev/methods/b088b4b5.svg rename to dev/methods/fd86fc62.svg index 69126088..d141cb5a 100644 --- a/dev/methods/b088b4b5.svg +++ b/dev/methods/fd86fc62.svg @@ -1,248 +1,248 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/methods/index.html b/dev/methods/index.html index 0e8a1590..d95c432d 100644 --- a/dev/methods/index.html +++ b/dev/methods/index.html @@ -13,24 +13,24 @@ 205.8 252.3

For each method, we will show how to perform the fit and use the plot recipe to show the fitting curve.

Linear Interpolation

This is a linear interpolation between the ends points of the interval of input data points.

A = LinearInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Quadratic Interpolation

This function fits a parabola passing through the two nearest points from the input data point as well as the next-closest point on the right or left, depending on whether the forward- or backward-looking mode is selected (default mode is forward-looking). It is continuous and piecewise differentiable.

A = QuadraticInterpolation(u, t) # same as QuadraticInterpolation(u,t,:Forward)
+plot!(A)
Example block output

Quadratic Interpolation

This function fits a parabola passing through the two nearest points from the input data point as well as the next-closest point on the right or left, depending on whether the forward- or backward-looking mode is selected (default mode is forward-looking). It is continuous and piecewise differentiable.

A = QuadraticInterpolation(u, t) # same as QuadraticInterpolation(u,t,:Forward)
 # alternatively: A = QuadraticInterpolation(u,t,:Backward)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Lagrange Interpolation

It fits a polynomial of degree d (=length(t)-1), and is thus a continuously differentiable function.

A = LagrangeInterpolation(u, t)
+plot!(A)
Example block output

Lagrange Interpolation

It fits a polynomial of degree d (=length(t)-1), and is thus a continuously differentiable function.

A = LagrangeInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Constant Interpolation

This function is constant between data points. By default, it takes the value at the left end of the interval. One can change that behavior by passing the keyword argument dir = :right.

A = ConstantInterpolation(u, t)
+plot!(A)
Example block output

Constant Interpolation

This function is constant between data points. By default, it takes the value at the left end of the interval. One can change that behavior by passing the keyword argument dir = :right.

A = ConstantInterpolation(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Or using the right endpoints:

A = ConstantInterpolation(u, t, dir = :right)
+plot!(A)
Example block output

Or using the right endpoints:

A = ConstantInterpolation(u, t, dir = :right)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Quadratic Spline

This is the quadratic spline. It is a continuously differentiable interpolation which hits each of the data points exactly. Splines are a local interpolation method, meaning that the curve in a given spot is only affected by the points nearest to it.

A = QuadraticSpline(u, t)
+plot!(A)
Example block output

Quadratic Spline

This is the quadratic spline. It is a continuously differentiable interpolation which hits each of the data points exactly. Splines are a local interpolation method, meaning that the curve in a given spot is only affected by the points nearest to it.

A = QuadraticSpline(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Cubic Spline

This is the cubic spline. It is a continuously twice differentiable interpolation which hits each of the data points exactly.

A = CubicSpline(u, t)
+plot!(A)
Example block output

Cubic Spline

This is the cubic spline. It is a continuously twice differentiable interpolation which hits each of the data points exactly.

A = CubicSpline(u, t)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

B-Splines

This is an interpolating B-spline. B-splines are a global method, meaning that every data point is taken into account for each point of the curve. The interpolating B-spline is the version which hits each of the points. This method is described in more detail here. Let's plot a cubic B-spline (3rd order). Since the data points are not close to uniformly spaced, we will use the :ArcLen and :Average choices:

A = BSplineInterpolation(u, t, 3, :ArcLen, :Average)
+plot!(A)
Example block output

B-Splines

This is an interpolating B-spline. B-splines are a global method, meaning that every data point is taken into account for each point of the curve. The interpolating B-spline is the version which hits each of the points. This method is described in more detail here. Let's plot a cubic B-spline (3rd order). Since the data points are not close to uniformly spaced, we will use the :ArcLen and :Average choices:

A = BSplineInterpolation(u, t, 3, :ArcLen, :Average)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

The approximating B-spline is a smoothed version of the B-spline. It again is a global method. In this case, we need to give a number of control points length(t)>h and this method fits a B-spline through the control points which is a least square approximation. This has a natural effect of smoothing the data. For example, if we use 4 control points, we get the result:

A = BSplineApprox(u, t, 3, 4, :ArcLen, :Average)
+plot!(A)
Example block output

The approximating B-spline is a smoothed version of the B-spline. It again is a global method. In this case, we need to give a number of control points length(t)>h and this method fits a B-spline through the control points which is a least square approximation. This has a natural effect of smoothing the data. For example, if we use 4 control points, we get the result:

A = BSplineApprox(u, t, 3, 4, :ArcLen, :Average)
 scatter(t, u, label = "input data")
-plot!(A)
Example block output

Regularization Smoothing

Smoothing by regularization (a.k.a. ridge regression) finds a function $\hat{u}$ that minimizes the objective function:

$Q(\hat{u}) = \int_{t_1}^{t_N} |\hat{u}(t) - u(t)|^2 \mathrm{d}t + \lambda \int_{\hat{t}_1}^{\hat{t}_N} |\hat{u}^{(d)}(\hat{t})|^2 \mathrm{d} \hat{t}$

where $(d)$ denotes derivative order and $\lambda$ is the regularization (smoothing) parameter. The integrals are evaluated numerically at the set of $t$ values for the first term and $\hat{t}$ values for the second term (equal to $t$ if not provided). Regularization smoothing is a global method that creates a smooth curve directly. See Stickel (2010) Comput. Chem. Eng. 34:467 for details. The implementation in this package uses cubic splines to interpolate between the smoothed points after they are determined.

using RegularizationTools
+plot!(A)
Example block output

Regularization Smoothing

Smoothing by regularization (a.k.a. ridge regression) finds a function $\hat{u}$ that minimizes the objective function:

$Q(\hat{u}) = \int_{t_1}^{t_N} |\hat{u}(t) - u(t)|^2 \mathrm{d}t + \lambda \int_{\hat{t}_1}^{\hat{t}_N} |\hat{u}^{(d)}(\hat{t})|^2 \mathrm{d} \hat{t}$

where $(d)$ denotes derivative order and $\lambda$ is the regularization (smoothing) parameter. The integrals are evaluated numerically at the set of $t$ values for the first term and $\hat{t}$ values for the second term (equal to $t$ if not provided). Regularization smoothing is a global method that creates a smooth curve directly. See Stickel (2010) Comput. Chem. Eng. 34:467 for details. The implementation in this package uses cubic splines to interpolate between the smoothed points after they are determined.

using RegularizationTools
 d = 2
 λ = 1e3
 A = RegularizationSmooth(u, t, d; λ = λ, alg = :fixed)
@@ -42,7 +42,7 @@
 lw = 1.5
 scatter(t, u, label = "data")
 scatter!(t, û, marker = :square, label = "smoothed data")
-plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
Example block output

Dense Data Demonstration

Some methods are better suited for dense data. Let's generate such data to demonstrate these methods.

import StableRNGs: StableRNG
+plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
Example block output

Dense Data Demonstration

Some methods are better suited for dense data. Let's generate such data to demonstrate these methods.

import StableRNGs: StableRNG
 rng = StableRNG(318)
 t = sort(10 .* rand(rng, 100))
 u = sin.(t) .+ 0.5 * randn(rng, 100);
100-element Vector{Float64}:
@@ -76,17 +76,17 @@
 scatter(t, u, label = "simulated data", legend = :top)
 scatter!(t, û, marker = (:square, 4), label = "smoothed data")
 plot!(titp, uitp, lw = lw, label = "smoothed interpolation")
-plot!(titp, ûm, lw = lw, linestyle = :dash, label = "smoothed, more points")
Example block output

Curve Fits

A curve fit works with both dense and sparse data. We will demonstrate the curve fit on the dense data since we generated it based on sin(t), so this is the curve we want to fit through it. To do so, let's define a similar function with parameters. Let's choose the form:

m(t, p) = @. p[1] * sin(p[2] * t) + p[3] * cos(p[4] * t)
m (generic function with 1 method)

Notice that this is a function on the whole array of t and expects an array for the predicted u out. This choice of m is based on the assumption that our function is of the form p1*sin(p2*t)+p3*cos(p4*t). We want to find the p to match our data. Let's start with the guess of every p being zero, that is p=ones(4). Then we would fit this curve using:

using Optim
+plot!(titp, ûm, lw = lw, linestyle = :dash, label = "smoothed, more points")
Example block output

Curve Fits

A curve fit works with both dense and sparse data. We will demonstrate the curve fit on the dense data since we generated it based on sin(t), so this is the curve we want to fit through it. To do so, let's define a similar function with parameters. Let's choose the form:

m(t, p) = @. p[1] * sin(p[2] * t) + p[3] * cos(p[4] * t)
m (generic function with 1 method)

Notice that this is a function on the whole array of t and expects an array for the predicted u out. This choice of m is based on the assumption that our function is of the form p1*sin(p2*t)+p3*cos(p4*t). We want to find the p to match our data. Let's start with the guess of every p being zero, that is p=ones(4). Then we would fit this curve using:

using Optim
 A = Curvefit(u, t, m, ones(4), LBFGS())
 scatter(t, u, label = "points", legend = :bottomright)
-plot!(A)
Example block output

We can check what the fitted parameters are via:

A.pmin
4-element Vector{Float64}:
+plot!(A)
Example block output

We can check what the fitted parameters are via:

A.pmin
4-element Vector{Float64}:
   1.00251731850411
   1.0396588440319725
  -0.13178842465264956
   1.0670107400675999

Notice that it essentially made p3=0 with p1=p2=1, meaning it approximately found sin(t)! But note that the ability to fit is dependent on the initial parameters. For example, with p=zeros(4) as the initial parameters, the fit is not good:

A = Curvefit(u, t, m, zeros(4), LBFGS())
 scatter(t, u, label = "points", legend = :bottomright)
-plot!(A)
Example block output

And the parameters show the issue:

A.pmin
4-element Vector{Float64}:
+plot!(A)
Example block output

And the parameters show the issue:

A.pmin
4-element Vector{Float64}:
  0.0
  0.0
  0.042632088464589324
- 0.0
+ 0.0 diff --git a/dev/objects.inv b/dev/objects.inv new file mode 100644 index 0000000000000000000000000000000000000000..258e796240fd90419f65a66888bb436a2da85579 GIT binary patch literal 639 zcmV-_0)YJ^AX9K?X>NERX>N99Zgg*Qc_4OWa&u{KZXhxWBOp+6Z)#;@bUGkJVRT_h zZggdGaBpm3bZKvHb1rIZ3L_v^WpZMd?av*PJ zAarPHb0B7EY-J#6b0A}HZE$jBb8}^6Aa!$TZf78RY-wUH3V58QR84QAFc7`_S6JG; zdaJ$mmNr`{QY&q{+82Wj6W&{?XW-E_!3Fz^N-I2xr^ci{ubFfg0YQ5p4?y-Z}SrElB@)(@I4aJ)hnMGyrGg$=;x{W!9uB>8{Mu$I9hMtV}-uDG8OL zK2bhc8XAp*zR&wB#p9)05!rmGBDOg`o+|j9JGA9S`a`z_H?oJxx|Qya=8fdAhX2d& ZZ^c(jwy9`bj$de$yEzwq{R8@-%$_AsEFb^? literal 0 HcmV?d00001