Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion pathview/data/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@
"B",
"C",
"D",
"initial_value"
"initial_value",
"state_labels",
"input_labels",
"output_labels"
]
},
"PT1": {
Expand Down Expand Up @@ -327,6 +330,13 @@
"func"
]
},
"Polynomial": {
"blockClass": "Polynomial",
"importPath": "pathsim.blocks",
"params": [
"coeffs"
]
},
"Sin": {
"blockClass": "Sin",
"importPath": "pathsim.blocks",
Expand Down Expand Up @@ -422,6 +432,14 @@
"switch_state"
]
},
"Splitter": {
"blockClass": "Splitter",
"importPath": "pathsim.blocks",
"params": [
"fractions",
"carrier"
]
},
"LUT": {
"blockClass": "LUT",
"importPath": "pathsim.blocks",
Expand Down Expand Up @@ -479,6 +497,14 @@
"tau"
]
},
"FirstOrderHold": {
"blockClass": "FirstOrderHold",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau"
]
},
"FIR": {
"blockClass": "FIR",
"importPath": "pathsim.blocks",
Expand All @@ -488,6 +514,55 @@
"tau"
]
},
"DiscreteIntegrator": {
"blockClass": "DiscreteIntegrator",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau",
"initial_value"
]
},
"DiscreteDerivative": {
"blockClass": "DiscreteDerivative",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau"
]
},
"DiscreteStateSpace": {
"blockClass": "DiscreteStateSpace",
"importPath": "pathsim.blocks",
"params": [
"A",
"B",
"C",
"D",
"T",
"tau",
"initial_value"
]
},
"DiscreteTransferFunction": {
"blockClass": "DiscreteTransferFunction",
"importPath": "pathsim.blocks",
"params": [
"Num",
"Den",
"T",
"tau"
]
},
"TappedDelay": {
"blockClass": "TappedDelay",
"importPath": "pathsim.blocks",
"params": [
"N",
"T",
"tau"
]
},
"ADC": {
"blockClass": "ADC",
"importPath": "pathsim.blocks",
Expand Down
1 change: 1 addition & 0 deletions scripts/config/pathsim/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"Rescale",
"Alias",
"Switch",
"Splitter",
"LUT",
"LUT1D"
],
Expand Down
77 changes: 76 additions & 1 deletion scripts/generated/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@
"B",
"C",
"D",
"initial_value"
"initial_value",
"state_labels",
"input_labels",
"output_labels"
]
},
"PT1": {
Expand Down Expand Up @@ -327,6 +330,13 @@
"func"
]
},
"Polynomial": {
"blockClass": "Polynomial",
"importPath": "pathsim.blocks",
"params": [
"coeffs"
]
},
"Sin": {
"blockClass": "Sin",
"importPath": "pathsim.blocks",
Expand Down Expand Up @@ -422,6 +432,14 @@
"switch_state"
]
},
"Splitter": {
"blockClass": "Splitter",
"importPath": "pathsim.blocks",
"params": [
"fractions",
"carrier"
]
},
"LUT": {
"blockClass": "LUT",
"importPath": "pathsim.blocks",
Expand Down Expand Up @@ -479,6 +497,14 @@
"tau"
]
},
"FirstOrderHold": {
"blockClass": "FirstOrderHold",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau"
]
},
"FIR": {
"blockClass": "FIR",
"importPath": "pathsim.blocks",
Expand All @@ -488,6 +514,55 @@
"tau"
]
},
"DiscreteIntegrator": {
"blockClass": "DiscreteIntegrator",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau",
"initial_value"
]
},
"DiscreteDerivative": {
"blockClass": "DiscreteDerivative",
"importPath": "pathsim.blocks",
"params": [
"T",
"tau"
]
},
"DiscreteStateSpace": {
"blockClass": "DiscreteStateSpace",
"importPath": "pathsim.blocks",
"params": [
"A",
"B",
"C",
"D",
"T",
"tau",
"initial_value"
]
},
"DiscreteTransferFunction": {
"blockClass": "DiscreteTransferFunction",
"importPath": "pathsim.blocks",
"params": [
"Num",
"Den",
"T",
"tau"
]
},
"TappedDelay": {
"blockClass": "TappedDelay",
"importPath": "pathsim.blocks",
"params": [
"N",
"T",
"tau"
]
},
"ADC": {
"blockClass": "ADC",
"importPath": "pathsim.blocks",
Expand Down
10 changes: 6 additions & 4 deletions scripts/pathview_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ def first_line(docstring):


def param_desc(docstring, name):
"""Extract a `:param name:` description from an RST docstring."""
"""Extract the description of parameter `name` from an RST docstring,
the indented lines below its `name : type` line (or `a, name : type`
for parameters documented together)."""
if not docstring:
return ""
pattern = (
re.escape(name)
+ r"\s*:\s*[^\n]*\n\s+(.+?)(?=\n\s*\w+\s*:|\n\n|$)"
r"^[ \t]*(?:\w+\s*,\s*)*" + re.escape(name)
+ r"\s*:\s*[^\n]*\n\s+(.+?)(?=\n\s*\w+\s*:|\n\n|\Z)"
)
m = re.search(pattern, docstring, re.DOTALL)
m = re.search(pattern, docstring, re.DOTALL | re.MULTILINE)
if m:
return re.sub(r"\s+", " ", m.group(1).strip())
return ""
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Auto-generated by scripts/extract.py - DO NOT EDIT
// Source: scripts/config/requirements-pyodide.txt, scripts/config/pyodide.json

export const PATHVIEW_VERSION = '0.15.3';
export const PATHVIEW_VERSION = '0.20.0';

export const PYODIDE_VERSION = '0.29.4';
export const PYODIDE_CDN_URL = `https://cdn.jsdelivr.net/pyodide/v${PYODIDE_VERSION}/full/pyodide.mjs`;
Expand Down
25 changes: 24 additions & 1 deletion src/lib/nodes/generated/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,28 @@ export const extractedBlocks: Record<string, ExtractedBlock> =
],
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 64\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"22\" y1=\"22\" x2=\"40\" y2=\"22\"/>\n <line x1=\"22\" y1=\"42\" x2=\"40\" y2=\"42\"/>\n <line x1=\"56\" y1=\"32\" x2=\"74\" y2=\"32\"/>\n <line x1=\"40\" y1=\"22\" x2=\"56\" y2=\"32\"/>\n <circle cx=\"40\" cy=\"22\" r=\"2.5\" fill=\"currentColor\" stroke=\"none\"/>\n <circle cx=\"40\" cy=\"42\" r=\"2.5\" fill=\"currentColor\" stroke=\"none\"/>\n <circle cx=\"56\" cy=\"32\" r=\"2.5\" fill=\"currentColor\" stroke=\"none\"/>\n</svg>\n"
},
"Splitter": {
"blockClass": "Splitter",
"description": "Splits the input into multiple outputs, weighted with fractions (SIMO).",
"docstringHtml": "<p>Splits the input into multiple outputs, weighted with fractions (SIMO).</p>\n<div class=\"math\">\n\\begin{equation*}\ny_i(t) = f_i \\cdot u(t)\n\\end{equation*}\n</div>\n<p>The fractions have to sum up to one, so the splitter conserves what flows\nthrough it, for example a mass or molar flow.</p>\n<p>With a carrier, the input is a stream of multiple channels, for example\nthe flows of multiple species. Every output is a stream with the same\nlayout and each channel is split with the same fractions.</p>\n<div class=\"section\" id=\"example\">\n<h3>Example</h3>\n<p>Split a flow into two outputs with 90 and 10 percent:</p>\n<pre class=\"code python literal-block\">\n<span class=\"name\">S</span> <span class=\"operator\">=</span> <span class=\"name\">Splitter</span><span class=\"punctuation\">([</span><span class=\"literal number float\">0.9</span><span class=\"punctuation\">,</span> <span class=\"literal number float\">0.1</span><span class=\"punctuation\">])</span>\n</pre>\n<p>Split a stream of species flows, the ports 'in', 'out_0' and 'out_1'\nhave the layout of the carrier:</p>\n<pre class=\"code python literal-block\">\n<span class=\"keyword\">class</span><span class=\"whitespace\"> </span><span class=\"name class\">Species</span><span class=\"punctuation\">(</span><span class=\"name\">Carrier</span><span class=\"punctuation\">):</span><span class=\"whitespace\">\n</span> <span class=\"name\">keys</span> <span class=\"operator\">=</span> <span class=\"punctuation\">(</span><span class=\"literal string double\">&quot;H&quot;</span><span class=\"punctuation\">,</span> <span class=\"literal string double\">&quot;D&quot;</span><span class=\"punctuation\">,</span> <span class=\"literal string double\">&quot;T&quot;</span><span class=\"punctuation\">)</span><span class=\"whitespace\">\n\n</span><span class=\"name\">S</span> <span class=\"operator\">=</span> <span class=\"name\">Splitter</span><span class=\"punctuation\">([</span><span class=\"literal number float\">0.9</span><span class=\"punctuation\">,</span> <span class=\"literal number float\">0.1</span><span class=\"punctuation\">],</span> <span class=\"name\">carrier</span><span class=\"operator\">=</span><span class=\"name\">Species</span><span class=\"punctuation\">())</span><span class=\"whitespace\">\n\n</span><span class=\"name\">C</span> <span class=\"operator\">=</span> <span class=\"name\">Connection</span><span class=\"punctuation\">(</span><span class=\"name\">S</span><span class=\"punctuation\">[</span><span class=\"literal string double\">&quot;out_1&quot;</span><span class=\"punctuation\">],</span> <span class=\"name\">B</span><span class=\"punctuation\">[</span><span class=\"literal string double\">&quot;in&quot;</span><span class=\"punctuation\">])</span>\n</pre>\n</div>\n<div class=\"section\" id=\"note\">\n<h3>Note</h3>\n<p>This block is purely algebraic and its operation (<cite>op_alg</cite>) will be called\nmultiple times per timestep, each time when <cite>Simulation._update(t)</cite> is\ncalled in the global simulation loop.</p>\n</div>\n<div class=\"section\" id=\"parameters\">\n<h3>Parameters</h3>\n<dl class=\"docutils\">\n<dt>fractions <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">array_like</span></dt>\n<dd>fractions of the input for each output, must sum up to one</dd>\n<dt>carrier <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">Carrier | None</span></dt>\n<dd>layout of the input and output streams, single channel if 'None'</dd>\n</dl>\n</div>\n<div class=\"section\" id=\"attributes\">\n<h3>Attributes</h3>\n<dl class=\"docutils\">\n<dt>op_alg <span class=\"classifier-delimiter\">:</span> <span class=\"classifier\">Operator</span></dt>\n<dd>internal algebraic operator</dd>\n</dl>\n</div>\n",
"params": {
"fractions": {
"type": "any",
"default": null,
"description": "fractions of the input for each output, must sum up to one"
},
"carrier": {
"type": "any",
"default": null,
"description": "layout of the input and output streams, single channel if 'None'"
}
},
"inputs": [
"in"
],
"outputs": null,
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 64\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M 18 32 H 40 C 52 32 50 20 62 20 H 78\"/>\n <path d=\"M 40 32 C 52 32 50 44 62 44 H 78\"/>\n <circle cx=\"40\" cy=\"32\" r=\"2.5\" fill=\"currentColor\" stroke=\"none\"/>\n</svg>\n"
},
"LUT": {
"blockClass": "LUT",
"description": "N-dimensional lookup table with linear interpolation functionality.",
Expand Down Expand Up @@ -1844,7 +1866,7 @@ export const extractedBlocks: Record<string, ExtractedBlock> =
export const blockConfig: Record<string, string[]> = {
Sources: ["Constant", "Source", "SinusoidalSource", "StepSource", "PulseSource", "TriangleWaveSource", "SquareWaveSource", "GaussianPulseSource", "ChirpPhaseNoiseSource", "ClockSource", "WhiteNoise", "PinkNoise", "RandomNumberGenerator"],
Dynamic: ["Integrator", "Differentiator", "Delay", "ODE", "DynamicalSystem", "StateSpace", "PT1", "PT2", "LeadLag", "PID", "AntiWindupPID", "RateLimiter", "Backlash", "Deadband", "TransferFunctionNumDen", "TransferFunctionZPG", "ButterworthLowpassFilter", "ButterworthHighpassFilter", "ButterworthBandpassFilter", "ButterworthBandstopFilter"],
Algebraic: ["Adder", "Multiplier", "Divider", "Amplifier", "Function", "Polynomial", "Sin", "Cos", "Tan", "Tanh", "Abs", "Sqrt", "Exp", "Log", "Log10", "Mod", "Clip", "Pow", "Atan2", "Rescale", "Alias", "Switch", "LUT", "LUT1D"],
Algebraic: ["Adder", "Multiplier", "Divider", "Amplifier", "Function", "Polynomial", "Sin", "Cos", "Tan", "Tanh", "Abs", "Sqrt", "Exp", "Log", "Log10", "Mod", "Clip", "Pow", "Atan2", "Rescale", "Alias", "Switch", "Splitter", "LUT", "LUT1D"],
Logic: ["GreaterThan", "LessThan", "Equal", "LogicAnd", "LogicOr", "LogicNot"],
Discrete: ["SampleHold", "FirstOrderHold", "FIR", "DiscreteIntegrator", "DiscreteDerivative", "DiscreteStateSpace", "DiscreteTransferFunction", "TappedDelay", "ADC", "DAC", "Counter", "CounterUp", "CounterDown", "Relay", "Wrapper"],
Recording: ["Scope", "Spectrum"],
Expand Down Expand Up @@ -1918,6 +1940,7 @@ export const blockImportPaths: Record<string, string> = {
"SinusoidalSource": "pathsim.blocks",
"Source": "pathsim.blocks",
"Spectrum": "pathsim.blocks",
"Splitter": "pathsim.blocks",
"Sqrt": "pathsim.blocks",
"SquareWaveSource": "pathsim.blocks",
"StateSpace": "pathsim.blocks",
Expand Down
Loading