Hi, On 2012-05-29, Martin Albrecht <martinralbre...@googlemail.com> wrote: >> sage: k.some_elements ? >> ... >> Returns a collection of elements of this finite field *for use >> in unit testing.* > > The function is indeed used in unitests as confirmed by > search_src("some_elements"). Perhaps it should start with an underscore?
That is a method required and defined by the category framework, such as sage: ZZ.some_elements.__module__ 'sage.categories.sets_cat' In some cases, it is overridden by something more useful (by default, that method just returns a list of length one). And yes, it *is* used in the testing framework. For example, if associativity is tested then some_elements provides the elements on which the test is performed (that's why it is a good idea to not just inherit some_elements but override it with something more meaningful). See sage: ZZ._test_associativity?? >> Why this function are defined as public? Why not? >> 2. Also a few misunderstanding functions >> >> - sage: *k.cardinality* ? >> Type: builtin_function_or_method >> Base Class: <type 'builtin_function_or_method'> >> String Form: <built-in method cardinality of >> FiniteField_givaro_with_category object at 0xbb0eaac> >> Namespace: Interactive >> Definition: k.cardinality(self) >> Docstring: >> Return the order of this finite field (*same as self.order()*). > > Why is this confusing? I can't understand the confusion either. Some people say "order" and some people say "cardinality" when they refer to the number of elements of a group or field. Personally, I'd tend to say "cardinality" in the case of a set (but a field *is* as set!), and "order" in the case of a field or group. But why shouldn't one offer both, if both is used by people? >> - sage: *k.ngens* *?* >> Docstring: >> The number of generators of the finite field. * Always 1.* > > This is a generic function provided for compatibility with other parents in > Sage. At that point one should mention "duck typing", I guess. Sometimes one writes generic code, that is supposed to work with various kinds of objects, and the type of these objects does not (and should not) matter. In some cases, all what one wants to know is whether the object is defined in terms of generators (e.g., a polynomial ring is, but a set is not), and how many generators there are. ngens() answers both questions. >> - sage: *k.normalize_names ?* >> >> sage: k.normalize_names() > > This is a generic method that perhaps could be private, i.e., > "_normalize_names()" or moved somewhere else? I sometimes wondered why it is a method of CategoryObject, and not a function defined in, say, sage.structure.parent. Cheers, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org