diff --git a/doc/news/bibliography.rst b/doc/news/bibliography.rst new file mode 100644 index 00000000..c3d8b654 --- /dev/null +++ b/doc/news/bibliography.rst @@ -0,0 +1,3 @@ +**Changed:** + +* Changed `collection.bibliography` to a cached_property. diff --git a/unitpackage/collection.py b/unitpackage/collection.py index 95d910d1..9ba19373 100644 --- a/unitpackage/collection.py +++ b/unitpackage/collection.py @@ -47,6 +47,7 @@ # along with unitpackage. If not, see . # ******************************************************************** import logging +from functools import cached_property from frictionless import Package @@ -133,7 +134,7 @@ def create_example(cls): package=package, ) - @property + @cached_property def bibliography(self): r""" Return a pybtex database of all bibtex bibliography files, @@ -150,7 +151,15 @@ def bibliography(self): ('engstfeld_2018_polycrystalline_17743', Entry('article', ... - A collection with entries without bibliography. + A derived collection includes only the bibliographic entries of the remaining entries:: + + >>> collection.filter(lambda entry: entry.source.citationKey != 'alves_2011_electrochemistry_6010').bibliography + BibliographyData( + entries=OrderedCaseInsensitiveDict([ + ('engstfeld_2018_polycrystalline_17743', Entry('article', + ... + + A collection with entries without bibliography:: >>> collection = Collection.create_example()["no_bibliography"] >>> collection.bibliography