{"id":17220735,"url":"https://github.com/lokeshh/numru","last_synced_at":"2025-06-20T14:32:36.352Z","repository":{"id":89253258,"uuid":"121948434","full_name":"lokeshh/numRu","owner":"lokeshh","description":"NumPy for RUby = NumRu","archived":false,"fork":false,"pushed_at":"2020-10-11T15:50:22.000Z","size":21,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T09:04:04.904Z","etag":null,"topics":["hacktoberfest","numpy","python","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lokeshh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-18T12:09:24.000Z","updated_at":"2025-02-16T02:11:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e3b8d77-868e-4b01-a21e-38ae5e6d7c88","html_url":"https://github.com/lokeshh/numRu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lokeshh/numRu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokeshh%2FnumRu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokeshh%2FnumRu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokeshh%2FnumRu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokeshh%2FnumRu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lokeshh","download_url":"https://codeload.github.com/lokeshh/numRu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokeshh%2FnumRu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260961648,"owners_count":23089260,"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":["hacktoberfest","numpy","python","ruby"],"created_at":"2024-10-15T03:53:00.604Z","updated_at":"2025-06-20T14:32:31.339Z","avatar_url":"https://github.com/lokeshh.png","language":"Ruby","readme":"# NumRu (NumPy in Ruby)\n\nNumRu is adoption of NumPy in Ruby. The aim is not just to port NumPy to Ruby but to adopt it to Ruby syntax and ease.\n\n## Installation\n\n1. You need Python 2 for this to work. It uses `rubypython` which currently only works for Python 2 but work is underway to make it work for Python 3.\n\n2. Install `numpy` package for Python.\n\n3. Add this line to your application's Gemfile:\n\n```ruby\ngem 'numru'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install numru\n\n## Usage\n\n1. Whatever works in NumPy works here. If there's something that doesn't work let me know in the issues.\n```rb\nrequire 'numru'\nnr = NumRu\n\n\u003e x = nr.array 0..10\n=\u003e array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10])\n\n\u003e x = nr.arange(27).reshape 3, 3, 3\n=\u003e array([[[ 0,  1,  2],\n        [ 3,  4,  5],\n        [ 6,  7,  8]],\n\n       [[ 9, 10, 11],\n        [12, 13, 14],\n        [15, 16, 17]],\n\n       [[18, 19, 20],\n        [21, 22, 23],\n        [24, 25, 26]]])\n\n```\n2. Keyword arguments are not supported. For that use hash instead.\n```rb\n\u003e x = nr.array [1, 2, 3], dtype: :complex\n=\u003e array([1.+0.j, 2.+0.j, 3.+0.j])\n\n\u003e x = nr.array [1, 2, 3], dtype: nr.int32\n=\u003e array([1, 2, 3], dtype=int32)\n```\n3. Indexing is similar to numpy except it use Ruby Range instead of Python Slice\n```rb\n\u003e x = nr.array(20.times.map { |i| i**2 }).reshape 4, 5\n=\u003e array([[  0,   1,   4,   9,  16],\n       [ 25,  36,  49,  64,  81],\n       [100, 121, 144, 169, 196],\n       [225, 256, 289, 324, 361]])\n\u003e x[0]\n=\u003e array([[ 0,  1,  4,  9, 16]])\n\u003e x[[0, 1]]\n=\u003e array([[ 0,  1,  4,  9, 16],\n       [25, 36, 49, 64, 81]])\n\u003e x[0..1]\n=\u003e array([[ 0,  1,  4,  9, 16],\n       [25, 36, 49, 64, 81]])\n\u003e x[0..-1, -1]\n=\u003e array([ 16,  81, 196, 361])\n\u003e x[0..-1, -2..-1]\n=\u003e array([[  9,  16],\n       [ 64,  81],\n       [169, 196],\n       [324, 361]])\n\n```\n4. Slicing is supported too but it has to be wrapped inside quotes\n```rb\n\u003e x = nr.arange(25).reshape(5, 5).T\n=\u003e array([[ 0,  5, 10, 15, 20],\n       [ 1,  6, 11, 16, 21],\n       [ 2,  7, 12, 17, 22],\n       [ 3,  8, 13, 18, 23],\n       [ 4,  9, 14, 19, 24]])\n\u003e x['::', '::-1']\n=\u003e array([[20, 15, 10,  5,  0],\n       [21, 16, 11,  6,  1],\n       [22, 17, 12,  7,  2],\n       [23, 18, 13,  8,  3],\n       [24, 19, 14,  9,  4]])\n\u003e x[':3', ':3']\n=\u003e array([[ 0,  5, 10],\n       [ 1,  6, 11],\n       [ 2,  7, 12]])\n\n```\n5. Operators work the way you expect\n```rb\n\u003e x = nr.array 1..5\n=\u003e array([1, 2, 3, 4, 5])\n\u003e x \u003e 3\n=\u003e array([False, False, False,  True,  True])\n\u003e x == 3\n=\u003e array([False, False,  True, False, False])\n\u003e x * 2\n=\u003e array([ 2,  4,  6,  8, 10])\n\u003e x * x\n=\u003e array([ 1,  4,  9, 16, 25])\n\u003e x % 3\n=\u003e array([1, 2, 0, 1, 2])\n\n```\n\n## In development\n\nThe motive is not just to build a wrapper for NumPy but to adapt it to Ruby.\n\nRough plan\n\n1. Provide all numpy functionality\n2. Provide `map`, `each`, etc.\n3. TODO: Think and discuss how to rubify the API\n\n## Contributing\n\n* To report bugs please create an issue [here](https://github.com/lokeshh/numRu/issues)\n* If you have fixed a bug, then please create a PR [here](https://github.com/lokeshh/numRu/pulls). While creating a PR please follow [contributing guidelines](CONTRIBUTING.md)\n\nNote - This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Numru project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/numru/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokeshh%2Fnumru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flokeshh%2Fnumru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokeshh%2Fnumru/lists"}