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

Cannot index the second last row of appended values #3

Open
AndreyDiDev opened this issue May 18, 2019 · 2 comments
Open

Cannot index the second last row of appended values #3

AndreyDiDev opened this issue May 18, 2019 · 2 comments

Comments

@AndreyDiDev
Copy link

If irises is an array with rows of values which are being appended constantly, then I should be able to index the second last row of the appended values with [-2] or even [0][-2]. But when I try to it fetches an error that the array is not big enough (although it is (2,2)). I have tried all sorts of indexing methods none of which index the second to last row, they only index the last row. I have also tried different ways of appending the values to the array, none of which I had success with. If you happen to know how I can index the second last row appended onto the irises or a different appending method, it would be appreciated if you can help me out!

@guy881
Copy link
Owner

guy881 commented May 21, 2019

Hmm, irises[-2] works well for me. Keep in mind that irises is numpy.ndarray for some reason.

Have a look at screenshot from my IDE debugging session. I added a note to readme, this code was intended to be run on Python 2.7, I also added requirements.txt, as there is a mess with opencv versions. Hope that you'll find this helpful.

image

@AndreyDiDev
Copy link
Author

Thanks for the quick response! Your results are precisely what I am trying to index, but how do I put the expression into the code? In other words, how do I translate the self.irises[-2] into code? (Note: I am running it on python 3.7, if it makes a difference) Having tried [-2] it gives me [[271.49973 324.8698 ]
[318.79807 332.70883]]-the whole array(print(irises) and [271.49973 324.8698 ]-(print(irises[-2]), it seems it indexes the wm element? And [0] also indexes the wm, so I think the first indexing number indexes one of the elements. For instance, [0] indexes wm and [1] indexes hm. The second indexing number seems to index one of the columns of the previously selected element. So [0][1] indexes the wm element and the second column. The question is how do I get around this problem? You do have an intriguing way of approaching this problem, but again I am confused as to how to implement it in the code? Would you happen to know? Thanks again for your guidance!

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

No branches or pull requests

2 participants