_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q234900 | Network.create_instructor_answer | train | def create_instructor_answer(self, post, content, revision, anonymous=False):
"""Create an instructor's answer to a post `post`.
It seems like if the post has `<p>` tags, then it's treated as HTML,
but is treated as text otherwise. You'll want to provide `content`
accordingly.
... | python | {
"resource": ""
} |
q234901 | Network.mark_as_duplicate | train | def mark_as_duplicate(self, duplicated_cid, master_cid, msg=''):
"""Mark the post at ``duplicated_cid`` as a duplicate of ``master_cid``
:type duplicated_cid: int
:param duplicated_cid: The numeric id of the duplicated post
:type master_cid: int
:param master_cid: The numeric ... | python | {
"resource": ""
} |
q234902 | Network.resolve_post | train | def resolve_post(self, post):
"""Mark post as resolved
:type post: dict|str|int
:param post: Either the post dict returned by another API method, or
the `cid` field of that post.
:returns: True if it is successful. False otherwise
"""
try:
cid = ... | python | {
"resource": ""
} |
q234903 | Network.delete_post | train | def delete_post(self, post):
""" Deletes post by cid
:type post: dict|str|int
:param post: Either the post dict returned by another API method, the post ID, or
the `cid` field of that post.
:rtype: dict
:returns: Dictionary with information about the post cid.
... | python | {
"resource": ""
} |
q234904 | Network.get_feed | train | def get_feed(self, limit=100, offset=0):
"""Get your feed for this network
Pagination for this can be achieved by using the ``limit`` and
``offset`` params
:type limit: int
:param limit: Number of posts from feed to get, starting from ``offset``
:type offset: int
... | python | {
"resource": ""
} |
q234905 | Network.get_filtered_feed | train | def get_filtered_feed(self, feed_filter):
"""Get your feed containing only posts filtered by ``feed_filter``
:type feed_filter: FeedFilter
:param feed_filter: Must be an instance of either: UnreadFilter,
FollowingFilter, or FolderFilter
:rtype: dict
"""
asser... | python | {
"resource": ""
} |
q234906 | CASIA.get_dataset | train | def get_dataset(self, dataset):
"""
Checks to see if the dataset is present. If not, it downloads and unzips it.
"""
# If the dataset is present, no need to download anything.
success = True
dataset_path = self.base_dataset_path + dataset
if not isdir(dataset_path... | python | {
"resource": ""
} |
q234907 | SanicPlugin.first_plugin_context | train | def first_plugin_context(self):
"""Returns the context is associated with the first app this plugin was
registered on"""
# Note, because registrations are stored in a set, its not _really_
# the first one, but whichever one it sees first in the set.
first_spf_reg = next(iter(sel... | python | {
"resource": ""
} |
q234908 | SanicPlugin.route_wrapper | train | async def route_wrapper(self, route, request, context, request_args,
request_kw, *decorator_args, with_context=None,
**decorator_kw):
"""This is the function that is called when a route is decorated with
your plugin decorator. Context will norma... | python | {
"resource": ""
} |
q234909 | check_credentials | train | def check_credentials(client):
"""
Checks credentials for given socket.
"""
pid, uid, gid = get_peercred(client)
euid = os.geteuid()
client_name = "PID:%s UID:%s GID:%s" % (pid, uid, gid)
if uid not in (0, euid):
raise SuspiciousClient("Can't accept client with %s. It doesn't match ... | python | {
"resource": ""
} |
q234910 | handle_connection_exec | train | def handle_connection_exec(client):
"""
Alternate connection handler. No output redirection.
"""
class ExitExecLoop(Exception):
pass
def exit():
raise ExitExecLoop()
client.settimeout(None)
fh = os.fdopen(client.detach() if hasattr(client, 'detach') else client.fileno())
... | python | {
"resource": ""
} |
q234911 | handle_connection_repl | train | def handle_connection_repl(client):
"""
Handles connection.
"""
client.settimeout(None)
# # disable this till we have evidence that it's needed
# client.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0)
# # Note: setting SO_RCVBUF on UDS has no effect, see: http://man7.org/linux/man-pages/m... | python | {
"resource": ""
} |
q234912 | install | train | def install(verbose=True,
verbose_destination=sys.__stderr__.fileno() if hasattr(sys.__stderr__, 'fileno') else sys.__stderr__,
strict=True,
**kwargs):
"""
Installs the manhole.
Args:
verbose (bool): Set it to ``False`` to squelch the logging.
verbose_des... | python | {
"resource": ""
} |
q234913 | dump_stacktraces | train | def dump_stacktraces():
"""
Dumps thread ids and tracebacks to stdout.
"""
lines = []
for thread_id, stack in sys._current_frames().items(): # pylint: disable=W0212
lines.append("\n######### ProcessID=%s, ThreadID=%s #########" % (
os.getpid(), thread_id
))
for f... | python | {
"resource": ""
} |
q234914 | ManholeThread.clone | train | def clone(self, **kwargs):
"""
Make a fresh thread with the same options. This is usually used on dead threads.
"""
return ManholeThread(
self.get_socket, self.sigmask, self.start_timeout,
connection_handler=self.connection_handler,
daemon_connection=s... | python | {
"resource": ""
} |
q234915 | Manhole.reinstall | train | def reinstall(self):
"""
Reinstalls the manhole. Checks if the thread is running. If not, it starts it again.
"""
with _LOCK:
if not (self.thread.is_alive() and self.thread in _ORIGINAL__ACTIVE):
self.thread = self.thread.clone(bind_delay=self.reinstall_delay)... | python | {
"resource": ""
} |
q234916 | Manhole.patched_forkpty | train | def patched_forkpty(self):
"""Fork a new process with a new pseudo-terminal as controlling tty."""
pid, master_fd = self.original_os_forkpty()
if not pid:
_LOG('Fork detected. Reinstalling Manhole.')
self.reinstall()
return pid, master_fd | python | {
"resource": ""
} |
q234917 | AlertConditionsNRQL.update | train | def update( # noqa: C901
self, alert_condition_nrql_id, policy_id, name=None, threshold_type=None, query=None,
since_value=None, terms=None, expected_groups=None, value_function=None,
runbook_url=None, ignore_overlap=None, enabled=True):
"""
Updates any of the option... | python | {
"resource": ""
} |
q234918 | AlertConditionsNRQL.create | train | def create(
self, policy_id, name, threshold_type, query, since_value, terms,
expected_groups=None, value_function=None, runbook_url=None,
ignore_overlap=None, enabled=True):
"""
Creates an alert condition nrql
:type policy_id: int
:param policy_id: A... | python | {
"resource": ""
} |
q234919 | AlertConditionsNRQL.delete | train | def delete(self, alert_condition_nrql_id):
"""
This API endpoint allows you to delete an alert condition nrql
:type alert_condition_nrql_id: integer
:param alert_condition_nrql_id: Alert Condition ID
:rtype: dict
:return: The JSON response of the API
::
... | python | {
"resource": ""
} |
q234920 | Servers.list | train | def list(self, filter_name=None, filter_ids=None, filter_labels=None, page=None):
"""
This API endpoint returns a paginated list of the Servers
associated with your New Relic account. Servers can be filtered
by their name or by a list of server IDs.
:type filter_name: str
... | python | {
"resource": ""
} |
q234921 | Servers.update | train | def update(self, id, name=None):
"""
Updates any of the optional parameters of the server
:type id: int
:param id: Server ID
:type name: str
:param name: The name of the server
:rtype: dict
:return: The JSON response of the API
::
... | python | {
"resource": ""
} |
q234922 | AlertPolicies.create | train | def create(self, name, incident_preference):
"""
This API endpoint allows you to create an alert policy
:type name: str
:param name: The name of the policy
:type incident_preference: str
:param incident_preference: Can be PER_POLICY, PER_CONDITION or
PER_CON... | python | {
"resource": ""
} |
q234923 | AlertPolicies.update | train | def update(self, id, name, incident_preference):
"""
This API endpoint allows you to update an alert policy
:type id: integer
:param id: The id of the policy
:type name: str
:param name: The name of the policy
:type incident_preference: str
:param incid... | python | {
"resource": ""
} |
q234924 | AlertPolicies.delete | train | def delete(self, id):
"""
This API endpoint allows you to delete an alert policy
:type id: integer
:param id: The id of the policy
:rtype: dict
:return: The JSON response of the API
::
{
"policy": {
"created_at":... | python | {
"resource": ""
} |
q234925 | AlertPolicies.associate_with_notification_channel | train | def associate_with_notification_channel(self, id, channel_id):
"""
This API endpoint allows you to associate an alert policy with an
notification channel
:type id: integer
:param id: The id of the policy
:type channel_id: integer
:param channel_id: The id of... | python | {
"resource": ""
} |
q234926 | AlertPolicies.dissociate_from_notification_channel | train | def dissociate_from_notification_channel(self, id, channel_id):
"""
This API endpoint allows you to dissociate an alert policy from an
notification channel
:type id: integer
:param id: The id of the policy
:type channel_id: integer
:param channel_id: The id ... | python | {
"resource": ""
} |
q234927 | AlertConditions.list | train | def list(self, policy_id, page=None):
"""
This API endpoint returns a paginated list of alert conditions associated with the
given policy_id.
This API endpoint returns a paginated list of the alert conditions
associated with your New Relic account. Alert conditions can be filter... | python | {
"resource": ""
} |
q234928 | AlertConditions.update | train | def update(
self, alert_condition_id, policy_id,
type=None,
condition_scope=None,
name=None,
entities=None,
metric=None,
runbook_url=None,
terms=None,
user_defined=None,
enabled=None):
"""
... | python | {
"resource": ""
} |
q234929 | AlertConditions.create | train | def create(
self, policy_id,
type,
condition_scope,
name,
entities,
metric,
terms,
runbook_url=None,
user_defined=None,
enabled=True):
"""
Creates an alert condition
:type pol... | python | {
"resource": ""
} |
q234930 | AlertConditions.delete | train | def delete(self, alert_condition_id):
"""
This API endpoint allows you to delete an alert condition
:type alert_condition_id: integer
:param alert_condition_id: Alert Condition ID
:rtype: dict
:return: The JSON response of the API
::
{
... | python | {
"resource": ""
} |
q234931 | AlertConditionsInfra.list | train | def list(self, policy_id, limit=None, offset=None):
"""
This API endpoint returns a paginated list of alert conditions for infrastucture
metrics associated with the given policy_id.
:type policy_id: int
:param policy_id: Alert policy id
:type limit: string
:para... | python | {
"resource": ""
} |
q234932 | AlertConditionsInfra.show | train | def show(self, alert_condition_infra_id):
"""
This API endpoint returns an alert condition for infrastucture, identified by its
ID.
:type alert_condition_infra_id: int
:param alert_condition_infra_id: Alert Condition Infra ID
:rtype: dict
:return: The JSON respo... | python | {
"resource": ""
} |
q234933 | AlertConditionsInfra.create | train | def create(self, policy_id, name, condition_type, alert_condition_configuration, enabled=True):
"""
This API endpoint allows you to create an alert condition for infrastucture
:type policy_id: int
:param policy_id: Alert policy id
:type name: str
:param name: The name o... | python | {
"resource": ""
} |
q234934 | AlertConditionsInfra.update | train | def update(self, alert_condition_infra_id, policy_id,
name, condition_type, alert_condition_configuration, enabled=True):
"""
This API endpoint allows you to update an alert condition for infrastucture
:type alert_condition_infra_id: int
:param alert_condition_infra_id: A... | python | {
"resource": ""
} |
q234935 | AlertConditionsInfra.delete | train | def delete(self, alert_condition_infra_id):
"""
This API endpoint allows you to delete an alert condition for infrastucture
:type alert_condition_infra_id: integer
:param alert_condition_infra_id: Alert Condition Infra ID
:rtype: dict
:return: The JSON response of the A... | python | {
"resource": ""
} |
q234936 | Labels.create | train | def create(self, name, category, applications=None, servers=None):
"""
This API endpoint will create a new label with the provided name and
category
:type name: str
:param name: The name of the label
:type category: str
:param category: The Category
:ty... | python | {
"resource": ""
} |
q234937 | Labels.delete | train | def delete(self, key):
"""
When applications are provided, this endpoint will remove those
applications from the label.
When no applications are provided, this endpoint will remove the label.
:type key: str
:param key: Label key. Example: 'Language:Java'
:rtype... | python | {
"resource": ""
} |
q234938 | Plugins.list | train | def list(self, filter_guid=None, filter_ids=None, detailed=None, page=None):
"""
This API endpoint returns a paginated list of the plugins associated
with your New Relic account.
Plugins can be filtered by their name or by a list of IDs.
:type filter_guid: str
:param fi... | python | {
"resource": ""
} |
q234939 | ApplicationInstances.list | train | def list(
self, application_id, filter_hostname=None, filter_ids=None,
page=None):
"""
This API endpoint returns a paginated list of instances associated with the
given application.
Application instances can be filtered by hostname, or the list of
applica... | python | {
"resource": ""
} |
q234940 | ApplicationHosts.show | train | def show(self, application_id, host_id):
"""
This API endpoint returns a single application host, identified by its
ID.
:type application_id: int
:param application_id: Application ID
:type host_id: int
:param host_id: Application host ID
:rtype: dict
... | python | {
"resource": ""
} |
q234941 | Components.metric_data | train | def metric_data(
self, id, names, values=None, from_dt=None, to_dt=None,
summarize=False):
"""
This API endpoint returns a list of values for each of the requested
metrics. The list of available metrics can be returned using the Metric
Name API endpoint.
... | python | {
"resource": ""
} |
q234942 | Dashboards.create | train | def create(self, dashboard_data):
"""
This API endpoint creates a dashboard and all defined widgets.
:type dashboard: dict
:param dashboard: Dashboard Dictionary
:rtype dict
:return: The JSON response of the API
::
{
"dashboard": {
... | python | {
"resource": ""
} |
q234943 | Dashboards.update | train | def update(self, id, dashboard_data):
"""
This API endpoint updates a dashboard and all defined widgets.
:type id: int
:param id: Dashboard ID
:type dashboard: dict
:param dashboard: Dashboard Dictionary
:rtype dict
:return: The JSON response of the API... | python | {
"resource": ""
} |
q234944 | operatorPrecedence | train | def operatorPrecedence(base, operators):
"""
This re-implements pyparsing's operatorPrecedence function.
It gets rid of a few annoying bugs, like always putting operators inside
a Group, and matching the whole grammar with Forward first (there may
actually be a reason for that, but I couldn't find ... | python | {
"resource": ""
} |
q234945 | Element.set_parse_attributes | train | def set_parse_attributes(self, string, location, tokens):
"Fluent API for setting parsed location"
self.string = string
self.location = location
self.tokens = tokens
return self | python | {
"resource": ""
} |
q234946 | Element.evaluate_object | train | def evaluate_object(obj, cls=None, cache=False, **kwargs):
"""Evaluates elements, and coerces objects to a class if needed"""
old_obj = obj
if isinstance(obj, Element):
if cache:
obj = obj.evaluate_cached(**kwargs)
else:
obj = obj.evaluate(... | python | {
"resource": ""
} |
q234947 | readGraph | train | def readGraph(edgeList, nodeList = None, directed = False, idKey = 'ID', eSource = 'From', eDest = 'To'):
"""Reads the files given by _edgeList_ and _nodeList_ and creates a networkx graph for the files.
This is designed only for the files produced by metaknowledge and is meant to be the reverse of [writeGraph... | python | {
"resource": ""
} |
q234948 | writeGraph | train | def writeGraph(grph, name, edgeInfo = True, typing = False, suffix = 'csv', overwrite = True, allSameAttribute = False):
"""Writes both the edge list and the node attribute list of _grph_ to files starting with _name_.
The output files start with _name_, the file type (edgeList, nodeAttributes) then if typing ... | python | {
"resource": ""
} |
q234949 | getNodeDegrees | train | def getNodeDegrees(grph, weightString = "weight", strictMode = False, returnType = int, edgeType = 'bi'):
"""
Retunrs a dictionary of nodes to their degrees, the degree is determined by adding the weight of edge with the weight being the string weightString that gives the name of the attribute of each edge con... | python | {
"resource": ""
} |
q234950 | mergeGraphs | train | def mergeGraphs(targetGraph, addedGraph, incrementedNodeVal = 'count', incrementedEdgeVal = 'weight'):
"""A quick way of merging graphs, this is meant to be quick and is only intended for graphs generated by metaknowledge. This does not check anything and as such may cause unexpected results if the source and targe... | python | {
"resource": ""
} |
q234951 | AD | train | def AD(val):
"""Affiliation
Undoing what the parser does then splitting at the semicolons and dropping newlines extra fitlering is required beacuse some AD's end with a semicolon"""
retDict = {}
for v in val:
split = v.split(' : ')
retDict[split[0]] = [s for s in' : '.join(split[1:]).rep... | python | {
"resource": ""
} |
q234952 | AUID | train | def AUID(val):
"""AuthorIdentifier
one line only just need to undo the parser's effects"""
retDict = {}
for v in val:
split = v.split(' : ')
retDict[split[0]] = ' : '.join(split[1:])
return retDict | python | {
"resource": ""
} |
q234953 | isInteractive | train | def isInteractive():
"""
A basic check of if the program is running in interactive mode
"""
if sys.stdout.isatty() and os.name != 'nt':
#Hopefully everything but ms supports '\r'
try:
import threading
except ImportError:
return False
else:
... | python | {
"resource": ""
} |
q234954 | NSERCGrant.getInstitutions | train | def getInstitutions(self, tags = None, seperator = ";", _getTag = False):
"""Returns a list with the names of the institution. The optional arguments are ignored
# Returns
`list [str]`
> A list with 1 entry the name of the institution
"""
if tags is None:
t... | python | {
"resource": ""
} |
q234955 | MedlineRecord.writeRecord | train | def writeRecord(self, f):
"""This is nearly identical to the original the FAU tag is the only tag not writen in the same place, doing so would require changing the parser and lots of extra logic.
"""
if self.bad:
raise BadPubmedRecord("This record cannot be converted to a file as the... | python | {
"resource": ""
} |
q234956 | quickVisual | train | def quickVisual(G, showLabel = False):
"""Just makes a simple _matplotlib_ figure and displays it, with each node coloured by its type. You can add labels with _showLabel_. This looks a bit nicer than the one provided my _networkx_'s defaults.
# Parameters
_showLabel_ : `optional [bool]`
> Default `F... | python | {
"resource": ""
} |
q234957 | graphDensityContourPlot | train | def graphDensityContourPlot(G, iters = 50, layout = None, layoutScaleFactor = 1, overlay = False, nodeSize = 10, axisSamples = 100, blurringFactor = .1, contours = 15, graphType = 'coloured'):
"""Creates a 3D plot giving the density of nodes on a 2D plane, as a surface in 3D.
Most of the options are for tweaki... | python | {
"resource": ""
} |
q234958 | makeBiDirectional | train | def makeBiDirectional(d):
"""
Helper for generating tagNameConverter
Makes dict that maps from key to value and back
"""
dTmp = d.copy()
for k in d:
dTmp[d[k]] = k
return dTmp | python | {
"resource": ""
} |
q234959 | reverseDict | train | def reverseDict(d):
"""
Helper for generating fullToTag
Makes dict of value to key
"""
retD = {}
for k in d:
retD[d[k]] = k
return retD | python | {
"resource": ""
} |
q234960 | makeNodeTuple | train | def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR):
"""Makes a tuple of idVal and a dict of the selected attributes"""
d = {}
if nodeInfo:
if nodeType == 'full':
if coreValues:
if citation in coreCites... | python | {
"resource": ""
} |
q234961 | expandRecs | train | def expandRecs(G, RecCollect, nodeType, weighted):
"""Expand all the citations from _RecCollect_"""
for Rec in RecCollect:
fullCiteList = [makeID(c, nodeType) for c in Rec.createCitation(multiCite = True)]
if len(fullCiteList) > 1:
for i, citeID1 in enumerate(fullCiteList):
... | python | {
"resource": ""
} |
q234962 | RecordCollection.dropNonJournals | train | def dropNonJournals(self, ptVal = 'J', dropBad = True, invert = False):
"""Drops the non journal type `Records` from the collection, this is done by checking _ptVal_ against the PT tag
# Parameters
_ptVal_ : `optional [str]`
> Default `'J'`, The value of the PT tag to be kept, default... | python | {
"resource": ""
} |
q234963 | RecordCollection.writeFile | train | def writeFile(self, fname = None):
"""Writes the `RecordCollection` to a file, the written file's format is identical to those download from WOS. The order of `Records` written is random.
# Parameters
_fname_ : `optional [str]`
> Default `None`, if given the output file will written t... | python | {
"resource": ""
} |
q234964 | RecordCollection.writeBib | train | def writeBib(self, fname = None, maxStringLength = 1000, wosMode = False, reducedOutput = False, niceIDs = True):
"""Writes a bibTex entry to _fname_ for each `Record` in the collection.
If the Record is of a journal article (PT J) the bibtext type is set to `'article'`, otherwise it is set to `'misc'`... | python | {
"resource": ""
} |
q234965 | RecordCollection.makeDict | train | def makeDict(self, onlyTheseTags = None, longNames = False, raw = False, numAuthors = True, genderCounts = True):
"""Returns a dict with each key a tag and the values being lists of the values for each of the Records in the collection, `None` is given when there is no value and they are in the same order across... | python | {
"resource": ""
} |
q234966 | RecordCollection.getCitations | train | def getCitations(self, field = None, values = None, pandasFriendly = True, counts = True):
"""Creates a pandas ready dict with each row a different citation the contained Records and columns containing the original string, year, journal, author's name and the number of times it occured.
There are also ... | python | {
"resource": ""
} |
q234967 | RecordCollection.networkCoCitation | train | def networkCoCitation(self, dropAnon = True, nodeType = "full", nodeInfo = True, fullInfo = False, weighted = True, dropNonJournals = False, count = True, keyWords = None, detailedCore = True, detailedCoreAttributes = False, coreOnly = False, expandedCore = False, addCR = False):
"""Creates a co-citation networ... | python | {
"resource": ""
} |
q234968 | RecordCollection.networkBibCoupling | train | def networkBibCoupling(self, weighted = True, fullInfo = False, addCR = False):
"""Creates a bibliographic coupling network based on citations for the RecordCollection.
# Parameters
_weighted_ : `optional bool`
> Default `True`, if `True` the weight of the edges will be added to the n... | python | {
"resource": ""
} |
q234969 | RecordCollection.yearSplit | train | def yearSplit(self, startYear, endYear, dropMissingYears = True):
"""Creates a RecordCollection of Records from the years between _startYear_ and _endYear_ inclusive.
# Parameters
_startYear_ : `int`
> The smallest year to be included in the returned RecordCollection
_endYear... | python | {
"resource": ""
} |
q234970 | RecordCollection.localCiteStats | train | def localCiteStats(self, pandasFriendly = False, keyType = "citation"):
"""Returns a dict with all the citations in the CR field as keys and the number of times they occur as the values
# Parameters
_pandasFriendly_ : `optional [bool]`
> default `False`, makes the output be a dict wit... | python | {
"resource": ""
} |
q234971 | RecordCollection.localCitesOf | train | def localCitesOf(self, rec):
"""Takes in a Record, WOS string, citation string or Citation and returns a RecordCollection of all records that cite it.
# Parameters
_rec_ : `Record, str or Citation`
> The object that is being cited
# Returns
`RecordCollection`
... | python | {
"resource": ""
} |
q234972 | RecordCollection.citeFilter | train | def citeFilter(self, keyString = '', field = 'all', reverse = False, caseSensitive = False):
"""Filters `Records` by some string, _keyString_, in their citations and returns all `Records` with at least one citation possessing _keyString_ in the field given by _field_.
# Parameters
_keyString_ ... | python | {
"resource": ""
} |
q234973 | filterNonJournals | train | def filterNonJournals(citesLst, invert = False):
"""Removes the `Citations` from _citesLst_ that are not journals
# Parameters
_citesLst_ : `list [Citation]`
> A list of citations to be filtered
_invert_ : `optional [bool]`
> Default `False`, if `True` non-journals will be kept instead of j... | python | {
"resource": ""
} |
q234974 | Collection.add | train | def add(self, elem):
""" Adds _elem_ to the collection.
# Parameters
_elem_ : `object`
> The object to be added
"""
if isinstance(elem, self._allowedTypes):
self._collection.add(elem)
self._collectedTypes.add(type(elem).__name__)
else:
... | python | {
"resource": ""
} |
q234975 | Collection.remove | train | def remove(self, elem):
"""Removes _elem_ from the collection, will raise a KeyError is _elem_ is missing
# Parameters
_elem_ : `object`
> The object to be removed
"""
try:
return self._collection.remove(elem)
except KeyError:
raise KeyE... | python | {
"resource": ""
} |
q234976 | Collection.clear | train | def clear(self):
""""Removes all elements from the collection and resets the error handling
"""
self.bad = False
self.errors = {}
self._collection.clear() | python | {
"resource": ""
} |
q234977 | Collection.pop | train | def pop(self):
"""Removes a random element from the collection and returns it
# Returns
`object`
> A random object from the collection
"""
try:
return self._collection.pop()
except KeyError:
raise KeyError("Nothing left in the {}: '{}'."... | python | {
"resource": ""
} |
q234978 | Collection.copy | train | def copy(self):
"""Creates a shallow copy of the collection
# Returns
`Collection`
> A copy of the `Collection`
"""
collectedCopy = copy.copy(self)
collectedCopy._collection = copy.copy(collectedCopy._collection)
self._collectedTypes = copy.copy(self._c... | python | {
"resource": ""
} |
q234979 | Collection.chunk | train | def chunk(self, maxSize):
"""Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all m... | python | {
"resource": ""
} |
q234980 | Collection.split | train | def split(self, maxSize):
"""Destructively, splits the `Collection` into _maxSize_ size or smaller `Collections`. The source `Collection` will be empty after this operation
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
... | python | {
"resource": ""
} |
q234981 | CollectionWithIDs.containsID | train | def containsID(self, idVal):
"""Checks if the collected items contains the give _idVal_
# Parameters
_idVal_ : `str`
> The queried id string
# Returns
`bool`
> `True` if the item is in the collection
"""
for i in self:
if i.id == ... | python | {
"resource": ""
} |
q234982 | CollectionWithIDs.discardID | train | def discardID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and discards it if it is found, will not raise an exception if item is not found
# Parameters
_idVal_ : `str`
> The discarded id string
"""
for i in self:
if i.id == idVa... | python | {
"resource": ""
} |
q234983 | CollectionWithIDs.removeID | train | def removeID(self, idVal):
"""Checks if the collected items contains the give _idVal_ and removes it if it is found, will raise a `KeyError` if item is not found
# Parameters
_idVal_ : `str`
> The removed id string
"""
for i in self:
if i.id == idVal:
... | python | {
"resource": ""
} |
q234984 | CollectionWithIDs.badEntries | train | def badEntries(self):
"""Creates a new collection of the same type with only the bad entries
# Returns
`CollectionWithIDs`
> A collection of only the bad entries
"""
badEntries = set()
for i in self:
if i.bad:
badEntries.add(i)
... | python | {
"resource": ""
} |
q234985 | CollectionWithIDs.dropBadEntries | train | def dropBadEntries(self):
"""Removes all the bad entries from the collection
"""
self._collection = set((i for i in self if not i.bad))
self.bad = False
self.errors = {} | python | {
"resource": ""
} |
q234986 | CollectionWithIDs.tags | train | def tags(self):
"""Creates a list of all the tags of the contained items
# Returns
`list [str]`
> A list of all the tags
"""
tags = set()
for i in self:
tags |= set(i.keys())
return tags | python | {
"resource": ""
} |
q234987 | CollectionWithIDs.rankedSeries | train | def rankedSeries(self, tag, outputFile = None, giveCounts = True, giveRanks = False, greatestFirst = True, pandasMode = True, limitTo = None):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by their number of occurrences. A list can also be returned with the the counts... | python | {
"resource": ""
} |
q234988 | CollectionWithIDs.timeSeries | train | def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list c... | python | {
"resource": ""
} |
q234989 | CollectionWithIDs.cooccurrenceCounts | train | def cooccurrenceCounts(self, keyTag, *countedTags):
"""Counts the number of times values from any of the _countedTags_ occurs with _keyTag_. The counts are retuned as a dictionary with the values of _keyTag_ mapping to dictionaries with each of the _countedTags_ values mapping to thier counts.
# Parame... | python | {
"resource": ""
} |
q234990 | makeNodeID | train | def makeNodeID(Rec, ndType, extras = None):
"""Helper to make a node ID, extras is currently not used"""
if ndType == 'raw':
recID = Rec
else:
recID = Rec.get(ndType)
if recID is None:
pass
elif isinstance(recID, list):
recID = tuple(recID)
else:
recID = r... | python | {
"resource": ""
} |
q234991 | pandoc_process | train | def pandoc_process(app, what, name, obj, options, lines):
""""Convert docstrings in Markdown into reStructureText using pandoc
"""
if not lines:
return None
input_format = app.config.mkdsupport_use_parser
output_format = 'rst'
# Since default encoding for sphinx.ext.autodoc is unicode... | python | {
"resource": ""
} |
q234992 | beginningPage | train | def beginningPage(R):
"""As pages may not be given as numbers this is the most accurate this function can be"""
p = R['PG']
if p.startswith('suppl '):
p = p[6:]
return p.split(' ')[0].split('-')[0].replace(';', '') | python | {
"resource": ""
} |
q234993 | Record.copy | train | def copy(self):
"""Correctly copies the `Record`
# Returns
`Record`
> A completely decoupled copy of the original
"""
c = copy.copy(self)
c._fieldDict = c._fieldDict.copy()
return c | python | {
"resource": ""
} |
q234994 | ExtendedRecord.values | train | def values(self, raw = False):
"""Like `values` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `ValuesView` contains the raw values
# Returns
`ValuesView`
> The values of the record
"""
... | python | {
"resource": ""
} |
q234995 | ExtendedRecord.items | train | def items(self, raw = False):
"""Like `items` for dicts but with a `raw` option
# Parameters
_raw_ : `optional [bool]`
> Default `False`, if `True` the `KeysView` contains the raw values as the values
# Returns
`KeysView`
> The key-value pairs of the record
... | python | {
"resource": ""
} |
q234996 | ExtendedRecord.getCitations | train | def getCitations(self, field = None, values = None, pandasFriendly = True):
"""Creates a pandas ready dict with each row a different citation and columns containing the original string, year, journal and author's name.
There are also options to filter the output citations with _field_ and _values_
... | python | {
"resource": ""
} |
q234997 | ExtendedRecord.subDict | train | def subDict(self, tags, raw = False):
"""Creates a dict of values of _tags_ from the Record. The tags are the keys and the values are the values. If the tag is missing the value will be `None`.
# Parameters
_tags_ : `list[str]`
> The list of tags requested
_raw_ : `optional [... | python | {
"resource": ""
} |
q234998 | ExtendedRecord.authGenders | train | def authGenders(self, countsOnly = False, fractionsMode = False, _countsTuple = False):
"""Creates a dict mapping `'Male'`, `'Female'` and `'Unknown'` to lists of the names of all the authors.
# Parameters
_countsOnly_ : `optional bool`
> Default `False`, if `True` the counts (lengths... | python | {
"resource": ""
} |
q234999 | proQuestParser | train | def proQuestParser(proFile):
"""Parses a ProQuest file, _proFile_, to extract the individual entries.
A ProQuest file has three sections, first a list of the contained entries, second the full metadata and finally a bibtex formatted entry for the record. This parser only uses the first two as the bibtex contai... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.