ones (1, x) != repmat (1, 1, x)

John W. Eaton jwe at octave.org
Tue Jul 21 11:54:26 CDT 2009


On 21-Jul-2009, Jaroslav Hajek wrote:

| I think assert should simply offer a range of tests, and the test for
| exact match (i.e., incl. typeinfo) is certainly useful.
| It justs so happens that the default test (no options) is the
| strictest one, which may sometimes require knowledge of Octave
| internals (I think typeinfo is internal) to understand what's going
| on, and that is maybe not a very favorable situation. Especially if we
| consider that assert may be useful not only in test blocks, but also
| in user code, where most users will be surprised by
| assert (2*linspace (1, 5, 5), 2*(1:5)) # fails
| assert (zeros (0, 0), []) # fails
| assert (2*ones (1, 5), (2) (ones (1,5))) # fails
| 
| all these used to pass in earlier versions, and now fail due to
| optimizations or other modifications. I think it's not a good behavior
| for the default test in assert. The default test should provide a test
| that is reasonably strict yet is unlikely to change due to changes in
| Octave's internals, which is what I attempted to. I think most
| existing tests actually don't need the strict checking, except certain
| cases like diag-perm tests etc.

OK, I think the change is OK.  I don't think it is necessary to
provide a new function (or option) that preserves the old behavior,
but the change should be noted in the NEWS file.

jwe



More information about the Bug-octave mailing list