[PYTHON MATRIX-SIG] Naming in arrayobject.c
P. Dubois
dubois@kristen.llnl.gov
Tue, 13 Feb 1996 12:15:00 -0800
SIG'ers,
Here are some thoughts about the names in arrayobject.c; I am now leaving
town until the 20th so that I don't have to listen to the resulting howls
of outrage (:->. My philosophy is close to that used in the ISE Eiffel
libraries and as described in the book Reusable Software by Meyer.
1. These are ok as is:
transpose (ok, imperative verb for something that modifies self)
cast (ok, ditto)
typecode (ok, noun = attribute)
itemsize (ok, noun = attribute)
toString
toFile
choose (this is so weird a function anyway ...)
2. These I think need changing:
Current -> Proposed Reason
------------------------------------
byteswap -> byteswapped (returns result, shouldn't be an imperative verb)
reshape -> shaped (returns result, shouldn't be an imperative verb)
If worried about typos because shape and shaped too similar,
consider shaped_as. But not reshape, which definitely sounds like
self is being modified.
isnonzero -> nonzero_indices (sounds too much like test of not all zeros)
This returns a list of indices where x is not zero.
(Note: maybe a new function x.is_zero() would be useful to mean
true => all elements are 0)
copy -> clone
copy is an ambiguous word as to whether one is the copier or the
copyee. But clone definitely carries more of a feeling that this
is going to produce a copy.
In Eiffel, x.copy(y) means set x's attributes from y, for example.
concat -> append (philosophically equivalent to list.append)
If you don't like append, then change it to concatenate;
abbreviations are not worth the trouble they cause.
contiguous -> is_contiguous
This is a query, not a command to make self contiguous
3. These are not clear to me
take -> gather
m.take(i_list) returns [m[i_list[0]], m[i_list[1]], ...]
Gather is a more traditional name but I won't argue this too hard.
conjugate -> conjugated
Ambiguous as to whether it modifies self.
But, you could make the case "conjugate" is a noun, not a verb
in which case it is ok.
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================