* feat: add configurable SMTP HELO hostname Allow the SMTP HELO/EHLO hostname to be configured separately from the SMTP server hostname. This is useful when the SMTP server requires clients to identify themselves with a fully qualified hostname different from the server address. * chore: remove vendored dependency changes * Bump go-pkgz/notify to v1.4.0 and document SMTP_HELO_HOST The HELOHost field lands in go-pkgz/notify v1.4.0, so the branch needs the bump to compile; v1.3.0 in master has no such field. The example module is tidied alongside, as any change to backend/go.mod requires. Documents the parameter in the parameters table and, separately, in the email setup page: what it does, that leaving it unset keeps the previous `localhost` greeting, and the case it exists for, a relay refusing the greeting under Postfix `reject_non_fqdn_helo_hostname`. Also records the current limit: verification emails for email authentication go through go-pkgz/auth's own sender, which has no equivalent setting, so the greeting there is unchanged. * Bump go-pkgz/auth to v2.2.0 and apply SMTP_HELO_HOST to verification email The verification email sender had no way to set the greeting, so a relay that refuses the HELO would accept notifications and still reject sign-in emails. EmailParams gains HELOHost in go-pkgz/auth v2.2.0, so the same SMTP_HELO_HOST now drives both paths. The example module is tidied alongside, as any change to backend/go.mod requires. --------- Co-authored-by: oli <someone@somewhere.tld> Co-authored-by: Dmitry Verkhoturov <paskal.07@gmail.com>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package stats
|
|
|
|
import "sort"
|
|
|
|
// Histogram calculates the histogram of a slice using the given
|
|
// number of equal-width bins over [min, max], returning the count
|
|
// of values in each bin along with the bins+1 bin edges. Each bin
|
|
// is half-open [edges[i], edges[i+1]) except the last, which also
|
|
// includes the maximum value.
|
|
func Histogram(input Float64Data, bins int) ([]int, []float64, error) {
|
|
|
|
if input.Len() == 0 {
|
|
return nil, nil, ErrEmptyInput
|
|
}
|
|
|
|
if bins < 1 {
|
|
return nil, nil, ErrBounds
|
|
}
|
|
|
|
// Disregard errors, since input is not empty
|
|
min, _ := Min(input)
|
|
max, _ := Max(input)
|
|
|
|
// Expand the range by 0.5 on each side like
|
|
// numpy when all of the values are equal
|
|
if min == max {
|
|
min -= 0.5
|
|
max += 0.5
|
|
}
|
|
|
|
// Build bins+1 equal-width bin edges from min to max
|
|
width := (max - min) / float64(bins)
|
|
edges := make([]float64, bins+1)
|
|
for i := range edges {
|
|
edges[i] = min + width*float64(i)
|
|
}
|
|
edges[bins] = max
|
|
|
|
// Count each value into the last bin whose left
|
|
// edge does not exceed it, so the maximum value
|
|
// lands in the final closed bin
|
|
counts := make([]int, bins)
|
|
for _, v := range input {
|
|
i := sort.Search(len(edges), func(i int) bool { return edges[i] > v }) - 1
|
|
if i == bins {
|
|
i--
|
|
}
|
|
counts[i]++
|
|
}
|
|
|
|
return counts, edges, nil
|
|
}
|
|
|
|
// Histogram returns the counts and equal-width bin edges of the data
|
|
func (f Float64Data) Histogram(bins int) ([]int, []float64, error) {
|
|
return Histogram(f, bins)
|
|
}
|