40 points · by anonfunction · 11y ago · 22 comments
Otherwise, nice to see someone take quality serious. :)
# Generate coverage data
go test -coverprofile=coverage.out
# View coverage by function
go tool cover -func="coverage.out"
# View coverage line by line
go tool cover -html="coverage.out"I think the biggest thing to do is finalize the public API and release v1.0.0. I started with only functions but have since added types, so I'd like to figure out if I should support both or stick to one or the other. I have a feeling I could use an Interface to make stats work for both []float64 and []int but I'm not sure about that.
Another thing I'd like to do is add more test suites, I know they are out there for more mature statistics packages in other languages that could be ported to Go.
Speaking of mature packages, I think the Gnu GSL Statistics[1] could be a good roadmap for future functionality and API design decisions.
1. http://www.gnu.org/software/gsl/manual/html_node/Statistics....
Thank you anonfunction et. al. for your sharing the fruits of your labor with us! :D
gonum/floats for max, min, round, sum, etc.
gonum/stat for mean, std, variance, etc.
gonum/stat/sample for sampling without replacement
I started with only []float64 but wanted to allow stuff like this:
func getData() []float64 {
// Do stuff to get the data and
// store it in var data []float64
return data
}
var d Float64Data = getData()
fmt.Println(d.Max())
1. https://github.com/montanaflynn/stats/blob/master/examples/m...2. https://github.com/montanaflynn/stats/blob/master/examples/m...
Documentation can be found in godoc, i.e. godoc.org/github.com/gonum/stat, godoc.org/github.com/gonum/matrix/mat64, etc.
1. https://github.com/montanaflynn/stats/commit/a3efee7551d14a9...
Is returning error common in go (as opposed to raising)?
1. https://gobyexample.com/errors
2. http://dave.cheney.net/2012/01/18/why-go-gets-exceptions-rig...
Go has panics, which are pretty much the same thing as exceptions in other languages (the details of how they are used are slightly different from, say, Java/Python/Ruby exceptions, but much more than, say, Perl 6 exceptions.)
Go has a strong stylistic recommendation not to expose panics to external consumers of code, and it is idiomatic to instead use error returns from publicly-exposed library code. But "Go doesn't have exceptions" is mostly misleading.
> no exceptions
1. http://commandcenter.blogspot.pt/2012/06/less-is-exponential...
It's worded too strongly perhaps. While `panic` behavior is similar to `java.lang.Exception`, it is not idiomatic to panic on problems like IOException/SQLException. They are detected by return codes to be handled immediately, rather than a broad swath of code wrapped in `try`.
This in Java:
try
code
code
code
catch errA
handle
catch errB
handle
catch errC
handle
Would be this in Go: code
handle errA
code
handle errB
code
handle errC
It's fair to say "Go doesn't use exceptions" since Go doesn't use panics for common error handling.