diff --git a/src/sage/databases/findstat.py b/src/sage/databases/findstat.py index dfb789ab7a5..2f0c29fe13e 100644 --- a/src/sage/databases/findstat.py +++ b/src/sage/databases/findstat.py @@ -248,6 +248,7 @@ def increasing_tree_shape(elt, compare=min): FINDSTAT_STATISTIC_COLLECTION = 'StatisticCollection' FINDSTAT_STATISTIC_DATA = 'StatisticData' FINDSTAT_STATISTIC_GENERATING_FUNCTION = 'StatisticGeneratingFunction' +FINDSTAT_STATISTIC_NAME = 'StatisticTitle' FINDSTAT_STATISTIC_DESCRIPTION = 'StatisticDescription' FINDSTAT_STATISTIC_REFERENCES = 'StatisticReferences' FINDSTAT_STATISTIC_CODE = 'StatisticCode' @@ -956,6 +957,7 @@ def _find_by_id(self): raise self._description = self._raw[FINDSTAT_STATISTIC_DESCRIPTION].encode("utf-8") + self._name = self._raw[FINDSTAT_STATISTIC_NAME].encode("utf-8") self._references = self._raw[FINDSTAT_STATISTIC_REFERENCES].encode("utf-8") self._collection = FindStatCollection(self._raw[FINDSTAT_STATISTIC_COLLECTION]) self._code = self._raw[FINDSTAT_STATISTIC_CODE] @@ -1518,14 +1520,14 @@ def set_description(self, value): sage: s = findstat([(d, randint(1,1000)) for d in DyckWords(4)]); s # optional -- internet a new statistic on Cc0005: Dyck paths - sage: s.set_description("Random values on Dyck paths.\r\nNot for submssion.") # optional -- internet + sage: s.set_description("Random values on Dyck paths.\r\nNot for submission.") # optional -- internet sage: s # optional -- internet a new statistic on Cc0005: Dyck paths sage: s.name() # optional -- internet 'Random values on Dyck paths.' sage: print s.description() # optional -- internet Random values on Dyck paths. - Not for submssion. + Not for submission. """ self._raise_error_modifying_statistic_with_perfect_match() @@ -1547,7 +1549,11 @@ def name(self): sage: findstat(1).name() # optional -- internet,random u'The number of ways to write a permutation as a minimal length product of simple transpositions.' """ - return self._description.partition(FINDSTAT_SEPARATOR_NAME)[0] + # this needs to be decided how to do properly + if hasattr(self,"_name"): + return self._name + else: + return self._description.partition(FINDSTAT_SEPARATOR_NAME)[0] def references(self): r""" @@ -2159,21 +2165,34 @@ def _repr_(self): """ return "%s: %s" %(self.id_str(), self._name_plural) - def name(self): + def name(self, style="singular"): r""" Return the name of the FindStat collection. + INPUT: + + - a string -- (default:"singular") can be + "singular", or "plural". + OUTPUT: - The name of the FindStat collection, in singular. + The name of the FindStat collection, in singular or in plural. EXAMPLES:: sage: from sage.databases.findstat import FindStatCollection sage: FindStatCollection("Binary trees").name() # optional -- internet u'Binary tree' + + sage: FindStatCollection("Binary trees").name(style="plural") # optional -- internet + u'Binary trees' """ - return self._name + if style == "singular": + return self._name + elif style == "plural": + return self._name_plural + else: + raise ValueError("Argument 'style' (=%s) must be 'singular' or 'plural'."%style) class FindStatCollections(Parent, UniqueRepresentation): r"""