module: topics

Support AGUP topics

class Assign_GUP.topics.Topics[source]

Bases: object

manage the list of AGUP topics (known here as key)

add(key, value=0.0)[source]

define a new topic (known here as key)

addTopics(key_list)[source]

add several topics at once (with default values)

Parameters:key_list ([str]) – list of topics (strings) to be added
clearAll()[source]

remove all keys from the list of topics

compare(other_topics_object)[source]

compare topics in self.topics with the other_topics_object, return True if identical

compares sorted list of topics between each object

Parameters:other_topics_object (obj) – instance of Topics()
diff(other_topics_object)[source]

differences in list of topics between self.topics and other_topics_object

Comparison assumes that self.topics is the final result. Returned result shows topics added and removed from other_topics_object to obtain current list.

Parameters:other_topics_object (obj) – instance of Topics()
Returns ([],[]):
 first list is topics added, second list is topics removed
dotProduct(other)[source]

normalized dot product of Proposal (self) and Reviewer (other) topic strengths, \(\vec{p} \cdot \vec{r}\)

Parameters:other (obj) – instance of Topics()
Returns:\(\sum{\vec{p} \cdot \vec{r}} / \sum{\vec{p}}\)
  • \(\vec{p}\) is array of topic value strengths for Proposal
  • \(\vec{r}\) is array of topic value strengths for Reviewer
exists(key)[source]

Is key already known?

get(key)[source]

return value of an existing topic (known here as key)

topic must exist or KeyError exception will be raised

getTopicList()[source]

return a list of all topics

importXml(xmlFile, read_values=True)[source]
Parameters:
  • filename (str) – name of XML file with Topics
  • read_values (bool) – import topic values?
importXmlTopics(parent_node, read_values=True)[source]

make this common code segment reuseable

Parameters:
  • parent_node (obj) – XML parent node
  • read_values (bool) – import topic values?
inOrder()[source]
remove(key)[source]

remove the named topic

Parameters:key (str) – topic to be removed
removeTopics(key_list)[source]

remove several topics at once

Parameters:key_list ([str]) – list of topics (strings) to be removed
set(key, value)[source]

set value of an existing topic (known here as key)

topic must exist or KeyError exception will be raised

valueOrder()[source]

sort by topic values

writeXml(specified_node, write_values=True)[source]

write Topics’ data to a specified node in the XML document

Parameters:
  • specified_node (obj) – XML node to contain this data
  • read_values (bool) – write topic values?
Assign_GUP.topics.checkTopicValueRange(value)[source]

topic values must be 0..1 inclusive: standardize this check

Parameters:value (float) – topic value to be checked
Assign_GUP.topics.diffLists(new_list, old_list)[source]

differences between two lists, return tuple([items added], [items removed])

assumes each list had only unique entries, no redundancies

Parameters:
  • new_list ([str]) – new list of strings to be compared
  • old_list ([str]) – old list of strings to be compared
Assign_GUP.topics.sortListUnique(the_list)[source]

sort list and eliminate redundant items

  • make a dictionary with each list item
  • redundancies will be overwritten
Parameters:the_list ([str]) – list of strings to be sorted
Assign_GUP.topics.synchronizeTopics(a_list, b_list)[source]

make the topic names in each list be the same

  • assumes each topics list had only unique entries, no redundancies
  • modifies objects in place
Parameters:
  • a_list (obj) – instance of Topics()
  • b_list (obj) – instance of Topics()