Skip to content

Commit

Permalink
v2.1.4
Browse files Browse the repository at this point in the history
Changes:

1. Performance:

  - Reimplement some internals of the packing algorithm to avoid
    consuming the string pool in documents with many trees. (We're about
    10\% slower now, but (depending on the document) the memory usage
    can drop up to five times!)

2. Bugfixes:

  -  Fix aggregate function `count`.

  - Provide a workaround for a PGF bug: for coordinate-shaped nodes,
    `\positionnodelater` provides dimensions with `pt` in a wrong
    catcode, so `max y` and friends did not work for such nodes.
  • Loading branch information
sasozivanovic committed Feb 2, 2017
1 parent 2a7e389 commit ac0bd11
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 86 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LaTeX package: forest [2017/01/27 v2.1.3 Drawing (linguistic) trees]
LaTeX package: forest [2017/02/02 v2.1.4 Drawing (linguistic) trees]

Copyright (c) 2012-2017 Saso Zivanovic
(Sa\v{s}o \v{Z}ivanovi\'{c})
Expand Down
18 changes: 18 additions & 0 deletions forest-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6409,7 +6409,25 @@ \subsection{Changelog}
\subsubsection{v2.1}

\begin{description}
\item[v2.1.4 (2017/02/02)] \mbox{}

Performance:
\begin{itemize}
\item Reimplement some internals of the packing algorithm to avoid consuming the string pool in
documents with many trees. (We're about 10\% slower now, but (depending on the document) the
memory usage can drop up to five times!)
\end{itemize}

Bugfixes:
\begin{itemize}
\item Fix aggregate function \index{aggregate>count}.
\item Provide a workaround for a PGF bug: for coordinate-shaped nodes, |\positionnodelater|
provides dimensions with |pt| in a wrong catcode, so \index{max y} and friends did not work for
such nodes.
\end{itemize}

\item[v2.1.3 (2017/01/27)] \mbox{}

Bugfixes:
\begin{itemize}
\item Update \index{nice empty nodes} to use \index{for step=\index{current and siblings}}.
Expand Down
106 changes: 106 additions & 0 deletions forest-test.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,49 @@
\usepackage[margin=1cm,landscape,twocolumn]{geometry}
\usepackage{forest}

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

\parindent 0pt

\makeatletter

\def\testmacro#1#2{% #1 = result, #2 = expected
\def\test@result{#1}%
\def\test@expected{#2}%
\ifx\test@result\test@expected
{#1}%
\else
{\textcolor{red}{#1} (expected: #2)}%
\fi
}

\newcount\test@result@count
\newcount\test@expected@count
\def\testcount#1#2{% #1 = result, #2 = expected
\test@result@count=#1\relax
\test@expected@count=#2\relax
\ifnum\test@result@count=\test@expected@count
{#1}%
\else
{\textcolor{red}{#1} (expected: #2)}%
\fi
}


\newdimen\test@result@dimen
\newdimen\test@expected@dimen
\def\testdimen#1#2{% #1 = result, #2 = expected
\test@result@dimen=#1\relax
\test@expected@dimen=#2\relax
\ifdim\test@result@dimen=\test@expected@dimen
{#1}%
\else
{\textcolor{red}{#1} (expected: #2)}%
\fi
}


\begin{document}

\section{Is it a number or dimension?}
Expand Down Expand Up @@ -130,4 +171,69 @@ \section{Is it a number or dimension?}
\\\testnumdim{dim}{4. 2cm}{false}
\\\testnumdim{dim}{ 4.2 cm }{true}

\section{Aggregate functions}
\label{sec:aggregate-functions}

\begin{forest}(stages={
for root'={
process keylist=given options,
TeX={%
\def\forestdebugtypeouttreenodeinfo{\forestoption{content}}%
{\tt\forestdebug@typeouttree\forest@cn\temp\temp\\}
},
%
tempcounta/.count=children,
TeX/.process=Rw{tempcounta}{Number of root's children: \testcount{##1}{3}\\},
%
tempcounta/.sum={>O+n{content}}{tree},
TeX/.process=Rw{tempcounta}{Sum of all nodes: \testcount{##1}{21}\\},
%
tempcounta/.average={>O+n{content}}{fake=2,1n},
TeX/.process=Rw{tempcounta}{Average (rounded) of bottom nodes: \testcount{##1}{5}\\},
%
tempcounta/.product={>O+n{content}}{fake={21},current and ancestors},
TeX/.process=Rw{tempcounta}{Product from root to 5: \testcount{##1}{15}\\},
%
tempcounta/.min={>O+n{content}}{tree},
TeX/.process=Rw{tempcounta}{Minimum in tree: \testcount{##1}{1}\\},
%
tempcounta/.max={>O+n{content}}{tree},
TeX/.process=Rw{tempcounta}{Maximum in tree: \testcount{##1}{6}\\},
%
TeX={Again: now interpret content as dimensions in points.\\},
tempdima/.sum={>O+n{content}}{tree},
TeX/.process=Rw{tempdima}{Sum of all nodes: \testdimen{##1}{21pt}\\},
%
tempdima/.average={>O+n{content}}{fake=2,1n},
TeX/.process=Rw{tempdima}{Average (rounded) of bottom nodes: \testdimen{##1}{5.5pt}\\},
%
tempdima/.product={>O+n{content}}{fake={21},current and ancestors},
TeX/.process=Rw{tempdima}{Product from root to 5: \testdimen{##1}{15pt}\\},
%
tempdima/.min={>O+n{content}}{tree},
TeX/.process=Rw{tempdima}{Minimum in tree: \testdimen{##1}{1pt}\\},
%
tempdima/.max={>O+n{content}}{tree},
TeX/.process=Rw{tempdima}{Maximum in tree: \testdimen{##1}{6pt}\\},
%
TeX={Sums again. Now sum using pgfmath:\\},
temptoksa/.sum={content}{tree},
TeX/.process=Rw{temptoksa}{Assign to toks: \testmacro{##1}{21.0}\\},
tempdima/.sum={content}{tree},
TeX/.process=Rw{tempdima}{Assign to dimen: \testdimen{##1}{21pt}\\},
tempcounta/.sum={content}{tree},
TeX/.process=Rw{tempcounta}{Assign to count: \testcount{##1}{21}\\},
}
})
[1
[2]
[3
[5]
[6]
]
[4]
]
\end{forest}


\end{document}
Loading

0 comments on commit ac0bd11

Please sign in to comment.