Repository navigation
fix: missing-check bugs across layout, model, parsers and metrics (follow-up to #551) - #553
Conversation
…tDates
Locations fixed:
- src/metrics/compute-midpoint.js: reset max_path per call; use branch_length_accessor
- src/metrics/center-of-tree.js: avoid 0/0 breakpoint on zero-length branches
- src/metrics/pairwise-distances.js: finite-number check; root with no children
- src/metrics/root-to-tip.js: use accessor; <2 points early return; best_node starts at root; r2t || {}
- src/metrics/sackins.js: compute depth by walking parents
- src/extract-dates.js: use node.data.name, drop /g regex
…ix phylopart root paths Locations fixed: - src/clustering/cluster-picker.js:38 use branch_length_accessor - src/clustering/cluster-picker.js:64 treat '' / NaN bootstrap as missing - src/clustering/cluster-picker.js:68 validate numeric thresholds; fix README example - src/clustering/phylopart.js:113 include root path segments (EU3031 297 -> 300) - src/clustering/phylopart.js:149 clamp histogram bin index - src/clustering/phylopart.js:183 treat '' / NaN bootstrap as missing
Locations fixed: src/formats/nexml.js:38,44; src/formats/phyloxml.js:44,47,57,68; src/formats/nexus.js:7,28
…join, distance matrix Locations fixed: - src/nodes.js:24 graftANode builds d3 hierarchy nodes and updates - src/nodes.js:50 addChild sets parent; NJ returns new phylotree(newick) - src/nodes.js:99 deleteANode root case lifts sibling children, then updates - src/export.js:12 getTipLengths uses the branch length accessor - src/traversal.js:80 leftChildRightSibling guards unary nodes - src/neighbor-join.js:120,38 jj starts at ii+1 - src/neighbor-join.js:62 getDistanceMatrix uses min length, guards empty input
…ets, annotations, internal-names - menus.js modifySelection: attribute-list clear uses === true; restricted-selectable returns this and uses Array.isArray; notshown/tag bypass selectable and restricted-selectable - menus.js nodeDropdownMenu: resolve container with d3.select(container).node() - selection-sets.js initializeSelectionSets: rebuild members from node._selectionSet, persist active set and initial-sets-applied marker on phylotree - edges.js initializeEdgeLabels: skip reserved annotation names - nodes.js defNodeLabel: pass hierarchy node to showInternalName, never return undefined
…oot and branch-length scaling Locations fixed: - src/main.js: setBranchLength sync in constructor, parse errors thrown, JSON input, phyloxml detection, mrca, update(), name normalisation - src/rooting.js: reroot(root) no-op, NaN branch lengths after reroot - src/branches.js: defBranchLengthAccessor numeric/zero, setBranchLength sync, normalize equal/zero lengths, normalize/scale with custom accessor
Locations fixed: - src/formats/registry.js: nhx defaults to [ ] delimiters - src/formats/newick.js: reserved NHX keys namespaced (nhx_<key>), annotation initialised; getNewick skips hidden children without stray commas; coerces names and only skips 'root' for the actual root; non-string input rejected; root label/length kept; bootstrap_values left undefined for unlabeled internal nodes - src/formats/beast.js: default options, no caller mutation, null json passthrough
- unrooted.js: bbox/scale skip notshown and hidden nodes - unrooted.js: zero and negative branch lengths clamp to 0 (no || 1) - unrooted.js: countLeaves gives 0 for notshown and 1 for collapsed; collapsed clades are not recursed into - unrooted.js: collapsed clades get a screen-space [d.x, d.y] outline wedge - clades.js: only draw collapsed outlines that are non-empty arrays (leaf collapse no longer throws)
…ft lengths as strings
… tips, and setup guards Locations fixed in src/render/draw.js: - placenodes: compute max_depth before the first tree_layout (scaling:false) - placenodes/tree_layout: undef_BL is now an instance field so the unscaled fallback fires for undefined/non-finite branch lengths - _handle_single_node_layout: collapsed outline skips hidden/coordinate-less tips - process_internal_node: require a displayed child before placing the node - constructor: rescale_nodeSpan over all descendants (no root.children access; fixes single-node tree); guard selection-sets / initial-sets / initial-selection - placenodes/do_lr/radial/scale bar: guard zero extents against NaN - update(): refresh this.links; brush handler uses this.links - RTL: mirror collapsed outline points like d.y - replace shadowed font_size()/scale_bar_font_size() with fontSize() and scaleBarFontSize(); declare in types and usage.ts - style_edges(null) no longer throws
# Conflicts: # src/render/draw.js
- getBranchLengths() returns undefined for the root, as on master; the Newick parser now keeps a root length, and normalize/scale skip the root. - render-layout test looks up the root by its preserved label. - tree-model tests skip the root entry when checking normalized lengths.
- getBranchLengths() returns the accessor value for every node again;
normalize/scale include the root only when it has an explicit length.
- clusterPicker coerces numeric-string thresholds and throws only when the
result is not a finite number.
- The constructor honours a {json, error} parser result, rejects
non-object input with a clear error and recognises <phylogeny> as XML.
- The Newick parser rejects empty and whitespace-only strings; the
neighbor-join seed that needed them is gone.
- Drop the redundant refreshHierarchy in nodes.js (update() does it).
- Lint: unused catch bindings and an unused eslint-disable directive.
API Documentation PreviewThe API documentation has been updated in this PR. Here is a preview: ## Modules
<dl>
<dt><a href="#module_render/event-emitter">render/event-emitter</a></dt>
<dd><p>Event emitter mixin for phylotree TreeRender
Provides on/off/emit pattern for tree events</p>
</dd>
<dt><a href="#module_render/selection-sets">render/selection-sets</a></dt>
<dd><p>Multi-set selection management for phylotree</p>
</dd>
</dl>
## Classes
<dl>
<dt><a href="#Phylotree">Phylotree</a></dt>
<dd><p>An instance of a phylotree. Sets event listeners, parses tags, and creates links
that represent branches.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#getBranchLengths">getBranchLengths()</a> ⇒ <code>Array</code></dt>
<dd><p>Returns branch lengths</p>
</dd>
<dt><a href="#setBranchLength">setBranchLength(attr)</a> ⇒ <code>Object</code></dt>
<dd><p>Get or set branch length accessor.</p>
</dd>
<dt><a href="#normalize">normalize()</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Normalizes branch lengths to range [0,1]</p>
</dd>
<dt><a href="#scale">scale(scale_by)</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Scales branch lengths using a custom transformation function</p>
</dd>
<dt><a href="#branchName">branchName(attr)</a> ⇒</dt>
<dd><p>Get or set branch name accessor.</p>
</dd>
<dt><a href="#clusterPicker">clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)</a> ⇒</dt>
<dd><p>Implements a linear time / space version of the Cluster picker algorithm</p>
</dd>
<dt><a href="#newickParser">newickParser(nwk_str)</a> ⇒ <code>Object</code></dt>
<dd><p>Parses a Newick string into an equivalent JSON representation that is
suitable for consumption by <code>hierarchy</code>.</p>
<p>Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths,
as well as tagged trees such as
<code>(a,(b{TAG},(c{TAG},d{ANOTHERTAG})))</code></p>
</dd>
<dt><a href="#getNewick">getNewick(annotator, node)</a> ⇒ <code>String</code></dt>
<dd><p>Return Newick string representat
... (truncated)Full documentation will be available at: https://veg.github.io/phylotree.js/API.md when merged. |
|
Preview removed because the pull request was closed. |
- Constructor unwraps a {json} parser result whether or not it carries an
error field, so trees passed in that wrapper are no longer replaced by a
one-node tree.
- NEXUS statements and TRANSLATE entries are split outside quotes and
[comments], so quoted labels containing ';' or ',' parse again.
- fitRootToTip treats undefined dates as missing and returns fit: null
when the dates cannot support a fit (fewer than two, or no spread).
- The default branch-length accessor reports 0 for the actual root, not
for any node that happens to be named "root".
- clusterPicker accepts Infinity as an unbounded diameter again.
- Selection sets skip malformed definitions; initial-sets are not consumed
by a render that has no set definitions yet.
- NeXML picks the unreferenced node as root when none is flagged;
PhyloXML keeps a lone self-closing <clade/> child.
- Declarations: update() returns the tree, createNode returns a node,
fitRootToTip's fit may be null.
API Documentation PreviewThe API documentation has been updated in this PR. Here is a preview: ## Modules
<dl>
<dt><a href="#module_render/event-emitter">render/event-emitter</a></dt>
<dd><p>Event emitter mixin for phylotree TreeRender
Provides on/off/emit pattern for tree events</p>
</dd>
<dt><a href="#module_render/selection-sets">render/selection-sets</a></dt>
<dd><p>Multi-set selection management for phylotree</p>
</dd>
</dl>
## Classes
<dl>
<dt><a href="#Phylotree">Phylotree</a></dt>
<dd><p>An instance of a phylotree. Sets event listeners, parses tags, and creates links
that represent branches.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#getBranchLengths">getBranchLengths()</a> ⇒ <code>Array</code></dt>
<dd><p>Returns branch lengths</p>
</dd>
<dt><a href="#setBranchLength">setBranchLength(attr)</a> ⇒ <code>Object</code></dt>
<dd><p>Get or set branch length accessor.</p>
</dd>
<dt><a href="#normalize">normalize()</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Normalizes branch lengths to range [0,1]</p>
</dd>
<dt><a href="#scale">scale(scale_by)</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Scales branch lengths using a custom transformation function</p>
</dd>
<dt><a href="#branchName">branchName(attr)</a> ⇒</dt>
<dd><p>Get or set branch name accessor.</p>
</dd>
<dt><a href="#clusterPicker">clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)</a> ⇒</dt>
<dd><p>Implements a linear time / space version of the Cluster picker algorithm</p>
</dd>
<dt><a href="#newickParser">newickParser(nwk_str)</a> ⇒ <code>Object</code></dt>
<dd><p>Parses a Newick string into an equivalent JSON representation that is
suitable for consumption by <code>hierarchy</code>.</p>
<p>Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths,
as well as tagged trees such as
<code>(a,(b{TAG},(c{TAG},d{ANOTHERTAG})))</code></p>
</dd>
<dt><a href="#getNewick">getNewick(annotator, node)</a> ⇒ <code>String</code></dt>
<dd><p>Return Newick string representat
... (truncated)Full documentation will be available at: https://veg.github.io/phylotree.js/API.md when merged. |
- A hierarchy object that happens to carry a json field is no longer
mistaken for a parser result; only {json[, error]} without name or
children is unwrapped.
- fitRootToTip coerces numeric-string dates, returns fit: null when the
distances leave no finite line, and fits the current root from
data.rootToTip. It read data.rtta, which only the other-root pass sets,
so the baseline fit was always NaN and the current root could never win.
- NEXUS: the TREES block ends at the END statement found by quote-aware
splitting, so END; inside a quoted label is fine; doubled quotes inside
a single-quoted label unescape.
- initial-sets are consumed only once a requested set is actually defined.
API Documentation PreviewThe API documentation has been updated in this PR. Here is a preview: ## Modules
<dl>
<dt><a href="#module_render/event-emitter">render/event-emitter</a></dt>
<dd><p>Event emitter mixin for phylotree TreeRender
Provides on/off/emit pattern for tree events</p>
</dd>
<dt><a href="#module_render/selection-sets">render/selection-sets</a></dt>
<dd><p>Multi-set selection management for phylotree</p>
</dd>
</dl>
## Classes
<dl>
<dt><a href="#Phylotree">Phylotree</a></dt>
<dd><p>An instance of a phylotree. Sets event listeners, parses tags, and creates links
that represent branches.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#getBranchLengths">getBranchLengths()</a> ⇒ <code>Array</code></dt>
<dd><p>Returns branch lengths</p>
</dd>
<dt><a href="#setBranchLength">setBranchLength(attr)</a> ⇒ <code>Object</code></dt>
<dd><p>Get or set branch length accessor.</p>
</dd>
<dt><a href="#normalize">normalize()</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Normalizes branch lengths to range [0,1]</p>
</dd>
<dt><a href="#scale">scale(scale_by)</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Scales branch lengths using a custom transformation function</p>
</dd>
<dt><a href="#branchName">branchName(attr)</a> ⇒</dt>
<dd><p>Get or set branch name accessor.</p>
</dd>
<dt><a href="#clusterPicker">clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)</a> ⇒</dt>
<dd><p>Implements a linear time / space version of the Cluster picker algorithm</p>
</dd>
<dt><a href="#newickParser">newickParser(nwk_str)</a> ⇒ <code>Object</code></dt>
<dd><p>Parses a Newick string into an equivalent JSON representation that is
suitable for consumption by <code>hierarchy</code>.</p>
<p>Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths,
as well as tagged trees such as
<code>(a,(b{TAG},(c{TAG},d{ANOTHERTAG})))</code></p>
</dd>
<dt><a href="#getNewick">getNewick(annotator, node)</a> ⇒ <code>String</code></dt>
<dd><p>Return Newick string representat
... (truncated)Full documentation will be available at: https://veg.github.io/phylotree.js/API.md when merged. |
- A parser result that also carries a name is still unwrapped when it has an error field. - NEXUS unquoting strips one layer of quotes, so a single-quoted label may contain literal double quotes. - fitRootToTip: identical distances give fit: null (r2 was 0/0); blank strings and booleans are not dates; a candidate root has to beat the current root's r2 instead of 0, so a perfect current root is kept.
API Documentation PreviewThe API documentation has been updated in this PR. Here is a preview: ## Modules
<dl>
<dt><a href="#module_render/event-emitter">render/event-emitter</a></dt>
<dd><p>Event emitter mixin for phylotree TreeRender
Provides on/off/emit pattern for tree events</p>
</dd>
<dt><a href="#module_render/selection-sets">render/selection-sets</a></dt>
<dd><p>Multi-set selection management for phylotree</p>
</dd>
</dl>
## Classes
<dl>
<dt><a href="#Phylotree">Phylotree</a></dt>
<dd><p>An instance of a phylotree. Sets event listeners, parses tags, and creates links
that represent branches.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#getBranchLengths">getBranchLengths()</a> ⇒ <code>Array</code></dt>
<dd><p>Returns branch lengths</p>
</dd>
<dt><a href="#setBranchLength">setBranchLength(attr)</a> ⇒ <code>Object</code></dt>
<dd><p>Get or set branch length accessor.</p>
</dd>
<dt><a href="#normalize">normalize()</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Normalizes branch lengths to range [0,1]</p>
</dd>
<dt><a href="#scale">scale(scale_by)</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Scales branch lengths using a custom transformation function</p>
</dd>
<dt><a href="#branchName">branchName(attr)</a> ⇒</dt>
<dd><p>Get or set branch name accessor.</p>
</dd>
<dt><a href="#clusterPicker">clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)</a> ⇒</dt>
<dd><p>Implements a linear time / space version of the Cluster picker algorithm</p>
</dd>
<dt><a href="#newickParser">newickParser(nwk_str)</a> ⇒ <code>Object</code></dt>
<dd><p>Parses a Newick string into an equivalent JSON representation that is
suitable for consumption by <code>hierarchy</code>.</p>
<p>Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths,
as well as tagged trees such as
<code>(a,(b{TAG},(c{TAG},d{ANOTHERTAG})))</code></p>
</dd>
<dt><a href="#getNewick">getNewick(annotator, node)</a> ⇒ <code>String</code></dt>
<dd><p>Return Newick string representat
... (truncated)Full documentation will be available at: https://veg.github.io/phylotree.js/API.md when merged. |
- An object with a children array is hierarchical JSON even if it also carries json and error fields; only objects without children are unwrapped as parser results. - fitRootToTip keeps searching alternative roots when the current root has no usable fit, instead of returning early with fit: null.
API Documentation PreviewThe API documentation has been updated in this PR. Here is a preview: ## Modules
<dl>
<dt><a href="#module_render/event-emitter">render/event-emitter</a></dt>
<dd><p>Event emitter mixin for phylotree TreeRender
Provides on/off/emit pattern for tree events</p>
</dd>
<dt><a href="#module_render/selection-sets">render/selection-sets</a></dt>
<dd><p>Multi-set selection management for phylotree</p>
</dd>
</dl>
## Classes
<dl>
<dt><a href="#Phylotree">Phylotree</a></dt>
<dd><p>An instance of a phylotree. Sets event listeners, parses tags, and creates links
that represent branches.</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#getBranchLengths">getBranchLengths()</a> ⇒ <code>Array</code></dt>
<dd><p>Returns branch lengths</p>
</dd>
<dt><a href="#setBranchLength">setBranchLength(attr)</a> ⇒ <code>Object</code></dt>
<dd><p>Get or set branch length accessor.</p>
</dd>
<dt><a href="#normalize">normalize()</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Normalizes branch lengths to range [0,1]</p>
</dd>
<dt><a href="#scale">scale(scale_by)</a> ⇒ <code><a href="#Phylotree">Phylotree</a></code></dt>
<dd><p>Scales branch lengths using a custom transformation function</p>
</dd>
<dt><a href="#branchName">branchName(attr)</a> ⇒</dt>
<dd><p>Get or set branch name accessor.</p>
</dd>
<dt><a href="#clusterPicker">clusterPicker(tree, bootstrap_thresold, diameter_threshold, root_node, missing_bootstrap_value)</a> ⇒</dt>
<dd><p>Implements a linear time / space version of the Cluster picker algorithm</p>
</dd>
<dt><a href="#newickParser">newickParser(nwk_str)</a> ⇒ <code>Object</code></dt>
<dd><p>Parses a Newick string into an equivalent JSON representation that is
suitable for consumption by <code>hierarchy</code>.</p>
<p>Optionally accepts bootstrap values. Currently supports Newick strings with or without branch lengths,
as well as tagged trees such as
<code>(a,(b{TAG},(c{TAG},d{ANOTHERTAG})))</code></p>
</dd>
<dt><a href="#getNewick">getNewick(annotator, node)</a> ⇒ <code>String</code></dt>
<dd><p>Return Newick string representat
... (truncated)Full documentation will be available at: https://veg.github.io/phylotree.js/API.md when merged. |
The API Documentation workflow pushed a regenerated API.md to master after every merge. The branch ruleset added for Dependabot auto-merge now rejects that push (GH013), so the run after #553 failed and API.md went stale. API.md is now committed with the JSDoc change that affects it, and the workflow runs `yarn docs:validate` on pushes and pull requests. The PR preview comment compares against the base branch instead.
Fixes the bugs of the kind reported in #551 across the whole library: fields read before they are set, one field holding two types, a guard present in one layout or code path but missing in a sibling, arithmetic on undefined values that silently produces
NaN, and caches that outlive their inputs.An audit after #552 found 74 such defects (each confirmed by reproducing it through the public API); this PR addresses 73 of them, each with a regression test, and the bullets below are the inventory. Tests go from 476 to 796. No public API is removed or renamed.
Rendering
Layout (
src/render/draw.js)scaling: falseplaced internal nodes to the right of their own tips (max_depthwas 1 during layout).NaNpositions (undef_BLwas a dead local).NaN; a single-node tree no longer throws (see Not fixed for its radial layout).rescale_nodeSpanis the minimum positive span over all tips, so a customnode-spanno longer gives order-dependent spacing.update()refresheslinksafter a topology change; the brush uses the current links.right-to-leftlayouts.selection-sets/initial-setsoptions no longer throw;initial-setsis applied once per tree, so a reroot no longer re-adds nodes.style_edges(null)clears the styler.font_size()andscale_bar_font_size()were shadowed by numeric fields and could never be called. NewfontSize([n])andscaleBarFontSize([n])methods; the fields are unchanged.Unrooted layout (
src/render/unrooted.js,src/render/clades.js)Interaction (
src/render/menus.js,selection-sets.js,edges.js,nodes.js)binary-selectableand a multi-entryattribute-list, selecting for one attribute wiped the others.containerwas an Element or d3 selection.restricted-selectablebroke method chaining; Hide was a dead menu item whenselectable: false._selectionSetflags).children,data,collapsed, etc. overwrote node fields.internal-namescallbacks receivednode.datafrom one call site and the hierarchy node from the others; unnamed internal nodes maderender()throw.Tree model (
src/main.js,branches.js,rooting.js,nodes.js,traversal.js,export.js)branch_lengthandbranch_length_accessorcould diverge;setBranchLengthnow sets both, and every reader (metrics, clustering,getTipLengths,hasBranchLengths) uses the accessor.normalizeBranchLengthsnever mapped the shortest branch to 0 (write-back only when> 0), divided by zero for equal lengths, and rejected numeric attributes.reroot(root)threw and lefttree.nodesundefined; rerooting with a lengthless child producedNaN.mrca()cached across calls and included the node itself, so a second call returned the wrong node.deleteANodeon a child of a binary root threw and left the tree half-modified;graftANodebuilt plain objects without.data. Both now rebuild depth and height.neighborJoining()returned nodes without depth, height or links, so the tree could not be rendered (every branchNaN) or rerooted. It now returns a properphylotree; it also joined a node with itself on all-zero distances.Errorwhen a parser fails (including for an empty string or a{json: null, error}result), instead of an obscureTypeErrorfrom[].links(). An object is treated as a parser result when it has ajsonfield and nochildrenarray of its own; anything withchildrenis hierarchical JSON.leftChildRightSiblingtolerates unary nodes;getDistanceMatrixhandles empty input and unequal sequence lengths.Parsers and export (
src/formats/*,src/extract-dates.js)getNewick()after hiding nodes emitted(,B)and,,phantom tips; a taxon namedrootwas dropped; an unnamed internal node threw.)are kept; an unlabeled internal node no longer getsbootstrap_values = ''(which read as support 0);type: 'nhx'enables bracket delimiters; NHX keys that collide with node fields are stored asnhx_<key>..mapon single elements, wrong return shape, hard-codednex:prefix). It parses now; tip names come from OTU labels.if (DOMParser)threw aReferenceErrorin Node; unnamed clades brokegetNewick;@branch_lengthattributes were ignored and every branch got an invented0.01.TREEstatements andTRANSLATEblocks are handled (split outside quotes and[comments], so a quoted label may contain;or,); lowercase keywords work; a missing TREES block returns an error instead of throwing.extractDates()with the default getter returned no dates (it checked'name' in nodeinstead ofnode.data.name).Metrics and clustering (
src/metrics/*,src/clustering/*)computeMidpointnever resetmax_pathbetween calls;rootToTip/fitRootToTipgaveNaNor threw on fewer than two dated tips or a single-node tree;fitRootToTipfitted the current root from a field only the other-root pass sets, so its baseline fit was alwaysNaNand the current root could never be chosen; candidates were also compared against 0 rather than the current root's fit;centerOfTreedivided 0/0 on zero-length branches;sackinused staledepthafter a reroot;pairwiseDistancescrashed on a single-node tree.clusterPickerandphyloparttreated an unlabeled internal node as support 0 instead of missing;clusterPickervalidates its thresholds (the README example passed an options object it never accepted).phylopartadded the last child's branch to every root-to-leaf path, and its histogram bin index was not clamped.Behavior changes to note in the release
phylopartontest/data/EU3031.txtfinds 300 clusters; it found 297 because of the root-path bug. The test is updated.0.01branch length; lengthless trees fall back to length 1 like Newick.getNewick()preserves root labels and a taxon namedroot.clusterPickerthrows on a non-numericbootstrap_thresholdor a negative or non-numericdiameter_threshold. Numeric strings are still accepted.normalizeBranchLengths()andscaleBranchLengths()with a custom accessor write the results intodata.attributeand restore the default accessor, since a custom accessor cannot be written through.initial-setsis applied once per tree; a secondrender()of the same tree with differentinitial-setsdoes not re-apply them.fitRootToTipreturns{ root, fit: null }when no root has a finite fit: fewer than two dated tips, all dates identical, or zero/infinite distances everywhere. A current root without a fit no longer stops the search for a better one. Undated tips (decimal_date_valueundefined, null or'') count as missing; numeric strings are accepted.getBranchLengths(),getTipLengths(),hasBranchLengths()and every metric read throughbranch_length_accessor. Assigning thebranch_lengthfield directly no longer affects them; usesetBranchLength(). On a tree with no branch lengths,getBranchLengths()reports the constructor's fallback of 1 per branch instead ofundefined.mrca()returnsundefinedwhen a requested name is absent (it returned the root), matches leaf names only, and no longer caches onnode.data.mrca.loadAnnotations(tree, label, …)stores underlabel(it always stored under"test");parseAnnotations()returns an empty{dimensions, format, matrix}structure instead of''when there is no DATA block.clusterPickeracceptsInfinityas an unbounded diameter;NaNor a negative diameter throws.Not fixed
translate(NaN,NaN); the linear layout is fixed.getNewick()cannot distinguish a real taxon labelrooton the root node from the parser's implicitrootname; the root's label is dropped in that one case, as on master.computeMidpointthrows on a one-node tree;deleteANodeon the only child of a unary node throws; deleting a node drops the connecting branch length rather than adding it to the sibling.Checks
yarn build, 796/796 tests,yarn lint(0 errors; 12 warnings, down from 14),yarn typecheck.{json}without anerrorfield, the NEXUS splitter broke quoted labels containing;,fitRootToTipreturned a non-null fit for undated tips, andclusterPickerrejectedInfinity.setBranchLength,update()) and that the public API is unchanged apart from the behavior changes listed above.