NumRu (NumPy in Ruby)

NumRu 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.

Installation

  1. 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.

  2. Install numpy package for Python.

  3. Add this line to your application's Gemfile:

gem 'numru'

And then execute:

$ bundle

Or install it yourself as:

$ gem install numru

Usage

  1. Whatever works in NumPy works here. If there's something that doesn't work let me know in the issues. ```rb require 'numru' nr = NumRu

x = nr.array 0..10 => array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

x = nr.arange(27).reshape 3, 3, 3 => array([[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]],

   [[ 9, 10, 11],
    [12, 13, 14],
    [15, 16, 17]],

   [[18, 19, 20],
    [21, 22, 23],
    [24, 25, 26]]])
Keyword arguments are not supported. For that use hash.
```rb
> x = nr.array [1, 2, 3], dtype: :complex
=> array([1.+0.j, 2.+0.j, 3.+0.j])

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lokeshh/numru. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Numru project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.