{"action":"created","issue":{"url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/71","repository_url":"https://api.github.com/repos/AtheMathmo/rulinalg","labels_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/71/comments","events_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/71/events","html_url":"https://github.com/AtheMathmo/rulinalg/pull/71","id":183279651,"number":71,"title":"Matrix equality assertion","user":{"login":"Andlon","id":578309,"avatar_url":"https://avatars.githubusercontent.com/u/578309?v=3","gravatar_id":"","url":"https://api.github.com/users/Andlon","html_url":"https://github.com/Andlon","followers_url":"https://api.github.com/users/Andlon/followers","following_url":"https://api.github.com/users/Andlon/following{/other_user}","gists_url":"https://api.github.com/users/Andlon/gists{/gist_id}","starred_url":"https://api.github.com/users/Andlon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andlon/subscriptions","organizations_url":"https://api.github.com/users/Andlon/orgs","repos_url":"https://api.github.com/users/Andlon/repos","events_url":"https://api.github.com/users/Andlon/events{/privacy}","received_events_url":"https://api.github.com/users/Andlon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":41,"created_at":"2016-10-16T17:40:35Z","updated_at":"2016-11-16T18:14:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/71","html_url":"https://github.com/AtheMathmo/rulinalg/pull/71","diff_url":"https://github.com/AtheMathmo/rulinalg/pull/71.diff","patch_url":"https://github.com/AtheMathmo/rulinalg/pull/71.patch"},"body":"This pull request is not intended as a candidate for merge (yet).\n\nI'm working on the matrix equality macro mentioned in #67. I added an example in the `examples/` subfolder, which one can run with `cargo run --example mismatched_f64_elements`. See also the small number of tests currently included as well. The example looks like this:\n\n``` rust\n#[macro_use]\nextern crate rulinalg;\n\nfn main() {\n    // The purpose of this example is to demonstrate the type of errors generated\n    // by `assert_matrix_eq!` when the comparison fails (which the below call will).\n    let a = matrix![1.00, 2.00;\n                    3.00, 4.00];\n    let b = matrix![1.01, 2.00;\n                    3.40, 4.00];\n    assert_matrix_eq!(a, b, comp = abs, tol = 1e-8);\n}\n```\n\nand it gives the following output:\n\n```\n     Running `target/debug/examples/mismatched_f64_elements`\nthread 'main' panicked at '\n\nMatrices X and Y have 2 mismatched element pairs. The mismatched elements are listed below, in the format\n(row, col): x = x[[row, col]], y = y[[row, col]].\n\n (0, 0): x = 1, y = 1.01. Error: 0.010000000000000009\n (1, 0): x = 3, y = 3.4. Error: 0.3999999999999999\n\nComparison criterion: absolute difference, defined by\n    |x - y| <= 0.00000001.\n\n', examples/mismatched_f64_elements.rs:11\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n```\n\nNow, I'd like to give people the chance to give some input on how the macro should work. Comparing floating numbers is _seriously hard_. See for example [this famous article](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). A preliminary conclusion is that there is no one-size-fits-all solution for comparing floating point numbers. Hence, it's impossible for us to have a default `assert_matrix_eq!(a, b)` macro that works in all cases. This is why I've opted for explicitly making the user choose which criterion to assert with (the `comp = abs` and `tol = 1e-8` parameters).\n\nHowever, I think we can provide a very conservative default `assert_matrix_eq!(a, b)` macro. I need to think a bit more on exactly how it's going to work, but I have the following in mind:\n1. The default invocation is very strict and conservative.\n2. The user simply writes `assert_matrix_eq!(a, b)` for his/her tests, and this might be fine if the numbers are very close to exactly equal.\n3. However, in the case when the numbers are near but not sufficiently near, the macro will fail.\n4. When the macro fails, the error message should explain the next steps the user should take (ideally by referring to a fleshed out part in the documentation on this) to ensure that he/she is using the correct comparison criteria.\n\nThe reasoning in step 4 again comes back to the fact that a _one-size-fits-all comparison does not exist_. I'm a bit inspired by how `rustc` guides users around compilation failures, by giving error messages that are truly helpful. Hopefully we can do the same for our users (and for our contributors).\n\nCurrently, the macro only supports absolute difference as a comparison criterion, but I want to at least support [ULP](https://en.wikipedia.org/wiki/Unit_in_the_last_place)-based comparison too (probably basing the default criterion on something involving ULP). I also need to write a **lot** more tests, as I hope this could form the cornerstone of future test assertions in rulinalg as a whole, as well as flesh out the documentation much more. Also, there should perhaps be an analogous `assert_vector_eq` macro?\n\nWould really appreciate any opinions, questions, reservations or advice anyone might have!\n"},"comment":{"url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/comments/261025710","html_url":"https://github.com/AtheMathmo/rulinalg/pull/71#issuecomment-261025710","issue_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/71","id":261025710,"user":{"login":"Andlon","id":578309,"avatar_url":"https://avatars.githubusercontent.com/u/578309?v=3","gravatar_id":"","url":"https://api.github.com/users/Andlon","html_url":"https://github.com/Andlon","followers_url":"https://api.github.com/users/Andlon/followers","following_url":"https://api.github.com/users/Andlon/following{/other_user}","gists_url":"https://api.github.com/users/Andlon/gists{/gist_id}","starred_url":"https://api.github.com/users/Andlon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andlon/subscriptions","organizations_url":"https://api.github.com/users/Andlon/orgs","repos_url":"https://api.github.com/users/Andlon/repos","events_url":"https://api.github.com/users/Andlon/events{/privacy}","received_events_url":"https://api.github.com/users/Andlon/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T18:14:27Z","updated_at":"2016-11-16T18:14:27Z","body":"Sure, I can write up an issue with remaining ideas for improvement after we've merged (if I somehow forget, feel free to remind me).\r\n\r\nAs for the `compare` function, I totally agree! It's a bit inverted as it is. Always felt wrong to me. I agree that a `Result<(), ComparisonFailure>` (pseudosyntax) would make more sense. Thanks :)"}}
{"actor":{"display_login":"Andlon"}}