Bug #7369

Matrix #row_size, #column_size methods

Added by Boris Stitnicky over 1 year ago. Updated over 1 year ago.

Assignee:Marc-Andre Lafortune
Target version:-
ruby -v:1.9.x Backport:


I believe these methods should be renamed. "row_size" is confusing, because it can be intuitively understood as both "number of rows", and "size along a row" (or size of a matrix row). Same goes for "column size". I would like these methods renamed to unambigous, mnemonic names, such as

#numberofrows alias #height
#numberofcolumns alias #width

I do not insist on the above names. They are just examples of unambigous, mnemonic names. But I insist that "rowsize" and "columnsize" method names impress me as ambiguous.

Associated revisions

Revision 38300
Added by Marc-Andre Lafortune over 1 year ago

  • lib/matrix: alias {row|column}size to {row|column}count and use the latter. [Bug #7369]


#1 Updated by Marc-Andre Lafortune over 1 year ago

  • Category set to lib
  • Assignee set to Marc-Andre Lafortune

I agree that {row|column}_size can be ambiguous.

I don't believe height/width is used in this context though, at least in mathematics.

Possibilities I can think of: column_count or nb_columns.


#2 Updated by Benoit Daloze over 1 year ago

m and n?
They are awfully short and might be confusing but they also are the names used in standard notation (an m-by-n matrix).

#3 Updated by Boris Stitnicky over 1 year ago

@Eregon: #m and #n? Maybe as aliases, but I think that one-character methods should be generally left to daring users. Perhaps #msize and #nsize.

@Marc-Andre: This is what they call conundrum. #numberofrows is clear, but almost as long as #eachwithobject. #rowcount is shorter, but less mnemonic. #nbrows and such is even less mnemonic. #height / #width is unambiguous, but slightly boorish with respect to mathematicians. Some recommend that methods should be named only with full-length (unabbreviated) English words, but on the other hand, when writing core or stdlib, one is allowed to trade brevity for mnemonism, as seen eg. in "attrreader". For that case, #noofrows / #noof_columns can be considered. Additional possibility is having a method named eg. #dimensions returning [m, n] for m x n matrix.

#4 Updated by Marc-Andre Lafortune over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38300.
Boris, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

  • lib/matrix: alias {row|column}size to {row|column}count and use the latter. [Bug #7369]

Also available in: Atom PDF