Skip to content

Commit 694a88e

Browse files
committed
Added docstring
Former-commit-id: e5cb45f
1 parent 808b335 commit 694a88e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

metaknowledge/recordCollection.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,30 @@ def makeDict(self, onlyTheseTags = None, longNames = False, cleanedVal = True, n
474474
def coAuthNetwork(self, detailedInfo = False, weighted = True, dropNonJournals = False, count = True):
475475
"""Creates a coauthorship network for the RecordCollection.
476476
477+
# Parameters
478+
479+
_detailedInfo_ : `optional [bool or iterable[WOS tag Strings]]`
480+
481+
> default `False`, if `True` all nodes will be given info strings composed of information from the Record objects themselves. This is Equivalent to passing the list: `['PY', 'TI', 'SO', 'VL', 'BP']`.
482+
483+
> If _detailedCore_ is an iterable (That evaluates to `True`) of WOS Tags (or long names) The values of those tags will be used to make the info attributes. All
484+
485+
> For each of the selected tags an attribute will be added to the node using the values of those tags on the first `Record` encountered. **Warning** iterating over `RecordCollection` objects is not deterministic the first `Record` will not always be same between runs. The node will be given attributes with the names of the WOS tags for each of the selected tags. The attributes will contain strings of containing the values (with commas removed), if multiple values are encountered they will be comma separated.
486+
487+
> Note: _detailedInfo_ is not identical to the _detailedCore_ argument of [`Recordcollection.coCiteNetwork()`](#RecordCollection.coCiteNetwork) or [`Recordcollection.citationNetwork()'](#RecordCollection.citationNetwork)
488+
489+
_weighted_ : `optional [bool]`
490+
491+
> default `True`, wether the edges are weighted. If `True` the edges are weighted by the number of co-authorships.
492+
493+
_dropNonJournals_ : `optional [bool]`
494+
495+
> default `False`, wether to drop authors from non-journals
496+
497+
_count_ : `optional [bool]`
498+
499+
> default `True`, causes the number of occurrences of a node to be counted
500+
477501
# Returns
478502
479503
`Networkx Graph`
@@ -497,7 +521,11 @@ def coAuthNetwork(self, detailedInfo = False, weighted = True, dropNonJournals =
497521
def attributeMaker(Rec):
498522
attribsDict = {}
499523
for val in infoVals:
500-
attribsDict[val] = str(getattr(Rec, val))
524+
recVal = getattr(Rec, val)
525+
if isinstance(recVal, list):
526+
attribsDict[val] = ', '.join((str(v).replace(',', '') , recVal))
527+
else:
528+
attribsDict[val] = str(recVal).replace(',', '')
501529
if count:
502530
attribsDict['count'] = 1
503531
return attribsDict
@@ -589,6 +617,8 @@ def coCiteNetwork(self, dropAnon = True, nodeType = "full", nodeInfo = True, ful
589617
590618
> The resultant string is the values of each tag, with commas removed, seperated by `', '`, just like the info given by non-core Citations. Note that for tags like `'AF'` that return lists only the first entry in the list will be used. Also a second attribute is created for all nodes called inCore wich is a boolean describing if the node is in the core or not.
591619
620+
> Note: _detailedCore_ is not identical to the _detailedInfo_ argument of [`Recordcollection.coAuthNetwork()`](#RecordCollection.coAuthNetwork)
621+
592622
_coreOnly_ : `optional [bool]`
593623
594624
> default `False`, if `True` only Citations from the RecordCollection will be included in the network
@@ -689,6 +719,8 @@ def citationNetwork(self, dropAnon = True, nodeType = "full", nodeInfo = True, f
689719
690720
> The resultant string is the values of each tag, with commas removed, seperated by `', '`, just like the info given by non-core Citations. Note that for tags like `'AF'` that return lists only the first entry in the list will be used. Also a second attribute is created for all nodes called inCore wich is a boolean describing if the node is in the core or not.
691721
722+
> Note: _detailedCore_ is not identical to the _detailedInfo_ argument of [`Recordcollection.coAuthNetwork()`](#RecordCollection.coAuthNetwork)
723+
692724
_coreOnly_ : `optional [bool]`
693725
694726
> default `False`, if `True` only Citations from the RecordCollection will be included in the network

0 commit comments

Comments
 (0)