Skip to content

Instantly share code, notes, and snippets.

@lokeshh
Last active June 11, 2016 20:15
Show Gist options
  • Select an option

  • Save lokeshh/cfb01ff54845e09968f9625bd64965d7 to your computer and use it in GitHub Desktop.

Select an option

Save lokeshh/cfb01ff54845e09968f9625bd64965d7 to your computer and use it in GitHub Desktop.
[1] pry(main)> dv = Daru::Vector.new ['third', 'third', 'first', 'second'], type: :category
=> #<Daru::Vector(4)>
0 third
1 third
2 first
3 second
[2] pry(main)> dv.order
=> ["third", "first", "second"]
[3] pry(main)> dv.order = ['first', 'second', 'thrd']
ArgumentError: The contents of new and old order must be the same.
from /home/ubuntu/workspace/daru/lib/daru/category.rb:124:in `order='
[4] pry(main)> dv.order = ['first', 'second', 'third']
=> ["first", "second", "third"]
[5] pry(main)> dv.sort!
ArgumentError: Can not apply sort when vector is unordered
from /home/ubuntu/workspace/daru/lib/daru/category.rb:238:in `assert_ordered'
[6] pry(main)> dv.ordered = true
=> true
[7] pry(main)> dv.sort!
=> #<Daru::Vector(4)>
2 first
3 second
0 third
1 third
[9] pry(main)> dv.eq 'third'
=> #<Daru::Core::Query::BoolArray:10944520 bool_arry=[false, false, true, true]>
[10] pry(main)> dv.where(dv.mt 'first')
=> #<Daru::Vector(3)>
3 second
0 third
1 third
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment