{"id":13713529,"url":"https://github.com/Kunde21/numgo","last_synced_at":"2025-05-06T23:32:20.266Z","repository":{"id":57514020,"uuid":"47018519","full_name":"Kunde21/numgo","owner":"Kunde21","description":"n-dimensional array implementation in Go.","archived":false,"fork":false,"pushed_at":"2017-01-08T02:57:17.000Z","size":190,"stargazers_count":28,"open_issues_count":4,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-07T07:03:39.772Z","etag":null,"topics":["array","go","multi-dimensional"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kunde21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-28T09:59:41.000Z","updated_at":"2024-07-25T14:42:12.000Z","dependencies_parsed_at":"2022-09-19T05:40:23.164Z","dependency_job_id":null,"html_url":"https://github.com/Kunde21/numgo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunde21%2Fnumgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunde21%2Fnumgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunde21%2Fnumgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kunde21%2Fnumgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kunde21","download_url":"https://codeload.github.com/Kunde21/numgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224547006,"owners_count":17329413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","go","multi-dimensional"],"created_at":"2024-08-02T23:01:38.775Z","updated_at":"2024-11-14T00:30:41.946Z","avatar_url":"https://github.com/Kunde21.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# numgo [![GoDoc](https://godoc.org/github.com/Kunde21/numgo?status.svg)](https://godoc.org/github.com/Kunde21/numgo) [![Build Status](https://travis-ci.org/Kunde21/numgo.svg?branch=master)](https://travis-ci.org/Kunde21/numgo) [![Go Report Card](https://goreportcard.com/badge/github.com/Kunde21/numgo)](https://goreportcard.com/report/github.com/Kunde21/numgo) [![codecov.io](https://codecov.io/github/Kunde21/numgo/coverage.svg?branch=master)](https://codecov.io/github/Kunde21/numgo?branch=master)\n\nAn n-dimensional array package implemented in Go.  \n\nNote:  Under heavy development.  API will not stabilize until v0.1 tag.\n\n## Installation \n\n```\ngo get github.com/Kunde21/numgo\n```\n\n## Using numgo\n\nMost of the functionality resembles numpy's API, with some changes to work with Go's type system.  \n\n```go\nvar array := numgo.NewArray64(nil,/*array shape*/1,2,3)\t// This will be filled with zeros by default\nvar arange := numgo.Arange(100)                         // Simple 1-D array filled with incrementing numbers\narange.Reshape(2,5,10)                                  // Changes the shape from 1-D to 3-D\narange.Mean(2)                                          // Mean across axis 2, returning a 2-D (2x5) array\narange.Sum()                                            // An empty call operates over all data on all axes\n```\n\nAny formula can be created and mapped onto one or more axes within the array:\n\n```go\n\t// Create a FoldFunc\n\tcountNaNFn := func(input []float64) float64 {\n\t   var i float64 :=0\n\t       for _,v := range input {\n\t       \t       if math.IsNaN(v) {\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\treturn i\n\t}\n\n\t// Pass it into the Fold method and give it any number of axes to fold over\n\n\t// Returns an n-dimensional array object \n\t// with the count of NaN values on 2nd and 4th axes. (0-based axis count)\n\tarray.Fold(countNaNFn, 2,4) \n\t// No axes operates over all data on all axes\n\tarray.Fold(countNanfn)\n```\n\n## Function chaining\n\nnumgo is designed to allow chaining of functions, to allow different actions on different axes and at different points in the calculation.  Errors are maintained by the object and can be checked and handled using `HasErr()` or `GetErr()`:\n\n```go\n\t// Errors are not handled on each call, \n\t// but, instead, can be checked and handled after a block of calculations\n\tng := numgo.Arange(100).Reshape(2,5,10).Mean(2).Min(1).Max()\n\t\n\t// Non-allocating style\n\tif ng.HasErr() {\n\t   log.Println(ng.GetErr())  // GetErr() clears the error flag\n\t }\n\t   \n\t // Allocation style\n\tif err = ng.GetErr(); err != nil {  \n\t\tlog.Println(err)\n\t}\n\t// ng.GetErr() will always return nil here, \n\t// so avoid stacking this type of error handling \n```\n\n## Debugging option\n\nDebugging can be enabled by calling `numgo.Debug(true)`.  This will give detailed error strings and stack traces by using `GetDebug()` instead of `GetErr()`.  This makes debugging chained method calls much easier.\n\n```go\n\tnumgo.Debug(true)\n\tnilp := new(Array64)\t\t// Forgot to inintialize the array.\n\t\n\tnilp.Set(12, 1,4,0).AddC(2).DivC(6).At(1,4,0)\n\tif nilp.HasErr(){\n\t\terr, debug, trace := nilp.GetDebug()\n\t\t// Prints generic error: \"Nil pointer received.\"\n\t\tfmt.Println(err)\n\t\t// Prints debug info: \"Nil pointer received by GetDebug().  Source array was not initialized.\"\n\t\tfmt.Println(debug)\n\t\t// Prints stack trace for the call to GetDebug()\n\t\tfmt.Println(trace)\n\t}\n\n\tresz := NewArray64(nil, 2, 5)   // 2-D (2x5) array of zeros\n\t\n\t// Reshape would change the capacity of the array, which should use Resize\n\tresz.AddC(10).DivC(2).Reshape(3,3).Mean(1)  \n\n\tif resz.HasErr() {\n\t   \terr, debug, trace := resz.GetDebug()\n\t\t// Prints generic error: \"New shape cannot change the size of the array.\"\n\t\tfmt.Println(err)\n\t\t// Prints debug info: \"Reshape() cannot change data size.  Dimensions: [2,5] reshape: [3,3]\"\n\t\tfmt.Println(debug)\n\t\t// Prints stack trace for the call to Reshape()\n\t\tfmt.Println(trace)\n\t}\n\n```\n\n## Contributions\n\nIf you have any suggestions, corrections, bug reports, or design ideas please create an issue so that we can discuss and improve the code.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKunde21%2Fnumgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKunde21%2Fnumgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKunde21%2Fnumgo/lists"}