[go: nahoru, domu]

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

backported ind2sub and sub2ind. #683

Merged
merged 6 commits into from
Jun 7, 2016
Merged

backported ind2sub and sub2ind. #683

merged 6 commits into from
Jun 7, 2016

Conversation

nilayjain
Copy link
Member

No description provided.

{
arma::mat A = arma::randu(5,5);
arma::uvec u = arma::ind2sub(arma::size(A), 3);
u.print();
Copy link
Member
@rcurtin rcurtin Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this test doesn't actually test anything in the code, do you think that we can test the output with BOOST_REQUIRE_EQUAL? I don't know what the output values of u are supposed to be, but maybe something like

BOOST_REQUIRE_EQUAL(u(0), 0);
BOOST_REQUIRE_EQUAL(u(1), 3);

Technically I don't think we need to test Armadillo support since Armadillo should already be testing that, but, one nice thing this test does do is ensure that ind2sub() compiles correctly. If you like, we can also add a very simple test like this for sub2ind().

@nilayjain
Copy link
Member Author

Now the test checks whether ind2sub and sub2ind work as they are supposed to.

@rcurtin rcurtin merged commit b29bad9 into mlpack:master Jun 7, 2016
@nilayjain
Copy link
Member Author

Why did travis show this totally unrelated error?

@rcurtin
Copy link
Member
rcurtin commented Jun 7, 2016

Travis runs all of the tests, and some of the mlpack tests are probabilistic so they have a nonzero chance of failing. We try to keep the probability of failure acceptably low but sometimes we have not kept it low enough so sometimes Travis builds a test and it is unlucky and fails. I generally only care about Travis output insofar that it builds successfully and the relevant tests to the PR are passing.

// images (3), boundaries (1), segmentations (1).
int loop_iter = num_images * 5;
size_t row_idx = 0;
int col_i = 0, col_s = 0, col_b = 0;
Copy link
Contributor
@stereomatchingkiss stereomatchingkiss Jun 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use size_t maybe is a better choice, since this type guarantee it is large enough for the index of array. Besides, if the value would not change in the future, I think they are good candidates to become const

rgb2xyz(0,0) = 0.430574; rgb2xyz(0,1) = 0.430574; rgb2xyz(0,2) = 0.430574;
rgb2xyz(1,0) = 0.430574; rgb2xyz(1,1) = 0.430574; rgb2xyz(1,2) = 0.430574;
rgb2xyz(2,0) = 0.430574; rgb2xyz(2,1) = 0.430574; rgb2xyz(2,2) = 0.430574;

Copy link
Contributor
@stereomatchingkiss stereomatchingkiss Jun 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this one is easier to read and write

arma::mat rgb2xyz(3,3);
rgb2xyz = 0.430574;

Are you sure all of the value of the matrix are same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No values are not same, i forgot to initialize them. i will correct it.

@stereomatchingkiss
Copy link
Contributor

I read all of the codes before Gradient, write down some opinions and ideas, you can take it as reference if you like. Will read the other part on next week. Thanks for the contributions, this class is quite hard to implement.

@nilayjain
Copy link
Member Author

You're welcome. I'll try to incorporate the changes you suggested along with the tests for these functions and file an updated PR as soon as possible. Thank You for your analysis. :)

@rcurtin
Copy link
Member
rcurtin commented Jun 9, 2016

I wonder why all the comments came to this PR but none of the changes that were being commented on were part of this PR? I guess once a new PR is filed this will not be a problem. :)

@stereomatchingkiss
Copy link
Contributor

I wonder why all the comments came to this PR but none of the changes that were being commented on were part of this PR?

Oh my god, you are right. The pull request was revert already.....

Installing ubuntu on my old laptop, I hope mlpack could be quite easy to build on ubuntu.

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.

4 participants