Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #61 , MultiIndex #[] raises error on accessing invalid index #90

Merged
merged 1 commit into from
Apr 3, 2016

Conversation

shreyanshd
Copy link
Contributor

MultiIndex was working with invalid index :

mi = Daru::MultiIndex.from_tuples([ ['a',1,'x'] ,
                                    ['a',1,'y'] , 
                                    ['a',2,'x'] ,
                                    ['b',1,'y'] ,
                                    ['b',1,'z'] ,
                                    ['c',2,'z'] ])
 => Daru::MultiIndex:70139316645780 (levels: [["a", "b", "c"], [1, 2], ["x", "y", "z"]]
labels: [[0, 0, 0, 1, 1, 2], [0, 0, 1, 0, 0, 1], [0, 1, 0, 1, 2, 2]])

Accessing invalid index worked :

mi['p',1]
 => Daru::MultiIndex:70139316743800 (levels: [["a", "b"], [1], ["x", "y", "z"]]
labels: [[0, 0, 1, 1], [0, 0, 0, 0], [0, 1, 1, 2]])

This PR fixes this bug :

mi['p',1]
index.rb:256:in `block in retrieve_from_tuples': Specified index ["p", 1] do not exist (IndexError)
    from index.rb:254:in `each'
    from index.rb:254:in `each_with_index'
    from index.rb:254:in `retrieve_from_tuples'
    from index.rb:235:in `[]'
    from index.rb:373:in `<main>'

@v0dro v0dro merged commit 891c183 into SciRuby:master Apr 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants