I like the initiative of having a global naming scheme. No preference from my side on which one.
As a data point: numpy/scipy seem to be using the `nxxx` pattern: - https://numpy.org/doc/2.2/search.html?q=ndim - https://docs.scipy.org/doc/scipy-1.16.2/search.html?q=npoints - https://docs.scipy.org/doc/scipy-1.16.2/reference/generated/scipy.sparse.bsr_array.nnz.html#scipy.sparse.bsr_array.nnz and "count_xyz" if it's a method (which I do like): - https://docs.scipy.org/doc/scipy-1.16.2/reference/generated/scipy.sparse.bsr_array.count_nonzero.html#scipy.sparse.bsr_array.count_nonzero - https://docs.scipy.org/doc/scipy-1.16.2/reference/generated/scipy.spatial.KDTree.count_neighbors.html#scipy.spatial.KDTree.count_neighbors In general, they seem to try to not use "number of xyz" but use a more descriptive term (eg. matrix.shape instead of matrix.ncols/nrows). On Wednesday, September 24, 2025 at 2:12:22 PM UTC+8 [email protected] wrote: > At https://github.com/sagemath/sage/pull/40875, Frédéric is harmonizing > the prefix of the names of methods returning the number of facets (points, > vertices, parts, etc.) of polytopes to `n_facets`, before it was `nfacets`. > > While I think this is very good, I would rather go one tiny step further, > and harmonize both to `number_of_facets`, or, in fact, just make > `number_of_facets` an alias. > > My question here is: is anybody strictly against this? More precisely: > > Any method returning the number of some components of a structure should > be named `number_of_xxx`, other aliases are OK. > > I did a quick grep, the current situation is as follows: > > grep -r --include=*.{py,pyx} --color=auto -nH --null -e "def[^(]* > number_of_.*(" * > 125 matches > > grep -r --include=*.{py,pyx} --color=auto -nH --null -e "def[^(]* num_.*(" > * > 22 matches > most important example: graph.num_verts > > grep -r --include=*.{py,pyx} --color=auto -nH --null -e "def[^(]* n_.*(" * > 97 matches > mostly geometry/polyhedron > > most important example for nxxx is of course ngens, and I'm afraid we > shouldn't rename that one. But there is also `nvars` (in sat/solvers), > `ncols` and `nrows` for matrices, `ncusps` in `arithgroup`, and the > polytope methods. > > Finally, there are a few really odd ones, which I stumble across every > other month (and hate): > > combinat/binary_tree.py:1752: def left_children_node_number(self, > direction='left'): > combinat/binary_tree.py:2600: def hook_number(self): > combinat/abstract_tree.py:1159: def node_number(self): > combinat/permutation.py:2442: def > longest_increasing_subsequences_number(self): > combinat/posets/posets.py:2714: def relations_number(self): > > Martin > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/sage-devel/640de3c6-f267-475f-b7db-78a5882ce28en%40googlegroups.com.
