Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
_delete_1_to_many_inactive_assocskyrgn
()
Delete the assocskyrgn links of the old runcat Since we replaced this runcat.id with multiple new ones, we now delete the old links.
Delete the assocskyrgn links of the old runcat
def _delete_1_to_many_inactive_assocskyrgn(): """Delete the assocskyrgn links of the old runcat Since we replaced this runcat.id with multiple new ones, we now delete the old links. """ query = """\ DELETE FROM assocskyrgn WHERE runcat IN (SELECT runcat FROM temprunni...
[ "def", "_delete_1_to_many_inactive_assocskyrgn", "(", ")", ":", "query", "=", "\"\"\"\\\nDELETE\n FROM assocskyrgn\n WHERE runcat IN (SELECT runcat\n FROM temprunningcatalog\n WHERE inactive = FALSE\n GROUP BY runcat\n ...
[ 1277, 0 ]
[ 1293, 38 ]
python
en
['en', 'en', 'en']
True
_delete_1_to_many_inactive_newsource
()
Delete the newsource sources of the old runcat Since we replaced this runcat.id with multiple new ones, we now delete the old one.
Delete the newsource sources of the old runcat
def _delete_1_to_many_inactive_newsource(): """Delete the newsource sources of the old runcat Since we replaced this runcat.id with multiple new ones, we now delete the old one. """ query = """\ DELETE FROM newsource WHERE runcat IN (SELECT runcat FROM temprunningcata...
[ "def", "_delete_1_to_many_inactive_newsource", "(", ")", ":", "query", "=", "\"\"\"\\\nDELETE\n FROM newsource\n WHERE runcat IN (SELECT runcat\n FROM temprunningcatalog\n WHERE inactive = FALSE\n GROUP BY runcat\n ...
[ 1296, 0 ]
[ 1312, 38 ]
python
en
['en', 'en', 'en']
True
_delete_1_to_many_inactive_assocxtrsource
()
Delete the association pairs of the old runcat from assocxtrsource NOTE: It might sound confusing, but those are not qualified as inactive in tempruncat (read below). Since we replaced this runcat.id with multiple new one, we first flag it as inactive, after which we delete it from the runningcatalog ...
Delete the association pairs of the old runcat from assocxtrsource
def _delete_1_to_many_inactive_assocxtrsource(): """Delete the association pairs of the old runcat from assocxtrsource NOTE: It might sound confusing, but those are not qualified as inactive in tempruncat (read below). Since we replaced this runcat.id with multiple new one, we first flag it as inac...
[ "def", "_delete_1_to_many_inactive_assocxtrsource", "(", ")", ":", "#NB temprunningcatalog 'runcat' field still refers to old,", "#superceded runcat entries.", "query", "=", "\"\"\"\\\nDELETE\n FROM assocxtrsource\n WHERE runcat IN (SELECT runcat\n FROM temprunningcatalog\n...
[ 1315, 0 ]
[ 1342, 38 ]
python
en
['en', 'en', 'en']
True
_delete_1_to_many_inactive_runcat_flux
()
Flag the old runcat ids in the runningcatalog to inactive Since we replaced this runcat.id with multiple new one, we first flag it as inactive, after which we delete it from the runningcatalog
Flag the old runcat ids in the runningcatalog to inactive
def _delete_1_to_many_inactive_runcat_flux(): """Flag the old runcat ids in the runningcatalog to inactive Since we replaced this runcat.id with multiple new one, we first flag it as inactive, after which we delete it from the runningcatalog """ query = """\ DELETE FROM runningcatalog_flux ...
[ "def", "_delete_1_to_many_inactive_runcat_flux", "(", ")", ":", "query", "=", "\"\"\"\\\nDELETE\n FROM runningcatalog_flux\n WHERE runcat IN (SELECT runcat\n FROM temprunningcatalog\n WHERE inactive = FALSE\n GROUP BY runcat\n ...
[ 1345, 0 ]
[ 1362, 38 ]
python
en
['en', 'en', 'en']
True
_flag_1_to_many_inactive_runcat
()
Flag the old runcat ids in the runningcatalog to inactive We do not delete them yet, because we still need to clear up all the superseded entries in assocskyrgn, etc.
Flag the old runcat ids in the runningcatalog to inactive
def _flag_1_to_many_inactive_runcat(): """Flag the old runcat ids in the runningcatalog to inactive We do not delete them yet, because we still need to clear up all the superseded entries in assocskyrgn, etc. """ query = """\ UPDATE runningcatalog SET inactive = TRUE WHERE id IN (SELECT runcat ...
[ "def", "_flag_1_to_many_inactive_runcat", "(", ")", ":", "query", "=", "\"\"\"\\\nUPDATE runningcatalog\n SET inactive = TRUE\n WHERE id IN (SELECT runcat\n FROM temprunningcatalog\n WHERE inactive = FALSE\n GROUP BY runcat\n HAVING COUNT(*) > 1...
[ 1365, 0 ]
[ 1381, 38 ]
python
en
['en', 'en', 'en']
True
_flag_1_to_many_inactive_tempruncat
()
Flag the one-to-many associations from temprunningcatalog. (Since we are done processing them, now.) We do not delete them yet- if we did, we would not be able to cross-match extractedsources to determine which sources did not have a match in temprunningcatalog ('new' sources).
Flag the one-to-many associations from temprunningcatalog.
def _flag_1_to_many_inactive_tempruncat(): """ Flag the one-to-many associations from temprunningcatalog. (Since we are done processing them, now.) We do not delete them yet- if we did, we would not be able to cross-match extractedsources to determine which sources did not have a match in temp...
[ "def", "_flag_1_to_many_inactive_tempruncat", "(", ")", ":", "query", "=", "\"\"\"\\\nUPDATE temprunningcatalog\n SET inactive = TRUE\n WHERE runcat IN (SELECT runcat\n FROM temprunningcatalog\n WHERE inactive = FALSE\n GROUP BY runcat\n ...
[ 1384, 0 ]
[ 1405, 38 ]
python
en
['en', 'error', 'th']
False
_insert_1_to_1_assoc
()
Insert remaining associations from temprunningcatalog into assocxtrsource. We also calculate the variability indices at the timestamp of the the current image.
Insert remaining associations from temprunningcatalog into assocxtrsource.
def _insert_1_to_1_assoc(): """ Insert remaining associations from temprunningcatalog into assocxtrsource. We also calculate the variability indices at the timestamp of the the current image. """ tkp.db.execute(ONE_TO_ONE_ASSOC_QUERY, {'type': 3}, commit=True)
[ "def", "_insert_1_to_1_assoc", "(", ")", ":", "tkp", ".", "db", ".", "execute", "(", "ONE_TO_ONE_ASSOC_QUERY", ",", "{", "'type'", ":", "3", "}", ",", "commit", "=", "True", ")" ]
[ 1462, 0 ]
[ 1469, 68 ]
python
en
['en', 'error', 'th']
False
_update_1_to_1_runcat
()
Update the running catalog with the values in temprunningcatalog
Update the running catalog with the values in temprunningcatalog
def _update_1_to_1_runcat(): """Update the running catalog with the values in temprunningcatalog""" query = """\ UPDATE runningcatalog SET datapoints = (SELECT datapoints FROM temprunningcatalog WHERE temprunningcatalog.runcat = run...
[ "def", "_update_1_to_1_runcat", "(", ")", ":", "query", "=", "\"\"\"\\\n UPDATE runningcatalog\n SET datapoints = (SELECT datapoints\n FROM temprunningcatalog\n WHERE temprunningcatalog.runcat = runningcatalog.id\n ...
[ 1472, 0 ]
[ 1558, 38 ]
python
en
['en', 'en', 'en']
True
_update_1_to_1_runcat_flux
()
Updates the fluxes in runningcatalog_flux of an existing band for an existing runcat source. If the runcat, band, stokes entry does exist in runcat_flux, it will be updated with the values from tempruncat.
Updates the fluxes in runningcatalog_flux of an existing band for an existing runcat source.
def _update_1_to_1_runcat_flux(): """Updates the fluxes in runningcatalog_flux of an existing band for an existing runcat source. If the runcat, band, stokes entry does exist in runcat_flux, it will be updated with the values from tempruncat. """ query = """\ UPDATE runningcatalog_flux SET f...
[ "def", "_update_1_to_1_runcat_flux", "(", ")", ":", "query", "=", "\"\"\"\\\nUPDATE runningcatalog_flux\n SET f_datapoints = (SELECT f_datapoints\n FROM temprunningcatalog\n WHERE temprunningcatalog.runcat = runningcatalog_flux.runcat\n ...
[ 1560, 0 ]
[ 1656, 26 ]
python
en
['en', 'en', 'en']
True
_insert_1_to_1_runcat_flux
()
Insert the fluxes in runningcatalog_flux of a new band for an existing runcat source. If the runcat, band, stokes entry does not exist (yet) in runcat_flux, we need to insert the new values from tempruncat. This might be the case if a source has been observed at other frequencies, but not in the cu...
Insert the fluxes in runningcatalog_flux of a new band for an existing runcat source.
def _insert_1_to_1_runcat_flux(): """Insert the fluxes in runningcatalog_flux of a new band for an existing runcat source. If the runcat, band, stokes entry does not exist (yet) in runcat_flux, we need to insert the new values from tempruncat. This might be the case if a source has been observed at...
[ "def", "_insert_1_to_1_runcat_flux", "(", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog_flux\n (runcat\n ,band\n ,stokes\n ,f_datapoints\n ,avg_f_peak\n ,avg_f_peak_sq\n ,avg_f_peak_weight\n ,avg_weighted_f_peak\n ,avg_weighted_f_peak_sq\n ,avg_f_int\n ,avg_f_int_sq\n ,avg_...
[ 1660, 0 ]
[ 1708, 26 ]
python
en
['en', 'en', 'en']
True
_insert_new_runcat
(image_id)
Insert previously unknown sources into the ``runningcatalog`` table. Extractedsources for which no counterpart was found in the runningcatalog (i.e. no pair exists in tempruncat), will be added as a new source to the assocxtrsource, runningcatalog and runningcatalog_flux tables.
Insert previously unknown sources into the ``runningcatalog`` table.
def _insert_new_runcat(image_id): """Insert previously unknown sources into the ``runningcatalog`` table. Extractedsources for which no counterpart was found in the runningcatalog (i.e. no pair exists in tempruncat), will be added as a new source to the assocxtrsource, runningcatalog and runningcat...
[ "def", "_insert_new_runcat", "(", "image_id", ")", ":", "# NOTE: Here we select all (inactive TRUE&FALSE) tempruncat entries", "# source in order to exclude all extractedsources that have been associated.", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog\n (xtrsrc\n ,dataset\n ,datapoints...
[ 1712, 0 ]
[ 1791, 68 ]
python
en
['en', 'en', 'en']
True
_insert_new_runcat_flux
(image_id)
Insert previously unknown sources into the ``runningcatalog_flux`` table. (i.e. those without *any* previous runcat-counterpart)
Insert previously unknown sources into the ``runningcatalog_flux`` table.
def _insert_new_runcat_flux(image_id): """ Insert previously unknown sources into the ``runningcatalog_flux`` table. (i.e. those without *any* previous runcat-counterpart) """ query = """\ INSERT INTO runningcatalog_flux (runcat ,band ,stokes ,f_datapoints ,avg_f_peak ,avg_f_peak_sq ,avg_f_...
[ "def", "_insert_new_runcat_flux", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog_flux\n (runcat\n ,band\n ,stokes\n ,f_datapoints\n ,avg_f_peak\n ,avg_f_peak_sq\n ,avg_f_peak_weight\n ,avg_weighted_f_peak\n ,avg_weighted_f_peak_sq\n ,avg_f_int\n ,avg_f_int_...
[ 1795, 0 ]
[ 1847, 55 ]
python
en
['en', 'error', 'th']
False
_insert_new_runcat_skyrgn_assocs
(image_id)
Process newly created entries from the runningcatalog, determine which skyregions they lie within. Upon creation of a new runningcatalog entry, we need to determine which previous fields of view (skyrgns) we expect to see it in. This knowledge helps us to make accurate guesses as whether a new...
Process newly created entries from the runningcatalog, determine which skyregions they lie within.
def _insert_new_runcat_skyrgn_assocs(image_id): """ Process newly created entries from the runningcatalog, determine which skyregions they lie within. Upon creation of a new runningcatalog entry, we need to determine which previous fields of view (skyrgns) we expect to see it in. This knowl...
[ "def", "_insert_new_runcat_skyrgn_assocs", "(", "image_id", ")", ":", "# First, mark membership in the skyregion of the image of initial detection.", "# We look for extracted sources from this image", "# that are not in temprunningcatalog, i.e. have no association candidates.", "# By dealing with ...
[ 1850, 0 ]
[ 1939, 69 ]
python
en
['en', 'error', 'th']
False
_insert_new_assocxtrsource
(image_id)
Insert new associations for previously unknown sources.
Insert new associations for previously unknown sources.
def _insert_new_assocxtrsource(image_id): """ Insert new associations for previously unknown sources. """ query = """\ INSERT INTO assocxtrsource (runcat ,xtrsrc ,type ,distance_arcsec ,r ,v_int ,eta_int ,f_datapoints ) SELECT r0.id AS runcat ,r0.xtrsrc ,4 ,0...
[ "def", "_insert_new_assocxtrsource", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO assocxtrsource\n (runcat\n ,xtrsrc\n ,type\n ,distance_arcsec\n ,r\n ,v_int\n ,eta_int\n ,f_datapoints\n )\n SELECT r0.id AS runcat\n ,r0.xtrsrc\n ,4\n ,0\n ,0\n...
[ 1942, 0 ]
[ 1977, 54 ]
python
en
['en', 'error', 'th']
False
_determine_newsource_previous_limits
(image_id, new_source_sigma_margin)
Determines which new-runcat sources are also probably transient. Looks up previous images relevant to this source-position, using the following criteria - images must: - overlap the new-source position, according to the skyregion information; - be in the same dataset; - be in the sa...
Determines which new-runcat sources are also probably transient.
def _determine_newsource_previous_limits(image_id, new_source_sigma_margin): """ Determines which new-runcat sources are also probably transient. Looks up previous images relevant to this source-position, using the following criteria - images must: - overlap the new-source position, according to ...
[ "def", "_determine_newsource_previous_limits", "(", "image_id", ",", "new_source_sigma_margin", ")", ":", "# This is another hairy query, but it breaks down like so:", "#", "# The innermost SELECT (unassoc_xtr) is a standard query", "# that we use to grab extractedsources from the current imag...
[ 1979, 0 ]
[ 2121, 72 ]
python
en
['en', 'error', 'th']
False
_update_ff_runcat_extractedsource
()
We are about to delete the runcats that are inactivated, and therefore have to set the ff_runcat reference in extractedsource to NULL.
We are about to delete the runcats that are inactivated, and therefore have to set the ff_runcat reference in extractedsource to NULL.
def _update_ff_runcat_extractedsource(): """ We are about to delete the runcats that are inactivated, and therefore have to set the ff_runcat reference in extractedsource to NULL. """ query = """\ UPDATE extractedsource SET ff_runcat = NULL WHERE EXISTS (SELECT id FROM runningca...
[ "def", "_update_ff_runcat_extractedsource", "(", ")", ":", "query", "=", "\"\"\"\\\nUPDATE extractedsource\n SET ff_runcat = NULL\n WHERE EXISTS (SELECT id\n FROM runningcatalog\n WHERE runningcatalog.id = extractedsource.ff_runcat\n AND runningcatalog...
[ 2124, 0 ]
[ 2141, 69 ]
python
en
['en', 'error', 'th']
False
_delete_inactive_runcat
()
Delete the one-to-many associations from temprunningcatalog, and delete the inactive rows from runningcatalog. After the one-to-many associations have been processed, they can be deleted from the temporary table and the runningcatalog.
Delete the one-to-many associations from temprunningcatalog, and delete the inactive rows from runningcatalog.
def _delete_inactive_runcat(): """Delete the one-to-many associations from temprunningcatalog, and delete the inactive rows from runningcatalog. After the one-to-many associations have been processed, they can be deleted from the temporary table and the runningcatalog. """ query = """\ DELE...
[ "def", "_delete_inactive_runcat", "(", ")", ":", "query", "=", "\"\"\"\\\nDELETE\n FROM runningcatalog\n WHERE inactive = TRUE\n\"\"\"", "tkp", ".", "db", ".", "execute", "(", "query", ",", "commit", "=", "True", ")" ]
[ 2143, 0 ]
[ 2156, 38 ]
python
en
['en', 'en', 'en']
True
DatabaseOperations.fetch_returned_insert_ids
(self, cursor)
Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, return the list of newly created IDs.
Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, return the list of newly created IDs.
def fetch_returned_insert_ids(self, cursor): """ Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, return the list of newly created IDs. """ return [item[0] for item in cursor.fetchall()]
[ "def", "fetch_returned_insert_ids", "(", "self", ",", "cursor", ")", ":", "return", "[", "item", "[", "0", "]", "for", "item", "in", "cursor", ".", "fetchall", "(", ")", "]" ]
[ 69, 4 ]
[ 75, 54 ]
python
en
['en', 'error', 'th']
False
DatabaseOperations.max_name_length
(self)
Returns the maximum length of an identifier. Note that the maximum length of an identifier is 63 by default, but can be changed by recompiling PostgreSQL after editing the NAMEDATALEN macro in src/include/pg_config_manual.h . This implementation simply returns 63, but can easi...
Returns the maximum length of an identifier.
def max_name_length(self): """ Returns the maximum length of an identifier. Note that the maximum length of an identifier is 63 by default, but can be changed by recompiling PostgreSQL after editing the NAMEDATALEN macro in src/include/pg_config_manual.h . This implemen...
[ "def", "max_name_length", "(", "self", ")", ":", "return", "63" ]
[ 211, 4 ]
[ 223, 17 ]
python
en
['en', 'error', 'th']
False
FootballEnv._convert_observations
(self, original, player, left_player_position, right_player_position)
Converts generic observations returned by the environment to the player specific observations. Args: original: original observations from the environment. player: player for which to generate observations. left_player_position: index into observation corresponding to the left pla...
Converts generic observations returned by the environment to the player specific observations.
def _convert_observations(self, original, player, left_player_position, right_player_position): """Converts generic observations returned by the environment to the player specific observations. Args: original: original observations from the environment. player: pl...
[ "def", "_convert_observations", "(", "self", ",", "original", ",", "player", ",", "left_player_position", ",", "right_player_position", ")", ":", "observations", "=", "[", "]", "for", "is_left", "in", "[", "True", ",", "False", "]", ":", "adopted", "=", "ori...
[ 92, 2 ]
[ 132, 23 ]
python
en
['en', 'en', 'en']
True
WhiteNoiseMiddleware.immutable_file_test
(self, path, url)
Determine whether given URL represents an immutable file (i.e. a file with a hash of its contents as part of its name) which can therefore be cached forever
Determine whether given URL represents an immutable file (i.e. a file with a hash of its contents as part of its name) which can therefore be cached forever
def immutable_file_test(self, path, url): """ Determine whether given URL represents an immutable file (i.e. a file with a hash of its contents as part of its name) which can therefore be cached forever """ if not url.startswith(self.static_prefix): return Fal...
[ "def", "immutable_file_test", "(", "self", ",", "path", ",", "url", ")", ":", "if", "not", "url", ".", "startswith", "(", "self", ".", "static_prefix", ")", ":", "return", "False", "name", "=", "url", "[", "len", "(", "self", ".", "static_prefix", ")",...
[ 132, 4 ]
[ 150, 20 ]
python
en
['en', 'error', 'th']
False
WhiteNoiseMiddleware.get_name_without_hash
(self, filename)
Removes the version hash from a filename e.g, transforms 'css/application.f3ea4bcc2.css' into 'css/application.css' Note: this is specific to the naming scheme used by Django's CachedStaticFilesStorage. You may have to override this if you are using a different static files ver...
Removes the version hash from a filename e.g, transforms 'css/application.f3ea4bcc2.css' into 'css/application.css'
def get_name_without_hash(self, filename): """ Removes the version hash from a filename e.g, transforms 'css/application.f3ea4bcc2.css' into 'css/application.css' Note: this is specific to the naming scheme used by Django's CachedStaticFilesStorage. You may have to override this...
[ "def", "get_name_without_hash", "(", "self", ",", "filename", ")", ":", "name_with_hash", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "name", "=", "os", ".", "path", ".", "splitext", "(", "name_with_hash", ")", "[", "0", ...
[ 152, 4 ]
[ 163, 25 ]
python
en
['en', 'error', 'th']
False
bdist_wininst.reinitialize_command
(self, command, reinit_subcommands=0)
Supplement reinitialize_command to work around http://bugs.python.org/issue20819
Supplement reinitialize_command to work around http://bugs.python.org/issue20819
def reinitialize_command(self, command, reinit_subcommands=0): """ Supplement reinitialize_command to work around http://bugs.python.org/issue20819 """ cmd = self.distribution.reinitialize_command( command, reinit_subcommands) if command in ('install', 'instal...
[ "def", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", "=", "0", ")", ":", "cmd", "=", "self", ".", "distribution", ".", "reinitialize_command", "(", "command", ",", "reinit_subcommands", ")", "if", "command", "in", "(", "'insta...
[ 7, 4 ]
[ 16, 18 ]
python
en
['en', 'error', 'th']
False
BroadcastWebsocketStatsManager.get_stats_sync
(cls)
Stringified verion of all the stats
Stringified verion of all the stats
def get_stats_sync(cls): """ Stringified verion of all the stats """ redis_conn = redis.Redis.from_url(settings.BROKER_URL) stats_str = redis_conn.get(BROADCAST_WEBSOCKET_REDIS_KEY_NAME) or b'' return parser.text_string_to_metric_families(stats_str.decode('UTF-8'))
[ "def", "get_stats_sync", "(", "cls", ")", ":", "redis_conn", "=", "redis", ".", "Redis", ".", "from_url", "(", "settings", ".", "BROKER_URL", ")", "stats_str", "=", "redis_conn", ".", "get", "(", "BROADCAST_WEBSOCKET_REDIS_KEY_NAME", ")", "or", "b''", "return"...
[ 100, 4 ]
[ 106, 79 ]
python
en
['en', 'error', 'th']
False
Timeout._validate_timeout
(cls, value, name)
Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version of the given value. :raises ValueError: If it...
Check that a timeout attribute is valid.
def _validate_timeout(cls, value, name): """Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version o...
[ "def", "_validate_timeout", "(", "cls", ",", "value", ",", "name", ")", ":", "if", "value", "is", "_Default", ":", "return", "cls", ".", "DEFAULT_TIMEOUT", "if", "value", "is", "None", "or", "value", "is", "cls", ".", "DEFAULT_TIMEOUT", ":", "return", "v...
[ 119, 4 ]
[ 162, 20 ]
python
en
['en', 'en', 'en']
True
Timeout.from_float
(cls, timeout)
Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value passed to this function. ...
Create a new Timeout from a legacy timeout value.
def from_float(cls, timeout): """Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value ...
[ "def", "from_float", "(", "cls", ",", "timeout", ")", ":", "return", "Timeout", "(", "read", "=", "timeout", ",", "connect", "=", "timeout", ")" ]
[ 165, 4 ]
[ 178, 53 ]
python
en
['en', 'en', 'en']
True
Timeout.clone
(self)
Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout`
Create a copy of the timeout object
def clone(self): """Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout` """ ...
[ "def", "clone", "(", "self", ")", ":", "# We can't use copy.deepcopy because that will also create a new object", "# for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to", "# detect the user default.", "return", "Timeout", "(", "connect", "=", "self", ".", "_connect", ...
[ 180, 4 ]
[ 192, 80 ]
python
en
['en', 'en', 'en']
True
Timeout.start_connect
(self)
Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already.
Start the timeout clock, used during a connect() attempt
def start_connect(self): """Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already. """ if self._start_connect is not None: raise TimeoutStateError("Time...
[ "def", "start_connect", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "not", "None", ":", "raise", "TimeoutStateError", "(", "\"Timeout timer has already been started.\"", ")", "self", ".", "_start_connect", "=", "current_time", "(", ")", "retu...
[ 194, 4 ]
[ 203, 34 ]
python
en
['en', 'en', 'en']
True
Timeout.get_connect_duration
(self)
Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started.
Gets the time elapsed since the call to :meth:`start_connect`.
def get_connect_duration(self): """Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started. """ ...
[ "def", "get_connect_duration", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "None", ":", "raise", "TimeoutStateError", "(", "\"Can't get connect duration for timer that has not started.\"", ")", "return", "current_time", "(", ")", "-", "self", "."...
[ 205, 4 ]
[ 217, 51 ]
python
en
['en', 'en', 'en']
True
Timeout.connect_timeout
(self)
Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
Get the value to use when setting a connection timeout.
def connect_timeout(self): """Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None ...
[ "def", "connect_timeout", "(", "self", ")", ":", "if", "self", ".", "total", "is", "None", ":", "return", "self", ".", "_connect", "if", "self", ".", "_connect", "is", "None", "or", "self", ".", "_connect", "is", "self", ".", "DEFAULT_TIMEOUT", ":", "r...
[ 220, 4 ]
[ 235, 45 ]
python
en
['en', 'en', 'en']
True
Timeout.read_timeout
(self)
Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If the connection time has not been ...
Get the value for the read timeout.
def read_timeout(self): """Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If th...
[ "def", "read_timeout", "(", "self", ")", ":", "if", "(", "self", ".", "total", "is", "not", "None", "and", "self", ".", "total", "is", "not", "self", ".", "DEFAULT_TIMEOUT", "and", "self", ".", "_read", "is", "not", "None", "and", "self", ".", "_read...
[ 238, 4 ]
[ 267, 29 ]
python
en
['en', 'en', 'en']
True
TestFormResponsesPanel.test_render_with_submissions
(self)
Show the panel with the count of submission and a link to the list_submissions view.
Show the panel with the count of submission and a link to the list_submissions view.
def test_render_with_submissions(self): """Show the panel with the count of submission and a link to the list_submissions view.""" self.client.post('/contact-us/', { 'your_email': 'bob@example.com', 'your_message': 'hello world', 'your_choices': {'foo': '', 'bar': '',...
[ "def", "test_render_with_submissions", "(", "self", ")", ":", "self", ".", "client", ".", "post", "(", "'/contact-us/'", ",", "{", "'your_email'", ":", "'bob@example.com'", ",", "'your_message'", ":", "'hello world'", ",", "'your_choices'", ":", "{", "'foo'", ":...
[ 41, 4 ]
[ 54, 35 ]
python
en
['en', 'en', 'en']
True
TestFormResponsesPanel.test_render_without_submissions
(self)
The panel should not be shown if the number of submission is zero.
The panel should not be shown if the number of submission is zero.
def test_render_without_submissions(self): """The panel should not be shown if the number of submission is zero.""" result = self.panel.render() self.assertEqual('', result)
[ "def", "test_render_without_submissions", "(", "self", ")", ":", "result", "=", "self", ".", "panel", ".", "render", "(", ")", "self", ".", "assertEqual", "(", "''", ",", "result", ")" ]
[ 56, 4 ]
[ 60, 36 ]
python
en
['en', 'en', 'en']
True
TestFormResponsesPanelWithCustomSubmissionClass.test_render_with_submissions
(self)
Show the panel with the count of submission and a link to the list_submissions view.
Show the panel with the count of submission and a link to the list_submissions view.
def test_render_with_submissions(self): """Show the panel with the count of submission and a link to the list_submissions view.""" new_form_submission = CustomFormPageSubmission.objects.create( user=self.test_user, page=self.form_page, form_data=json.dumps({ ...
[ "def", "test_render_with_submissions", "(", "self", ")", ":", "new_form_submission", "=", "CustomFormPageSubmission", ".", "objects", ".", "create", "(", "user", "=", "self", ".", "test_user", ",", "page", "=", "self", ".", "form_page", ",", "form_data", "=", ...
[ 82, 4 ]
[ 101, 35 ]
python
en
['en', 'en', 'en']
True
TestFormResponsesPanelWithCustomSubmissionClass.test_render_without_submissions
(self)
The panel should not be shown if the number of submission is zero.
The panel should not be shown if the number of submission is zero.
def test_render_without_submissions(self): """The panel should not be shown if the number of submission is zero.""" result = self.panel.render() self.assertEqual('', result)
[ "def", "test_render_without_submissions", "(", "self", ")", ":", "result", "=", "self", ".", "panel", ".", "render", "(", ")", "self", ".", "assertEqual", "(", "''", ",", "result", ")" ]
[ 103, 4 ]
[ 107, 36 ]
python
en
['en', 'en', 'en']
True
TestFormsIndex.make_form_pages
(self)
This makes 100 form pages and adds them as children to 'contact-us' This is used to test pagination on the forms index
This makes 100 form pages and adds them as children to 'contact-us' This is used to test pagination on the forms index
def make_form_pages(self): """ This makes 100 form pages and adds them as children to 'contact-us' This is used to test pagination on the forms index """ for i in range(100): self.form_page.add_child(instance=FormPage( title="Form " + str(i), ...
[ "def", "make_form_pages", "(", "self", ")", ":", "for", "i", "in", "range", "(", "100", ")", ":", "self", ".", "form_page", ".", "add_child", "(", "instance", "=", "FormPage", "(", "title", "=", "\"Form \"", "+", "str", "(", "i", ")", ",", "slug", ...
[ 117, 4 ]
[ 127, 14 ]
python
en
['en', 'error', 'th']
False
TestFormsSubmissionsList.make_list_submissions
(self)
This makes 100 submissions to test pagination on the forms submissions page
This makes 100 submissions to test pagination on the forms submissions page
def make_list_submissions(self): """ This makes 100 submissions to test pagination on the forms submissions page """ for i in range(100): submission = FormSubmission( page=self.form_page, form_data=json.dumps({ 'hello': 'wor...
[ "def", "make_list_submissions", "(", "self", ")", ":", "for", "i", "in", "range", "(", "100", ")", ":", "submission", "=", "FormSubmission", "(", "page", "=", "self", ".", "form_page", ",", "form_data", "=", "json", ".", "dumps", "(", "{", "'hello'", "...
[ 247, 4 ]
[ 258, 29 ]
python
en
['en', 'error', 'th']
False
TestCustomFormsSubmissionsList.make_list_submissions
(self)
This makes 100 submissions to test pagination on the forms submissions page
This makes 100 submissions to test pagination on the forms submissions page
def make_list_submissions(self): """ This makes 100 submissions to test pagination on the forms submissions page """ for i in range(100): submission = CustomFormPageSubmission( user=self.create_test_user_without_admin('generated-username-%s' % i), ...
[ "def", "make_list_submissions", "(", "self", ")", ":", "for", "i", "in", "range", "(", "100", ")", ":", "submission", "=", "CustomFormPageSubmission", "(", "user", "=", "self", ".", "create_test_user_without_admin", "(", "'generated-username-%s'", "%", "i", ")",...
[ 876, 4 ]
[ 889, 29 ]
python
en
['en', 'error', 'th']
False
TestFormsWithCustomSubmissionsList.make_list_submissions
(self)
Make 100 submissions to test pagination on the forms submissions page
Make 100 submissions to test pagination on the forms submissions page
def make_list_submissions(self): """ Make 100 submissions to test pagination on the forms submissions page """ for i in range(120): submission = CustomFormPageSubmission( page=self.form_page, user=self.test_user_1, form_data=json.dumps({ ...
[ "def", "make_list_submissions", "(", "self", ")", ":", "for", "i", "in", "range", "(", "120", ")", ":", "submission", "=", "CustomFormPageSubmission", "(", "page", "=", "self", ".", "form_page", ",", "user", "=", "self", ".", "test_user_1", ",", "form_data...
[ 1196, 4 ]
[ 1208, 29 ]
python
en
['en', 'en', 'en']
True
TestDuplicateFormFieldLabels.test_adding_duplicate_form_labels_as_cleaned_name
(self)
Ensure form submission fails when attempting to create labels that will resolve to the same internal clean_name on the form field.
Ensure form submission fails when attempting to create labels that will resolve to the same internal clean_name on the form field.
def test_adding_duplicate_form_labels_as_cleaned_name(self): """ Ensure form submission fails when attempting to create labels that will resolve to the same internal clean_name on the form field. """ post_data = { 'title': "Form page!", 'content': "Some c...
[ "def", "test_adding_duplicate_form_labels_as_cleaned_name", "(", "self", ")", ":", "post_data", "=", "{", "'title'", ":", "\"Form page!\"", ",", "'content'", ":", "\"Some content\"", ",", "'slug'", ":", "'contact-us'", ",", "'form_fields-TOTAL_FORMS'", ":", "'3'", ","...
[ 1374, 4 ]
[ 1407, 9 ]
python
en
['en', 'error', 'th']
False
generic_inlineformset_factory
(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, ...
Returns a ``GenericInlineFormSet`` for the given kwargs. You must provide ``ct_field`` and ``fk_field`` if they are different from the defaults ``content_type`` and ``object_id`` respectively.
Returns a ``GenericInlineFormSet`` for the given kwargs.
def generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=...
[ "def", "generic_inlineformset_factory", "(", "model", ",", "form", "=", "ModelForm", ",", "formset", "=", "BaseGenericInlineFormSet", ",", "ct_field", "=", "\"content_type\"", ",", "fk_field", "=", "\"object_id\"", ",", "fields", "=", "None", ",", "exclude", "=", ...
[ 48, 0 ]
[ 82, 18 ]
python
en
['en', 'error', 'th']
False
TestOutgoingWebhookMessaging.test_empty_string_json_as_response_to_outgoing_webhook_request
(self)
Verifies that if the response to the request triggered by mentioning the bot is the json representation of the empty string, the outcome is the same as {"response_not_required": True} - since this behavior is kept for backwards-compatibility.
Verifies that if the response to the request triggered by mentioning the bot is the json representation of the empty string, the outcome is the same as {"response_not_required": True} - since this behavior is kept for backwards-compatibility.
def test_empty_string_json_as_response_to_outgoing_webhook_request(self) -> None: """ Verifies that if the response to the request triggered by mentioning the bot is the json representation of the empty string, the outcome is the same as {"response_not_required": True} - since this behav...
[ "def", "test_empty_string_json_as_response_to_outgoing_webhook_request", "(", "self", ")", "->", "None", ":", "bot_owner", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "bot", "=", "self", ".", "create_outgoing_bot", "(", "bot_owner", ")", "responses", ...
[ 514, 4 ]
[ 543, 60 ]
python
en
['en', 'error', 'th']
False
LinearGeometryMixin.merged
(self)
Return the line merge of this Geometry.
Return the line merge of this Geometry.
def merged(self): """ Return the line merge of this Geometry. """ return self._topology(capi.geos_linemerge(self.ptr))
[ "def", "merged", "(", "self", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "geos_linemerge", "(", "self", ".", "ptr", ")", ")" ]
[ 704, 4 ]
[ 708, 60 ]
python
en
['en', 'error', 'th']
False
LinearGeometryMixin.closed
(self)
Return whether or not this Geometry is closed.
Return whether or not this Geometry is closed.
def closed(self): """ Return whether or not this Geometry is closed. """ return capi.geos_isclosed(self.ptr)
[ "def", "closed", "(", "self", ")", ":", "return", "capi", ".", "geos_isclosed", "(", "self", ".", "ptr", ")" ]
[ 711, 4 ]
[ 715, 43 ]
python
en
['en', 'error', 'th']
False
permission_denied
(request)
Return a standard 'permission denied' response
Return a standard 'permission denied' response
def permission_denied(request): """Return a standard 'permission denied' response""" if request.is_ajax(): raise PermissionDenied from wagtail.admin import messages messages.error(request, _('Sorry, you do not have permission to access this area.')) return redirect('wagtailadmin_home')
[ "def", "permission_denied", "(", "request", ")", ":", "if", "request", ".", "is_ajax", "(", ")", ":", "raise", "PermissionDenied", "from", "wagtail", ".", "admin", "import", "messages", "messages", ".", "error", "(", "request", ",", "_", "(", "'Sorry, you do...
[ 35, 0 ]
[ 43, 40 ]
python
en
['es', 'mt', 'en']
False
user_passes_test
(test)
Given a test function that takes a user object and returns a boolean, return a view decorator that denies access to the user if the test returns false.
Given a test function that takes a user object and returns a boolean, return a view decorator that denies access to the user if the test returns false.
def user_passes_test(test): """ Given a test function that takes a user object and returns a boolean, return a view decorator that denies access to the user if the test returns false. """ def decorator(view_func): # decorator takes the view function, and returns the view wrapped in #...
[ "def", "user_passes_test", "(", "test", ")", ":", "def", "decorator", "(", "view_func", ")", ":", "# decorator takes the view function, and returns the view wrapped in", "# a permission check", "@", "wraps", "(", "view_func", ")", "def", "wrapped_view_func", "(", "request...
[ 46, 0 ]
[ 66, 20 ]
python
en
['en', 'error', 'th']
False
permission_required
(permission_name)
Replacement for django.contrib.auth.decorators.permission_required which returns a more meaningful 'permission denied' response than just redirecting to the login page. (The latter doesn't work anyway because Wagtail doesn't define LOGIN_URL...)
Replacement for django.contrib.auth.decorators.permission_required which returns a more meaningful 'permission denied' response than just redirecting to the login page. (The latter doesn't work anyway because Wagtail doesn't define LOGIN_URL...)
def permission_required(permission_name): """ Replacement for django.contrib.auth.decorators.permission_required which returns a more meaningful 'permission denied' response than just redirecting to the login page. (The latter doesn't work anyway because Wagtail doesn't define LOGIN_URL...) """ ...
[ "def", "permission_required", "(", "permission_name", ")", ":", "def", "test", "(", "user", ")", ":", "return", "user", ".", "has_perm", "(", "permission_name", ")", "# user_passes_test constructs a decorator function specific to the above test function", "return", "user_pa...
[ 69, 0 ]
[ 79, 33 ]
python
en
['en', 'error', 'th']
False
any_permission_required
(*perms)
Decorator that accepts a list of permission names, and allows the user to pass if they have *any* of the permissions in the list
Decorator that accepts a list of permission names, and allows the user to pass if they have *any* of the permissions in the list
def any_permission_required(*perms): """ Decorator that accepts a list of permission names, and allows the user to pass if they have *any* of the permissions in the list """ def test(user): for perm in perms: if user.has_perm(perm): return True return Fal...
[ "def", "any_permission_required", "(", "*", "perms", ")", ":", "def", "test", "(", "user", ")", ":", "for", "perm", "in", "perms", ":", "if", "user", ".", "has_perm", "(", "perm", ")", ":", "return", "True", "return", "False", "return", "user_passes_test...
[ 82, 0 ]
[ 94, 33 ]
python
en
['en', 'error', 'th']
False
user_has_any_page_permission
(user)
Check if a user has any permission to add, edit, or otherwise manage any page.
Check if a user has any permission to add, edit, or otherwise manage any page.
def user_has_any_page_permission(user): """ Check if a user has any permission to add, edit, or otherwise manage any page. """ # Can't do nothin' if you're not active. if not user.is_active: return False # Superusers can do anything. if user.is_superuser: return True ...
[ "def", "user_has_any_page_permission", "(", "user", ")", ":", "# Can't do nothin' if you're not active.", "if", "not", "user", ".", "is_active", ":", "return", "False", "# Superusers can do anything.", "if", "user", ".", "is_superuser", ":", "return", "True", "# At leas...
[ 118, 0 ]
[ 139, 16 ]
python
en
['en', 'error', 'th']
False
WrappedModelRegression.__init__
(self, regressor, transformer)
Create WrappedModelRegression object. Override __name__ and __class__ attributes with appropriate attributes from regressor. Args: regressor (sklearn.Model): Model used to predict regression target transformer (sklearn.Transformer): Transformer used to transform y (target) ...
Create WrappedModelRegression object.
def __init__(self, regressor, transformer): """Create WrappedModelRegression object. Override __name__ and __class__ attributes with appropriate attributes from regressor. Args: regressor (sklearn.Model): Model used to predict regression target transformer (sklearn.Tran...
[ "def", "__init__", "(", "self", ",", "regressor", ",", "transformer", ")", ":", "self", ".", "clf", "=", "TransformedTargetRegressor", "(", "regressor", "=", "regressor", ",", "transformer", "=", "transformer", ")", "self", ".", "__name__", "=", "self", ".",...
[ 41, 4 ]
[ 52, 53 ]
python
en
['en', 'en', 'en']
True
WrappedModelRegression.fit
(self, *args, **kwargs)
Fit Model in clf attribute with provided arguments. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: self
Fit Model in clf attribute with provided arguments.
def fit(self, *args, **kwargs): """Fit Model in clf attribute with provided arguments. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: self """ self.clf.fit(*args, **kwargs) return self
[ "def", "fit", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "clf", ".", "fit", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self" ]
[ 54, 4 ]
[ 65, 19 ]
python
en
['en', 'en', 'en']
True
WrappedModelRegression.predict
(self, *args, **kwargs)
Predict provided arguments with Model in clf attribute. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: numpy.ndarray: predictions
Predict provided arguments with Model in clf attribute.
def predict(self, *args, **kwargs): """Predict provided arguments with Model in clf attribute. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: numpy.ndarray: predictions """ return self.clf.predict(...
[ "def", "predict", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "clf", ".", "predict", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 67, 4 ]
[ 77, 48 ]
python
en
['en', 'en', 'en']
True
WrappedModelRegression.get_params
(self, *args, **kwargs)
Return params of regressor inside wrapped clf Model. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: dict: params of regressor
Return params of regressor inside wrapped clf Model.
def get_params(self, *args, **kwargs): """Return params of regressor inside wrapped clf Model. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: dict: params of regressor """ return self.clf.regressor...
[ "def", "get_params", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "clf", ".", "regressor", ".", "get_params", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 79, 4 ]
[ 89, 61 ]
python
en
['en', 'pt', 'en']
True
WrappedModelRegression.__str__
(self)
Return __str__method of regressor inside wrapped clf Model. Returns: str: __str__ method of regressor
Return __str__method of regressor inside wrapped clf Model.
def __str__(self): """Return __str__method of regressor inside wrapped clf Model. Returns: str: __str__ method of regressor """ return self.clf.regressor.__str__()
[ "def", "__str__", "(", "self", ")", ":", "return", "self", ".", "clf", ".", "regressor", ".", "__str__", "(", ")" ]
[ 91, 4 ]
[ 97, 43 ]
python
en
['en', 'no', 'en']
True
WrappedModelRegression.__class__
(self, *args, **kwargs)
Return new object of regressor class instantiated with *args and **kwargs arguments. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: regressor: new regressor object
Return new object of regressor class instantiated with *args and **kwargs arguments.
def __class__(self, *args, **kwargs): """Return new object of regressor class instantiated with *args and **kwargs arguments. Args: *args: Variable length argument list. **kwargs: Arbitrary keyword arguments. Returns: regressor: new regressor object ...
[ "def", "__class__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "clf", ".", "regressor", ".", "__class__", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 99, 4 ]
[ 110, 60 ]
python
en
['en', 'en', 'en']
True
ModelFinder.__init__
(self, X, y, X_train, X_test, y_train, y_test, target_type, random_state=None)
Create ModelFinder object with provided X and y arguments. Set default values of attributes and create dummy model depending on target_type. Args: X (pandas.DataFrame, numpy.ndarray, scipy.csr_matrix): X feature space (transformed) y (pandas.Series, numpy.ndarray): target varia...
Create ModelFinder object with provided X and y arguments.
def __init__(self, X, y, X_train, X_test, y_train, y_test, target_type, random_state=None): """Create ModelFinder object with provided X and y arguments. Set default values of attributes and create dummy model depending on target_type. Args: X (pandas.DataFrame, numpy.ndarray, scip...
[ "def", "__init__", "(", "self", ",", "X", ",", "y", ",", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", ",", "target_type", ",", "random_state", "=", "None", ")", ":", "self", ".", "random_state", "=", "random_state", "self", ".", "X", "=", ...
[ 175, 4 ]
[ 219, 80 ]
python
en
['en', 'en', 'en']
True
ModelFinder.search_and_fit
(self, models=None, scoring=None, mode=_mode_quick)
Search for the Model and set it as the chosen Model. Refer to specific functions for further details. Args: models (list, dict, optional): list or 'model class': param_grid dict pairs, defaults to None scoring (func, optional): scoring function with which performance assessment...
Search for the Model and set it as the chosen Model.
def search_and_fit(self, models=None, scoring=None, mode=_mode_quick): """Search for the Model and set it as the chosen Model. Refer to specific functions for further details. Args: models (list, dict, optional): list or 'model class': param_grid dict pairs, defaults to None ...
[ "def", "search_and_fit", "(", "self", ",", "models", "=", "None", ",", "scoring", "=", "None", ",", "mode", "=", "_mode_quick", ")", ":", "model", "=", "self", ".", "search", "(", "models", ",", "scoring", ",", "mode", ")", "self", ".", "set_model", ...
[ 225, 4 ]
[ 241, 33 ]
python
en
['en', 'en', 'en']
True
ModelFinder.set_model_and_fit
(self, model)
Set provided model as a chosen Model of ModelFinder and fit it to X and y data. Args: model (sklearn.Model): instantiated Model
Set provided model as a chosen Model of ModelFinder and fit it to X and y data.
def set_model_and_fit(self, model): """Set provided model as a chosen Model of ModelFinder and fit it to X and y data. Args: model (sklearn.Model): instantiated Model """ self.set_model(model) self.fit()
[ "def", "set_model_and_fit", "(", "self", ",", "model", ")", ":", "self", ".", "set_model", "(", "model", ")", "self", ".", "fit", "(", ")" ]
[ 243, 4 ]
[ 250, 18 ]
python
en
['en', 'en', 'en']
True
ModelFinder.search
(self, models=None, scoring=None, mode=_mode_quick)
Search for Models that have the best performance with provided arguments. Models can be: - list of initialized models - dict of 'Model Class': param_grid of a given model to do the GridSearch on - None - default Models collection will be used scoring should be a skl...
Search for Models that have the best performance with provided arguments.
def search(self, models=None, scoring=None, mode=_mode_quick): """Search for Models that have the best performance with provided arguments. Models can be: - list of initialized models - dict of 'Model Class': param_grid of a given model to do the GridSearch on - None...
[ "def", "search", "(", "self", ",", "models", "=", "None", ",", "scoring", "=", "None", ",", "mode", "=", "_mode_quick", ")", ":", "if", "scoring", "is", "None", ":", "scoring", "=", "self", ".", "default_scoring", "if", "mode", "not", "in", "self", "...
[ 252, 4 ]
[ 315, 24 ]
python
en
['en', 'en', 'en']
True
ModelFinder.set_model
(self, model)
Set model as a chosen ModelFinder model. Create additional copy of the model and calculate it's scores with scoring functions specific to a given problem. Args: model (sklearn.Model): Instantiated Model
Set model as a chosen ModelFinder model.
def set_model(self, model): """Set model as a chosen ModelFinder model. Create additional copy of the model and calculate it's scores with scoring functions specific to a given problem. Args: model (sklearn.Model): Instantiated Model """ model = self._wrap_m...
[ "def", "set_model", "(", "self", ",", "model", ")", ":", "model", "=", "self", ".", "_wrap_model", "(", "model", ")", "params", "=", "model", ".", "get_params", "(", ")", "copy_for_scoring", "=", "model", ".", "__class__", "(", "*", "*", "params", ")",...
[ 317, 4 ]
[ 331, 93 ]
python
en
['en', 'da', 'en']
True
ModelFinder.best_model
(self)
Return _chosen_model attribute (chosen Model). Returns: sklearn.Model
Return _chosen_model attribute (chosen Model).
def best_model(self): """Return _chosen_model attribute (chosen Model). Returns: sklearn.Model """ return self._chosen_model
[ "def", "best_model", "(", "self", ")", ":", "return", "self", ".", "_chosen_model" ]
[ 333, 4 ]
[ 339, 33 ]
python
da
['da', 'no', 'en']
False
ModelFinder.fit
(self)
Fit chosen Model from _chosen_model attribute on X and y data. Raises: ModelNotSetError: when no Model was set as a chosen Model
Fit chosen Model from _chosen_model attribute on X and y data.
def fit(self): """Fit chosen Model from _chosen_model attribute on X and y data. Raises: ModelNotSetError: when no Model was set as a chosen Model """ if self._chosen_model is None: raise ModelNotSetError( "Model needs to be set before fitting. Ca...
[ "def", "fit", "(", "self", ")", ":", "if", "self", ".", "_chosen_model", "is", "None", ":", "raise", "ModelNotSetError", "(", "\"Model needs to be set before fitting. Call 'set_model' or 'search' for a model before trying to fit.\"", ")", "self", ".", "_chosen_model", ".", ...
[ 341, 4 ]
[ 351, 46 ]
python
en
['en', 'en', 'en']
True
ModelFinder.predict
(self, X)
Predict target variable from provided X features. Returns: numpy.ndarray: predicted target values from X Raises: ModelNotSetError: when no Model was set as a chosen Model
Predict target variable from provided X features.
def predict(self, X): """Predict target variable from provided X features. Returns: numpy.ndarray: predicted target values from X Raises: ModelNotSetError: when no Model was set as a chosen Model """ if self._chosen_model is None: raise Model...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "if", "self", ".", "_chosen_model", "is", "None", ":", "raise", "ModelNotSetError", "(", "\"Model needs to be set and fitted before prediction. Call 'set_model' or 'search' for a model before.\"", ")", "return", "self", "...
[ 353, 4 ]
[ 366, 44 ]
python
en
['en', 'en', 'en']
True
ModelFinder.quicksearch_results
(self)
Return quicksearch results from _quicksearch_results attribute. Returns: pandas.DataFrame
Return quicksearch results from _quicksearch_results attribute.
def quicksearch_results(self): """Return quicksearch results from _quicksearch_results attribute. Returns: pandas.DataFrame """ return self._quicksearch_results
[ "def", "quicksearch_results", "(", "self", ")", ":", "return", "self", ".", "_quicksearch_results" ]
[ 368, 4 ]
[ 374, 40 ]
python
en
['en', 'en', 'en']
True
ModelFinder.gridsearch_results
(self)
Return gridsearch results from _gridsearch_results attribute. Returns: pandas.DataFrame
Return gridsearch results from _gridsearch_results attribute.
def gridsearch_results(self): """Return gridsearch results from _gridsearch_results attribute. Returns: pandas.DataFrame """ return self._gridsearch_results
[ "def", "gridsearch_results", "(", "self", ")", ":", "return", "self", ".", "_gridsearch_results" ]
[ 376, 4 ]
[ 382, 39 ]
python
en
['en', 'en', 'en']
True
ModelFinder.search_results
(self, model_limit)
Return detailed search results DataFrame from _search_results_dataframe. model_limit restricts the number of Models and their results to be returned. Number of rows in the DataFrame is always model_limit + 1, as results from Dummy Model are being appended at the end. Args: model_li...
Return detailed search results DataFrame from _search_results_dataframe.
def search_results(self, model_limit): """Return detailed search results DataFrame from _search_results_dataframe. model_limit restricts the number of Models and their results to be returned. Number of rows in the DataFrame is always model_limit + 1, as results from Dummy Model are being append...
[ "def", "search_results", "(", "self", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results_dataframe", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "# dummy is a...
[ 388, 4 ]
[ 411, 17 ]
python
en
['en', 'en', 'en']
True
ModelFinder.dataframe_params_name
(self)
Return params column name. Returns: str
Return params column name.
def dataframe_params_name(self): """Return params column name. Returns: str """ return self._params_name
[ "def", "dataframe_params_name", "(", "self", ")", ":", "return", "self", ".", "_params_name" ]
[ 413, 4 ]
[ 419, 32 ]
python
en
['en', 'id', 'en']
True
ModelFinder.test_target_proportion
(self)
Calculate and return proportion of positive label (1) in target variable when compared with all observations. Note: Meaningless results are returned when used in regression or multiclass problems. Returns: float: proportion of positive label in target variable
Calculate and return proportion of positive label (1) in target variable when compared with all observations.
def test_target_proportion(self): """Calculate and return proportion of positive label (1) in target variable when compared with all observations. Note: Meaningless results are returned when used in regression or multiclass problems. Returns: float: proportion of positi...
[ "def", "test_target_proportion", "(", "self", ")", ":", "# only meaningful in binary classification", "return", "self", ".", "y_test", ".", "sum", "(", ")", "/", "self", ".", "y_test", ".", "shape", "[", "0", "]" ]
[ 421, 4 ]
[ 431, 55 ]
python
en
['en', 'en', 'en']
True
ModelFinder.roc_curves
(self, model_limit)
Return data for ROC curves for model_limit # of Models from search results. Note: Useful only in classification. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, data for curve)
Return data for ROC curves for model_limit # of Models from search results.
def roc_curves(self, model_limit): """Return data for ROC curves for model_limit # of Models from search results. Note: Useful only in classification. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (mod...
[ "def", "roc_curves", "(", "self", ",", "model_limit", ")", ":", "return", "self", ".", "_plot_curves", "(", "roc_curve", ",", "model_limit", ")" ]
[ 433, 4 ]
[ 445, 56 ]
python
en
['en', 'en', 'en']
True
ModelFinder.precision_recall_curves
(self, model_limit)
Return data for Precision-Recall curves for model_limit # of Models from search results. Args: model_limit (int): number of Models from search results Note: Useful only in classification. Returns: list: list of tuples - (model, data for curve)
Return data for Precision-Recall curves for model_limit # of Models from search results.
def precision_recall_curves(self, model_limit): """Return data for Precision-Recall curves for model_limit # of Models from search results. Args: model_limit (int): number of Models from search results Note: Useful only in classification. Returns: l...
[ "def", "precision_recall_curves", "(", "self", ",", "model_limit", ")", ":", "return", "self", ".", "_plot_curves", "(", "precision_recall_curve", ",", "model_limit", ")" ]
[ 447, 4 ]
[ 459, 69 ]
python
en
['en', 'en', 'en']
True
ModelFinder.det_curves
(self, model_limit)
Return data for Detection-Error Tradeoff curves for model_limit # of Models from search results. Note: Useful only in classification. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, data for curve) ...
Return data for Detection-Error Tradeoff curves for model_limit # of Models from search results.
def det_curves(self, model_limit): """Return data for Detection-Error Tradeoff curves for model_limit # of Models from search results. Note: Useful only in classification. Args: model_limit (int): number of Models from search results Returns: list: ...
[ "def", "det_curves", "(", "self", ",", "model_limit", ")", ":", "return", "self", ".", "_plot_curves", "(", "det_curve", ",", "model_limit", ")" ]
[ 461, 4 ]
[ 473, 56 ]
python
en
['en', 'en', 'en']
True
ModelFinder.confusion_matrices
(self, model_limit)
Return data for Confusion Matrices for model_limit # of Models from search results. Note: Useful only in classification/multiclass. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, data for confusion matr...
Return data for Confusion Matrices for model_limit # of Models from search results.
def confusion_matrices(self, model_limit): """Return data for Confusion Matrices for model_limit # of Models from search results. Note: Useful only in classification/multiclass. Args: model_limit (int): number of Models from search results Returns: ...
[ "def", "confusion_matrices", "(", "self", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results_dataframe", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "models",...
[ 475, 4 ]
[ 498, 16 ]
python
en
['en', 'en', 'en']
True
ModelFinder.prediction_errors
(self, model_limit)
Return data for Prediction Errors for model_limit # of Models from search results. Note: Useful only in regression. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, prediction errors) Raises: ...
Return data for Prediction Errors for model_limit # of Models from search results.
def prediction_errors(self, model_limit): """Return data for Prediction Errors for model_limit # of Models from search results. Note: Useful only in regression. Args: model_limit (int): number of Models from search results Returns: list: list of tup...
[ "def", "prediction_errors", "(", "self", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results_dataframe", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "models", ...
[ 500, 4 ]
[ 523, 16 ]
python
en
['en', 'en', 'en']
True
ModelFinder.residuals
(self, model_limit)
Return data for Residuals for model_limit # of Models from search results. Note: Useful only in regression. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, residuals data) Raises: Mo...
Return data for Residuals for model_limit # of Models from search results.
def residuals(self, model_limit): """Return data for Residuals for model_limit # of Models from search results. Note: Useful only in regression. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, re...
[ "def", "residuals", "(", "self", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results_dataframe", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "models", "=", ...
[ 525, 4 ]
[ 549, 16 ]
python
en
['en', 'en', 'en']
True
ModelFinder.predictions_X_test
(self, model_limit)
Return prediction data of X_test split for model_limit # of Models from search results. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, predictions) Raises: ModelsNotSearchedError: when no search and per...
Return prediction data of X_test split for model_limit # of Models from search results.
def predictions_X_test(self, model_limit): """Return prediction data of X_test split for model_limit # of Models from search results. Args: model_limit (int): number of Models from search results Returns: list: list of tuples - (model, predictions) Raises: ...
[ "def", "predictions_X_test", "(", "self", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results_dataframe", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "models",...
[ 551, 4 ]
[ 571, 16 ]
python
en
['en', 'en', 'en']
True
ModelFinder._set_problem
(self, problem_type)
Set different instance attributes depending on the problem_type provided. Args: problem_type (str): string representing type of a problem
Set different instance attributes depending on the problem_type provided.
def _set_problem(self, problem_type): """Set different instance attributes depending on the problem_type provided. Args: problem_type (str): string representing type of a problem """ if problem_type == self._target_categorical: # multiclass if len(np...
[ "def", "_set_problem", "(", "self", ",", "problem_type", ")", ":", "if", "problem_type", "==", "self", ".", "_target_categorical", ":", "# multiclass", "if", "len", "(", "np", ".", "unique", "(", "self", ".", "y", ")", ")", ">", "2", ":", "self", ".", ...
[ 577, 4 ]
[ 605, 119 ]
python
en
['en', 'en', 'en']
True
ModelFinder._search_for_models
(self, models, mode, scoring)
Assess Models in regard to their performance with provided scoring function. If models are provided as 'Model class': param_grid dict pairs in a dictionary, do gridsearch on provided parameters. If models is None, default models will be used depending on provided mode. "quick" mode makes the a...
Assess Models in regard to their performance with provided scoring function.
def _search_for_models(self, models, mode, scoring): """Assess Models in regard to their performance with provided scoring function. If models are provided as 'Model class': param_grid dict pairs in a dictionary, do gridsearch on provided parameters. If models is None, default models will be us...
[ "def", "_search_for_models", "(", "self", ",", "models", ",", "mode", ",", "scoring", ")", ":", "if", "isinstance", "(", "models", ",", "dict", ")", ":", "gridsearch_models", "=", "self", ".", "_gridsearch", "(", "models", ",", "scoring", ")", "elif", "m...
[ 611, 4 ]
[ 657, 31 ]
python
en
['en', 'en', 'en']
True
ModelFinder._gridsearch
(self, models_param_grid, scoring)
Perform gridsearch and update _gridsearch_results attribute with results DataFrame. Args: models_param_grid (dict): 'Model class': param_grid dict pairs scoring (function): sklearn scoring function Returns: list: 2-element tuples (Model class, params to instance the...
Perform gridsearch and update _gridsearch_results attribute with results DataFrame.
def _gridsearch(self, models_param_grid, scoring): """Perform gridsearch and update _gridsearch_results attribute with results DataFrame. Args: models_param_grid (dict): 'Model class': param_grid dict pairs scoring (function): sklearn scoring function Returns: ...
[ "def", "_gridsearch", "(", "self", ",", "models_param_grid", ",", "scoring", ")", ":", "chosen_models", ",", "all_results", "=", "self", ".", "_perform_gridsearch", "(", "models_param_grid", ",", "scoring", ")", "self", ".", "_gridsearch_results", "=", "self", "...
[ 659, 4 ]
[ 672, 28 ]
python
en
['en', 'en', 'en']
True
ModelFinder._perform_gridsearch
(self, models_param_grid, scoring, cv=5)
Perform gridsearch on provided models_param_grid and return results. Gridsearch is performed on provided Models space ('Models class': param_grid dict pairs) with scoring used as a sole metric to decide which Models perform well and which perform poor. HalvingGridSearch is used instead of a reg...
Perform gridsearch on provided models_param_grid and return results.
def _perform_gridsearch(self, models_param_grid, scoring, cv=5): """Perform gridsearch on provided models_param_grid and return results. Gridsearch is performed on provided Models space ('Models class': param_grid dict pairs) with scoring used as a sole metric to decide which Models perform wel...
[ "def", "_perform_gridsearch", "(", "self", ",", "models_param_grid", ",", "scoring", ",", "cv", "=", "5", ")", ":", "all_results", "=", "{", "}", "best_of_their_class", "=", "[", "]", "for", "model", ",", "params", "in", "models_param_grid", ".", "items", ...
[ 674, 4 ]
[ 738, 48 ]
python
en
['en', 'en', 'en']
True
ModelFinder._create_gridsearch_results_dataframe
(self, cv_results)
Create DataFrame with GridSearch results from cv_results dictionary of results. Args: cv_results (dict): 'Model class': results dict pairs Returns: pandas.DataFrame: DataFrame with gridsearch results
Create DataFrame with GridSearch results from cv_results dictionary of results.
def _create_gridsearch_results_dataframe(self, cv_results): """Create DataFrame with GridSearch results from cv_results dictionary of results. Args: cv_results (dict): 'Model class': results dict pairs Returns: pandas.DataFrame: DataFrame with gridsearch results ...
[ "def", "_create_gridsearch_results_dataframe", "(", "self", ",", "cv_results", ")", ":", "df", "=", "None", "for", "model", "in", "cv_results", ".", "keys", "(", ")", ":", "single_results", "=", "pd", ".", "DataFrame", "(", "cv_results", "[", "model", "]", ...
[ 740, 4 ]
[ 756, 17 ]
python
en
['en', 'en', 'en']
True
ModelFinder._quicksearch
(self, models, scoring)
Perform quicksearch and update _quicksearch_results attribute with results DataFrame. Returned Models list is truncated depending on _quicksearch_limit class attribute. Args: models (list): list of Model classes scoring (function): sklearn scoring function Returns: ...
Perform quicksearch and update _quicksearch_results attribute with results DataFrame.
def _quicksearch(self, models, scoring): """Perform quicksearch and update _quicksearch_results attribute with results DataFrame. Returned Models list is truncated depending on _quicksearch_limit class attribute. Args: models (list): list of Model classes scoring (funct...
[ "def", "_quicksearch", "(", "self", ",", "models", ",", "scoring", ")", ":", "scored_models", ",", "all_results", "=", "self", ".", "_perform_quicksearch", "(", "models", ",", "scoring", ")", "results_df", "=", "self", ".", "_create_search_results_dataframe", "(...
[ 758, 4 ]
[ 776, 78 ]
python
en
['en', 'en', 'en']
True
ModelFinder._perform_quicksearch
(self, models, scoring)
Assess performance of Models created with default parameters and return the results. Quicksearch works in a similar manner to LazyPredict package - Models are created with their default parameters and score is calculated with sklearn scoring function. The better the score, the better the Model. ...
Assess performance of Models created with default parameters and return the results.
def _perform_quicksearch(self, models, scoring): """Assess performance of Models created with default parameters and return the results. Quicksearch works in a similar manner to LazyPredict package - Models are created with their default parameters and score is calculated with sklearn scoring f...
[ "def", "_perform_quicksearch", "(", "self", ",", "models", ",", "scoring", ")", ":", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "self", ".", "X_train", ",", "self", ".", "y_train", ",", "random_state", "=", "self...
[ 778, 4 ]
[ 819, 41 ]
python
en
['en', 'en', 'en']
True
ModelFinder._create_search_results_dataframe
(self, results, chosen_scoring)
Create pandas.DataFrame from quicksearch results and return it. DataFrame is sorted with the best scoring Model put on top. Args: results (dict): 'Model class': results pairs chosen_scoring (function): sklearn scoring function Returns: pandas.DataFrame: Dat...
Create pandas.DataFrame from quicksearch results and return it.
def _create_search_results_dataframe(self, results, chosen_scoring): """Create pandas.DataFrame from quicksearch results and return it. DataFrame is sorted with the best scoring Model put on top. Args: results (dict): 'Model class': results pairs chosen_scoring (functio...
[ "def", "_create_search_results_dataframe", "(", "self", ",", "results", ",", "chosen_scoring", ")", ":", "data", "=", "defaultdict", "(", "list", ")", "for", "model", ",", "values", "in", "results", ".", "items", "(", ")", ":", "data", "[", "self", ".", ...
[ 821, 4 ]
[ 841, 95 ]
python
en
['en', 'en', 'en']
True
ModelFinder._assess_models_performance
(self, initiated_models, chosen_scoring)
Assess Models performance and return them in the order based on achieved scores. In comparison to quicksearch or gridsearch methods, Models must be already instanced with some parameters to have its score calculated. Note: Models are fit with X_train and y_train splits, but are sco...
Assess Models performance and return them in the order based on achieved scores.
def _assess_models_performance(self, initiated_models, chosen_scoring): """Assess Models performance and return them in the order based on achieved scores. In comparison to quicksearch or gridsearch methods, Models must be already instanced with some parameters to have its score calculated. ...
[ "def", "_assess_models_performance", "(", "self", ",", "initiated_models", ",", "chosen_scoring", ")", ":", "all_results", "=", "{", "}", "fitted_and_scored", "=", "[", "]", "for", "model", "in", "initiated_models", ":", "with", "warnings", ".", "catch_warnings", ...
[ 843, 4 ]
[ 882, 45 ]
python
en
['en', 'en', 'en']
True
ModelFinder._score_model
(self, fitted_model, chosen_scoring)
Score Model with all default scoring functions of a given problem type (+) chosen_scoring on X_test and y_test splits and return the result. Args: fitted_model (sklearn.Model): Model that was already fit to X_train/y_train data chosen_scoring (function): sklearn scoring function...
Score Model with all default scoring functions of a given problem type (+) chosen_scoring on X_test and y_test splits and return the result.
def _score_model(self, fitted_model, chosen_scoring): """Score Model with all default scoring functions of a given problem type (+) chosen_scoring on X_test and y_test splits and return the result. Args: fitted_model (sklearn.Model): Model that was already fit to X_train/y_train dat...
[ "def", "_score_model", "(", "self", ",", "fitted_model", ",", "chosen_scoring", ")", ":", "scorings", "=", "self", ".", "_get_scorings", "(", "chosen_scoring", ")", "scoring_results", "=", "{", "}", "for", "scoring", "in", "scorings", ":", "score", "=", "sel...
[ 888, 4 ]
[ 905, 30 ]
python
en
['en', 'en', 'en']
True
ModelFinder._get_scorings
(self, chosen_scoring)
Check if chosen_scoring is already in list of default scoring functions and add it or not to have it included in the list, but not duplicated. Args: chosen_scoring (function): sklearn scoring function Returns: list: functions scoring_functions attribute with chosen_scor...
Check if chosen_scoring is already in list of default scoring functions and add it or not to have it included in the list, but not duplicated.
def _get_scorings(self, chosen_scoring): """Check if chosen_scoring is already in list of default scoring functions and add it or not to have it included in the list, but not duplicated. Args: chosen_scoring (function): sklearn scoring function Returns: list: fu...
[ "def", "_get_scorings", "(", "self", ",", "chosen_scoring", ")", ":", "if", "chosen_scoring", "in", "self", ".", "scoring_functions", ":", "scorings", "=", "self", ".", "scoring_functions", "else", ":", "scorings", "=", "[", "chosen_scoring", "]", "+", "self",...
[ 907, 4 ]
[ 922, 23 ]
python
en
['en', 'en', 'en']
True
ModelFinder._calculate_model_score
(self, model, X, y_true, scoring_function)
Calculate Model score based on the type of scoring_function - if it requires simple '0-1' predictions or calculated probabilities. scoring_function is checked if it's defined in _probas_function class attribute - container of pre-defined functions that might require probabilities. If it is, the...
Calculate Model score based on the type of scoring_function - if it requires simple '0-1' predictions or calculated probabilities.
def _calculate_model_score(self, model, X, y_true, scoring_function): """Calculate Model score based on the type of scoring_function - if it requires simple '0-1' predictions or calculated probabilities. scoring_function is checked if it's defined in _probas_function class attribute - container...
[ "def", "_calculate_model_score", "(", "self", ",", "model", ",", "X", ",", "y_true", ",", "scoring_function", ")", ":", "# check if scoring_function is defined in _probas_function class attribute", "if", "any", "(", "(", "func", "==", "obj_name", "(", "scoring_function"...
[ 924, 4 ]
[ 952, 20 ]
python
en
['en', 'en', 'en']
True
ModelFinder._create_scoring_multiclass
(self)
Create scoring functions for multiclass problem with some of the parameters pre-set. Some functions used for multiclass scoring require different arguments to be called with when assessing the score of multiclass problems. They aren't called up until the point of scoring (late in the process) so ...
Create scoring functions for multiclass problem with some of the parameters pre-set.
def _create_scoring_multiclass(self): """Create scoring functions for multiclass problem with some of the parameters pre-set. Some functions used for multiclass scoring require different arguments to be called with when assessing the score of multiclass problems. They aren't called up until the...
[ "def", "_create_scoring_multiclass", "(", "self", ")", ":", "# (roc_auc_score, {\"average\": \"weighted\", \"multi_class\": \"ovr\"})", "# multiclass roc_auc_score requires probabilities for every class in comparison to simple predictions", "# required by other metrics, not included cause it breaks ...
[ 954, 4 ]
[ 981, 23 ]
python
en
['en', 'en', 'en']
True
ModelFinder._wrap_model
(self, model)
Wrap Model in WrappedModelRegression if the problem type is regression, return unchanged model otherwise. Args: model (sklearn.Model): model to be wrapped Returns: WrappedModelRegression, sklearn.Model: WrappedModelRegression object if regression, model otherwise
Wrap Model in WrappedModelRegression if the problem type is regression, return unchanged model otherwise.
def _wrap_model(self, model): """Wrap Model in WrappedModelRegression if the problem type is regression, return unchanged model otherwise. Args: model (sklearn.Model): model to be wrapped Returns: WrappedModelRegression, sklearn.Model: WrappedModelRegression object if r...
[ "def", "_wrap_model", "(", "self", ",", "model", ")", ":", "if", "self", ".", "problem", "==", "self", ".", "_regression", "and", "type", "(", "model", ")", "!=", "WrappedModelRegression", ":", "wrapped_model", "=", "WrappedModelRegression", "(", "regressor", ...
[ 987, 4 ]
[ 1000, 24 ]
python
en
['en', 'en', 'en']
True
ModelFinder._wrap_results_dataframe
(self, df)
Add another column to results DataFrame indicating params of TransformedTargerRegressor used in regression problem. Return unchanged df if the problem is different from regression. Args: df (pandas.DataFrame): results DataFrame Returns: pandas.DataFrame: df Dat...
Add another column to results DataFrame indicating params of TransformedTargerRegressor used in regression problem.
def _wrap_results_dataframe(self, df): """Add another column to results DataFrame indicating params of TransformedTargerRegressor used in regression problem. Return unchanged df if the problem is different from regression. Args: df (pandas.DataFrame): results DataFrame ...
[ "def", "_wrap_results_dataframe", "(", "self", ",", "df", ")", ":", "if", "self", ".", "problem", "==", "self", ".", "_regression", ":", "df", "[", "self", ".", "_transformed_target_name", "]", "=", "str", "(", "self", ".", "target_transformer", ".", "get_...
[ 1002, 4 ]
[ 1017, 17 ]
python
en
['en', 'en', 'en']
True
ModelFinder._wrap_params
(self, params)
Update params dictionary with parameters of TransformedTargetRegressor transformer used in regression problem. Return unchanged params dictionary if the problem is different from regression. Args: params (dict): dictionary of 'param': value pairs Returns: dict:...
Update params dictionary with parameters of TransformedTargetRegressor transformer used in regression problem.
def _wrap_params(self, params): """Update params dictionary with parameters of TransformedTargetRegressor transformer used in regression problem. Return unchanged params dictionary if the problem is different from regression. Args: params (dict): dictionary of 'param': valu...
[ "def", "_wrap_params", "(", "self", ",", "params", ")", ":", "if", "self", ".", "problem", "==", "self", ".", "_regression", ":", "params", "[", "self", ".", "_transformed_target_name", "]", "=", "obj_name", "(", "self", ".", "target_transformer", ")", "# ...
[ 1019, 4 ]
[ 1037, 21 ]
python
en
['en', 'en', 'en']
True
ModelFinder._plot_curves
(self, plot_func, model_limit)
Calculate data needed to plot performance curve from plot_func. Functions calculating performance curves require probas instead of '0-1' predictions. As not every Model has predict_probas method, decision_function method is also tried to get the probabilities. Args: plot_func (func...
Calculate data needed to plot performance curve from plot_func.
def _plot_curves(self, plot_func, model_limit): """Calculate data needed to plot performance curve from plot_func. Functions calculating performance curves require probas instead of '0-1' predictions. As not every Model has predict_probas method, decision_function method is also tried to get th...
[ "def", "_plot_curves", "(", "self", ",", "plot_func", ",", "model_limit", ")", ":", "if", "self", ".", "_search_results", "is", "None", ":", "raise", "ModelsNotSearchedError", "(", "\"Search Results is not available. Call 'search' to obtain comparison models.\"", ")", "cu...
[ 1043, 4 ]
[ 1076, 21 ]
python
en
['en', 'en', 'en']
True
ModelFinder._create_dummy_model
(self)
Create dummy Model for a given problem type and calculate default scores for it. Note: Dummy Model is scored in the beginning with a default set of functions to prevent errors from custom scoring function provided that Dummy Model might not be able to handle. This is a potential improve...
Create dummy Model for a given problem type and calculate default scores for it.
def _create_dummy_model(self): """Create dummy Model for a given problem type and calculate default scores for it. Note: Dummy Model is scored in the beginning with a default set of functions to prevent errors from custom scoring function provided that Dummy Model might not be a...
[ "def", "_create_dummy_model", "(", "self", ")", ":", "if", "self", ".", "problem", "==", "self", ".", "_classification", "or", "self", ".", "problem", "==", "self", ".", "_multiclass", ":", "model", "=", "DummyClassifier", "(", "strategy", "=", "\"stratified...
[ 1082, 4 ]
[ 1109, 29 ]
python
en
['en', 'en', 'en']
True
ModelFinder._dummy_model_results
(self)
Create Dummy Model results DataFrame from _dummy_model_scores attribute. Returns: pandas.DataFrame: DataFrame with Dummy Model score results
Create Dummy Model results DataFrame from _dummy_model_scores attribute.
def _dummy_model_results(self): """Create Dummy Model results DataFrame from _dummy_model_scores attribute. Returns: pandas.DataFrame: DataFrame with Dummy Model score results """ _ = { self._model_name: obj_name(self._dummy_model), self._fit_time_nam...
[ "def", "_dummy_model_results", "(", "self", ")", ":", "_", "=", "{", "self", ".", "_model_name", ":", "obj_name", "(", "self", ".", "_dummy_model", ")", ",", "self", ".", "_fit_time_name", ":", "np", ".", "nan", ",", "self", ".", "_params_name", ":", "...
[ 1111, 4 ]
[ 1123, 44 ]
python
en
['en', 'en', 'en']
True
bulk_get_subscriber_peer_info
( realm: Realm, streams: List[Stream], )
Glossary: subscribed_ids: This shows the users who are actually subscribed to the stream, which we generally send to the person subscribing to the stream. private_peer_dict: These are the folks that need to know about a new subscriber. I...
Glossary:
def bulk_get_subscriber_peer_info( realm: Realm, streams: List[Stream], ) -> SubscriberPeerInfo: """ Glossary: subscribed_ids: This shows the users who are actually subscribed to the stream, which we generally send to the person subscribing to the stream. ...
[ "def", "bulk_get_subscriber_peer_info", "(", "realm", ":", "Realm", ",", "streams", ":", "List", "[", "Stream", "]", ",", ")", "->", "SubscriberPeerInfo", ":", "subscribed_ids", "=", "{", "}", "private_peer_dict", "=", "{", "}", "private_stream_ids", "=", "{",...
[ 147, 0 ]
[ 196, 5 ]
python
en
['en', 'error', 'th']
False
subscriber_ids_with_stream_history_access
(stream: Stream)
Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration. 1. if !history_public_to_subscribers: History is not available to anyone 2. if history_public_to_subscribers: All...
Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration.
def subscriber_ids_with_stream_history_access(stream: Stream) -> Set[int]: """Returns the set of active user IDs who can access any message history on this stream (regardless of whether they have a UserMessage) based on the stream's configuration. 1. if !history_public_to_subscribers: History...
[ "def", "subscriber_ids_with_stream_history_access", "(", "stream", ":", "Stream", ")", "->", "Set", "[", "int", "]", ":", "if", "not", "stream", ".", "is_history_public_to_subscribers", "(", ")", ":", "return", "set", "(", ")", "return", "set", "(", "get_activ...
[ 261, 0 ]
[ 283, 5 ]
python
en
['en', 'en', 'en']
True
get_subscriptions_for_send_message
( *, realm_id: int, stream_id: int, possible_wildcard_mention: bool, possibly_mentioned_user_ids: AbstractSet[int], )
This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which can result in 10,000s of long_term_idle recipients in default streams. do_send_messages has an optimization to avoid doing work for long_term_idle unless message flags or notification...
This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which can result in 10,000s of long_term_idle recipients in default streams. do_send_messages has an optimization to avoid doing work for long_term_idle unless message flags or notification...
def get_subscriptions_for_send_message( *, realm_id: int, stream_id: int, possible_wildcard_mention: bool, possibly_mentioned_user_ids: AbstractSet[int], ) -> QuerySet: """This function optimizes an important use case for large streams. Open realms often have many long_term_idle users, which...
[ "def", "get_subscriptions_for_send_message", "(", "*", ",", "realm_id", ":", "int", ",", "stream_id", ":", "int", ",", "possible_wildcard_mention", ":", "bool", ",", "possibly_mentioned_user_ids", ":", "AbstractSet", "[", "int", "]", ",", ")", "->", "QuerySet", ...
[ 286, 0 ]
[ 342, 16 ]
python
en
['en', 'en', 'en']
True
parse
(version)
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
def parse(version): # type: (str) -> Union[LegacyVersion, Version] """ Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version. """ try: return Versi...
[ "def", "parse", "(", "version", ")", ":", "# type: (str) -> Union[LegacyVersion, Version]", "try", ":", "return", "Version", "(", "version", ")", "except", "InvalidVersion", ":", "return", "LegacyVersion", "(", "version", ")" ]
[ 47, 0 ]
[ 57, 37 ]
python
en
['en', 'error', 'th']
False
_parse_local_version
(local)
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
def _parse_local_version(local): # type: (str) -> Optional[LocalType] """ Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve"). """ if local is not None: return tuple( part.lower() if not part.isdigit() else int(part) for part in _local_version_sepa...
[ "def", "_parse_local_version", "(", "local", ")", ":", "# type: (str) -> Optional[LocalType]", "if", "local", "is", "not", "None", ":", "return", "tuple", "(", "part", ".", "lower", "(", ")", "if", "not", "part", ".", "isdigit", "(", ")", "else", "int", "(...
[ 460, 0 ]
[ 470, 15 ]
python
en
['en', 'error', 'th']
False
UsersViewTests.test_detail_view_overview_tab
(self)
Test the overview tab of the detail view . Test the overview tab using directly the url targeting the tab.
Test the overview tab of the detail view .
def test_detail_view_overview_tab(self): """Test the overview tab of the detail view . Test the overview tab using directly the url targeting the tab. """ domain = self._get_default_domain() user = self.users.get(id="1") tenant = self.tenants.get(id=user.project_id) ...
[ "def", "test_detail_view_overview_tab", "(", "self", ")", ":", "domain", "=", "self", ".", "_get_default_domain", "(", ")", "user", "=", "self", ".", "users", ".", "get", "(", "id", "=", "\"1\"", ")", "tenant", "=", "self", ".", "tenants", ".", "get", ...
[ 916, 4 ]
[ 949, 69 ]
python
en
['en', 'en', 'en']
True