To test relative imports before installing a package, add the source code directory to the path.
For example, import code from a file functions.py in src/mypackage/
import sys
sys.path.append('/Users/username/project/src/')
import mypackage.functions as f
Converting a ranking into a set of normally distributed scores.
rank2score <- function(rank, n_total, mn = 0, std = 1, n_tied = 1) {
# following the equal area method
# http://node101.psych.cornell.edu/Darlington/transfrm.htm
mean_rank <- rank / n_tied
qnorm(mean_rank / (n_total + 1), mean = mn, sd = std)
}
Counting the number of posts and different terms per taxonomy in Hugo requires looping through all
taxonomies.
{{ range $taxname, $tax := .Site.Taxonomies }}
{{ $nposts := len (where $.Site.RegularPages (print "Params" "." $taxname) "ne" nil) }}
{{ $nterms := len $tax }}
{{ $posttext := cond (gt $nposts 1) "posts" "post" }}
{{ $termtext := cond (gt $nterms 1) "terms" "term" }}
{{ $taxname }}: {{ $nposts }} {{ $posttext }} and {{ $nterms }} search {{ $termtext }}.
<br>
{{ end }}