id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
220,200
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.delete_series
def delete_series(self, database=None, measurement=None, tags=None): """Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which ...
python
def delete_series(self, database=None, measurement=None, tags=None): """Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which ...
[ "def", "delete_series", "(", "self", ",", "database", "=", "None", ",", "measurement", "=", "None", ",", "tags", "=", "None", ")", ":", "database", "=", "database", "or", "self", ".", "_database", "query_str", "=", "'DROP SERIES'", "if", "measurement", ":"...
Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which the series should be deleted, defaults to client's current database ...
[ "Delete", "series", "from", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L840-L864
220,201
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.get_list_privileges
def get_list_privileges(self, username): """Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: ...
python
def get_list_privileges(self, username): """Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: ...
[ "def", "get_list_privileges", "(", "self", ",", "username", ")", ":", "text", "=", "\"SHOW GRANTS FOR {0}\"", ".", "format", "(", "quote_ident", "(", "username", ")", ")", "return", "list", "(", "self", ".", "query", "(", "text", ")", ".", "get_points", "(...
Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: >> privileges = client.get_list_privilege...
[ "Get", "the", "list", "of", "all", "privileges", "granted", "to", "given", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L922-L942
220,202
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.get_list_continuous_queries
def get_list_continuous_queries(self): """Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u...
python
def get_list_continuous_queries(self): """Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u...
[ "def", "get_list_continuous_queries", "(", "self", ")", ":", "query_string", "=", "\"SHOW CONTINUOUS QUERIES\"", "return", "[", "{", "sk", "[", "0", "]", ":", "list", "(", "p", ")", "}", "for", "sk", ",", "p", "in", "self", ".", "query", "(", "query_stri...
Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u'db1': [] }, { ...
[ "Get", "the", "list", "of", "continuous", "queries", "in", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L944-L974
220,203
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.create_continuous_query
def create_continuous_query(self, name, select, database=None, resample_opts=None): r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query ...
python
def create_continuous_query(self, name, select, database=None, resample_opts=None): r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query ...
[ "def", "create_continuous_query", "(", "self", ",", "name", ",", "select", ",", "database", "=", "None", ",", "resample_opts", "=", "None", ")", ":", "query_string", "=", "(", "\"CREATE CONTINUOUS QUERY {0} ON {1}{2} BEGIN {3} END\"", ")", ".", "format", "(", "quo...
r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query :type select: str :param database: the database for which the continuous query is created. Defau...
[ "r", "Create", "a", "continuous", "query", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L976-L1020
220,204
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.drop_continuous_query
def drop_continuous_query(self, name, database=None): """Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's ...
python
def drop_continuous_query(self, name, database=None): """Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's ...
[ "def", "drop_continuous_query", "(", "self", ",", "name", ",", "database", "=", "None", ")", ":", "query_string", "=", "(", "\"DROP CONTINUOUS QUERY {0} ON {1}\"", ")", ".", "format", "(", "quote_ident", "(", "name", ")", ",", "quote_ident", "(", "database", "...
Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's database :type database: str
[ "Drop", "an", "existing", "continuous", "query", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1022-L1034
220,205
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.send_packet
def send_packet(self, packet, protocol='json', time_precision=None): """Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data...
python
def send_packet(self, packet, protocol='json', time_precision=None): """Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data...
[ "def", "send_packet", "(", "self", ",", "packet", ",", "protocol", "=", "'json'", ",", "time_precision", "=", "None", ")", ":", "if", "protocol", "==", "'json'", ":", "data", "=", "make_lines", "(", "packet", ",", "time_precision", ")", ".", "encode", "(...
Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data, either 'json' or 'line' :type protocol: str :param time_precis...
[ "Send", "an", "UDP", "packet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1036-L1051
220,206
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.close
def close(self): """Close http session.""" if isinstance(self._session, requests.Session): self._session.close()
python
def close(self): """Close http session.""" if isinstance(self._session, requests.Session): self._session.close()
[ "def", "close", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_session", ",", "requests", ".", "Session", ")", ":", "self", ".", "_session", ".", "close", "(", ")" ]
Close http session.
[ "Close", "http", "session", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1053-L1056
220,207
influxdata/influxdb-python
influxdb/chunked_json.py
loads
def loads(s): """Generate a sequence of JSON values from a string.""" _decoder = json.JSONDecoder() while s: s = s.strip() obj, pos = _decoder.raw_decode(s) if not pos: raise ValueError('no JSON object found at %i' % pos) yield obj s = s[pos:]
python
def loads(s): """Generate a sequence of JSON values from a string.""" _decoder = json.JSONDecoder() while s: s = s.strip() obj, pos = _decoder.raw_decode(s) if not pos: raise ValueError('no JSON object found at %i' % pos) yield obj s = s[pos:]
[ "def", "loads", "(", "s", ")", ":", "_decoder", "=", "json", ".", "JSONDecoder", "(", ")", "while", "s", ":", "s", "=", "s", ".", "strip", "(", ")", "obj", ",", "pos", "=", "_decoder", ".", "raw_decode", "(", "s", ")", "if", "not", "pos", ":", ...
Generate a sequence of JSON values from a string.
[ "Generate", "a", "sequence", "of", "JSON", "values", "from", "a", "string", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/chunked_json.py#L17-L27
220,208
influxdata/influxdb-python
influxdb/influxdb08/helper.py
SeriesHelper.commit
def commit(cls, client=None): """Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points. """ if not c...
python
def commit(cls, client=None): """Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points. """ if not c...
[ "def", "commit", "(", "cls", ",", "client", "=", "None", ")", ":", "if", "not", "client", ":", "client", "=", "cls", ".", "_client", "rtn", "=", "client", ".", "write_points", "(", "cls", ".", "_json_body_", "(", ")", ")", "cls", ".", "_reset_", "(...
Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points.
[ "Commit", "everything", "from", "datapoints", "via", "the", "client", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/helper.py#L122-L133
220,209
influxdata/influxdb-python
influxdb/influxdb08/helper.py
SeriesHelper._json_body_
def _json_body_(cls): """Return JSON body of the datapoints. :return: JSON body of the datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): json.append({'name': series_name, 'columns': cls._fields, ...
python
def _json_body_(cls): """Return JSON body of the datapoints. :return: JSON body of the datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): json.append({'name': series_name, 'columns': cls._fields, ...
[ "def", "_json_body_", "(", "cls", ")", ":", "json", "=", "[", "]", "for", "series_name", ",", "data", "in", "six", ".", "iteritems", "(", "cls", ".", "_datapoints", ")", ":", "json", ".", "append", "(", "{", "'name'", ":", "series_name", ",", "'colum...
Return JSON body of the datapoints. :return: JSON body of the datapoints.
[ "Return", "JSON", "body", "of", "the", "datapoints", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/helper.py#L136-L148
220,210
influxdata/influxdb-python
influxdb/_dataframe_client.py
DataFrameClient.query
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET", ...
python
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET", ...
[ "def", "query", "(", "self", ",", "query", ",", "params", "=", "None", ",", "bind_params", "=", "None", ",", "epoch", "=", "None", ",", "expected_response_code", "=", "200", ",", "database", "=", "None", ",", "raise_errors", "=", "True", ",", "chunked", ...
Query data into a DataFrame. .. danger:: In order to avoid injection vulnerabilities (similar to `SQL injection <https://www.owasp.org/index.php/SQL_Injection>`_ vulnerabilities), do not directly include untrusted data into the ``query`` parameter, use ``bind_par...
[ "Query", "data", "into", "a", "DataFrame", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/_dataframe_client.py#L142-L201
220,211
influxdata/influxdb-python
examples/tutorial.py
main
def main(host='localhost', port=8086): """Instantiate a connection to the InfluxDB.""" user = 'root' password = 'root' dbname = 'example' dbuser = 'smly' dbuser_password = 'my_secret_password' query = 'select Float_value from cpu_load_short;' query_where = 'select Int_value from cpu_load...
python
def main(host='localhost', port=8086): """Instantiate a connection to the InfluxDB.""" user = 'root' password = 'root' dbname = 'example' dbuser = 'smly' dbuser_password = 'my_secret_password' query = 'select Float_value from cpu_load_short;' query_where = 'select Int_value from cpu_load...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "user", "=", "'root'", "password", "=", "'root'", "dbname", "=", "'example'", "dbuser", "=", "'smly'", "dbuser_password", "=", "'my_secret_password'", "query", "=", "'select ...
Instantiate a connection to the InfluxDB.
[ "Instantiate", "a", "connection", "to", "the", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial.py#L9-L64
220,212
influxdata/influxdb-python
examples/tutorial_udp.py
main
def main(uport): """Instantiate connection to the InfluxDB.""" # NOTE: structure of the UDP packet is different than that of information # sent via HTTP json_body = { "tags": { "host": "server01", "region": "us-west" }, "time": "2009-11-10T23:00:00Z"...
python
def main(uport): """Instantiate connection to the InfluxDB.""" # NOTE: structure of the UDP packet is different than that of information # sent via HTTP json_body = { "tags": { "host": "server01", "region": "us-west" }, "time": "2009-11-10T23:00:00Z"...
[ "def", "main", "(", "uport", ")", ":", "# NOTE: structure of the UDP packet is different than that of information", "# sent via HTTP", "json_body", "=", "{", "\"tags\"", ":", "{", "\"host\"", ":", "\"server01\"", ",", "\"region\"", ":", "\"us-west\"", "}", ",", "\...
Instantiate connection to the InfluxDB.
[ "Instantiate", "connection", "to", "the", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_udp.py#L23-L52
220,213
influxdata/influxdb-python
influxdb/helper.py
SeriesHelper._json_body_
def _json_body_(cls): """Return the JSON body of given datapoints. :return: JSON body of these datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): for point in data: json_point = { "measurement": seri...
python
def _json_body_(cls): """Return the JSON body of given datapoints. :return: JSON body of these datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): for point in data: json_point = { "measurement": seri...
[ "def", "_json_body_", "(", "cls", ")", ":", "json", "=", "[", "]", "for", "series_name", ",", "data", "in", "six", ".", "iteritems", "(", "cls", ".", "_datapoints", ")", ":", "for", "point", "in", "data", ":", "json_point", "=", "{", "\"measurement\"",...
Return the JSON body of given datapoints. :return: JSON body of these datapoints.
[ "Return", "the", "JSON", "body", "of", "given", "datapoints", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/helper.py#L151-L175
220,214
influxdata/influxdb-python
examples/tutorial_server_data.py
main
def main(host='localhost', port=8086, nb_day=15): """Instantiate a connection to the backend.""" nb_day = 15 # number of day to generate time series timeinterval_min = 5 # create an event every x minutes total_minutes = 1440 * nb_day total_records = int(total_minutes / timeinterval_min) now = ...
python
def main(host='localhost', port=8086, nb_day=15): """Instantiate a connection to the backend.""" nb_day = 15 # number of day to generate time series timeinterval_min = 5 # create an event every x minutes total_minutes = 1440 * nb_day total_records = int(total_minutes / timeinterval_min) now = ...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ",", "nb_day", "=", "15", ")", ":", "nb_day", "=", "15", "# number of day to generate time series", "timeinterval_min", "=", "5", "# create an event every x minutes", "total_minutes", "=", "...
Instantiate a connection to the backend.
[ "Instantiate", "a", "connection", "to", "the", "backend", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_server_data.py#L19-L74
220,215
influxdata/influxdb-python
examples/tutorial_sine_wave.py
main
def main(host='localhost', port=8086): """Define function to generate the sin wave.""" now = datetime.datetime.today() points = [] for angle in range(0, 360): y = 10 + math.sin(math.radians(angle)) * 10 point = { "measurement": 'foobar', "time": int(now.strftime...
python
def main(host='localhost', port=8086): """Define function to generate the sin wave.""" now = datetime.datetime.today() points = [] for angle in range(0, 360): y = 10 + math.sin(math.radians(angle)) * 10 point = { "measurement": 'foobar', "time": int(now.strftime...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "points", "=", "[", "]", "for", "angle", "in", "range", "(", "0", ",", "360", ")", ":", "y", "=...
Define function to generate the sin wave.
[ "Define", "function", "to", "generate", "the", "sin", "wave", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_sine_wave.py#L17-L61
220,216
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.get_points
def get_points(self, measurement=None, tags=None): """Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator ""...
python
def get_points(self, measurement=None, tags=None): """Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator ""...
[ "def", "get_points", "(", "self", ",", "measurement", "=", "None", ",", "tags", "=", "None", ")", ":", "# Raise error if measurement is not str or bytes", "if", "not", "isinstance", "(", "measurement", ",", "(", "bytes", ",", "type", "(", "b''", ".", "decode",...
Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator
[ "Return", "a", "generator", "for", "all", "the", "points", "that", "match", "the", "given", "filters", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L80-L115
220,217
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.keys
def keys(self): """Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags) """ keys = [] for series in self._get_series(): keys.append( (series.get('measurement', series.get('nam...
python
def keys(self): """Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags) """ keys = [] for series in self._get_series(): keys.append( (series.get('measurement', series.get('nam...
[ "def", "keys", "(", "self", ")", ":", "keys", "=", "[", "]", "for", "series", "in", "self", ".", "_get_series", "(", ")", ":", "keys", ".", "append", "(", "(", "series", ".", "get", "(", "'measurement'", ",", "series", ".", "get", "(", "'name'", ...
Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags)
[ "Return", "the", "list", "of", "keys", "in", "the", "ResultSet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L153-L165
220,218
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.items
def items(self): """Return the set of items from the ResultSet. :return: List of tuples, (key, generator) """ items = [] for series in self._get_series(): series_key = (series.get('measurement', series.get('name', 'results')), ...
python
def items(self): """Return the set of items from the ResultSet. :return: List of tuples, (key, generator) """ items = [] for series in self._get_series(): series_key = (series.get('measurement', series.get('name', 'results')), ...
[ "def", "items", "(", "self", ")", ":", "items", "=", "[", "]", "for", "series", "in", "self", ".", "_get_series", "(", ")", ":", "series_key", "=", "(", "series", ".", "get", "(", "'measurement'", ",", "series", ".", "get", "(", "'name'", ",", "'re...
Return the set of items from the ResultSet. :return: List of tuples, (key, generator)
[ "Return", "the", "set", "of", "items", "from", "the", "ResultSet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L167-L180
220,219
influxdata/influxdb-python
influxdb/resultset.py
ResultSet._get_points_for_series
def _get_points_for_series(self, series): """Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts """ for point in series.get('values', []): yield self.point_from_cols_vals( series['column...
python
def _get_points_for_series(self, series): """Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts """ for point in series.get('values', []): yield self.point_from_cols_vals( series['column...
[ "def", "_get_points_for_series", "(", "self", ",", "series", ")", ":", "for", "point", "in", "series", ".", "get", "(", "'values'", ",", "[", "]", ")", ":", "yield", "self", ".", "point_from_cols_vals", "(", "series", "[", "'columns'", "]", ",", "point",...
Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts
[ "Return", "generator", "of", "dict", "from", "columns", "and", "values", "of", "a", "series", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L182-L192
220,220
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.point_from_cols_vals
def point_from_cols_vals(cols, vals): """Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns. """ point = {} for col_index, col_name in enumerate(cols): point[col_n...
python
def point_from_cols_vals(cols, vals): """Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns. """ point = {} for col_index, col_name in enumerate(cols): point[col_n...
[ "def", "point_from_cols_vals", "(", "cols", ",", "vals", ")", ":", "point", "=", "{", "}", "for", "col_index", ",", "col_name", "in", "enumerate", "(", "cols", ")", ":", "point", "[", "col_name", "]", "=", "vals", "[", "col_index", "]", "return", "poin...
Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns.
[ "Create", "a", "dict", "from", "columns", "and", "values", "lists", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L195-L206
220,221
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.from_dsn
def from_dsn(dsn, **kwargs): r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor...
python
def from_dsn(dsn, **kwargs): r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor...
[ "def", "from_dsn", "(", "dsn", ",", "*", "*", "kwargs", ")", ":", "init_args", "=", "{", "}", "conn_params", "=", "urlparse", "(", "dsn", ")", "scheme_info", "=", "conn_params", ".", "scheme", ".", "split", "(", "'+'", ")", "if", "len", "(", "scheme_...
r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor may be also be passed to thi...
[ "r", "Return", "an", "instaance", "of", "InfluxDBClient", "from", "given", "data", "source", "name", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L106-L169
220,222
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.request
def request(self, url, method='GET', params=None, data=None, expected_response_code=200): """Make a http request to API.""" url = "{0}/{1}".format(self._baseurl, url) if params is None: params = {} auth = { 'u': self._username, 'p': s...
python
def request(self, url, method='GET', params=None, data=None, expected_response_code=200): """Make a http request to API.""" url = "{0}/{1}".format(self._baseurl, url) if params is None: params = {} auth = { 'u': self._username, 'p': s...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "data", "=", "None", ",", "expected_response_code", "=", "200", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "_baseurl", ...
Make a http request to API.
[ "Make", "a", "http", "request", "to", "API", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L204-L248
220,223
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.write
def write(self, data): """Provide as convenience for influxdb v0.9.0, this may change.""" self.request( url="write", method='POST', params=None, data=data, expected_response_code=200 ) return True
python
def write(self, data): """Provide as convenience for influxdb v0.9.0, this may change.""" self.request( url="write", method='POST', params=None, data=data, expected_response_code=200 ) return True
[ "def", "write", "(", "self", ",", "data", ")", ":", "self", ".", "request", "(", "url", "=", "\"write\"", ",", "method", "=", "'POST'", ",", "params", "=", "None", ",", "data", "=", "data", ",", "expected_response_code", "=", "200", ")", "return", "T...
Provide as convenience for influxdb v0.9.0, this may change.
[ "Provide", "as", "convenience", "for", "influxdb", "v0", ".", "9", ".", "0", "this", "may", "change", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L250-L259
220,224
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_points
def delete_points(self, name): """Delete an entire series.""" url = "db/{0}/series/{1}".format(self._database, name) self.request( url=url, method='DELETE', expected_response_code=204 ) return True
python
def delete_points(self, name): """Delete an entire series.""" url = "db/{0}/series/{1}".format(self._database, name) self.request( url=url, method='DELETE', expected_response_code=204 ) return True
[ "def", "delete_points", "(", "self", ",", "name", ")", ":", "url", "=", "\"db/{0}/series/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "name", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expec...
Delete an entire series.
[ "Delete", "an", "entire", "series", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L364-L374
220,225
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.query
def query(self, query, time_precision='s', chunked=False): """Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks,...
python
def query(self, query, time_precision='s', chunked=False): """Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks,...
[ "def", "query", "(", "self", ",", "query", ",", "time_precision", "=", "'s'", ",", "chunked", "=", "False", ")", ":", "return", "self", ".", "_query", "(", "query", ",", "time_precision", "=", "time_precision", ",", "chunked", "=", "chunked", ")" ]
Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks, False otherwise.
[ "Query", "data", "from", "the", "influxdb", "v0", ".", "8", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L414-L423
220,226
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.create_database
def create_database(self, database): """Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean """ url = "db" data = {'name': database} self.request( url=url, ...
python
def create_database(self, database): """Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean """ url = "db" data = {'name': database} self.request( url=url, ...
[ "def", "create_database", "(", "self", ",", "database", ")", ":", "url", "=", "\"db\"", "data", "=", "{", "'name'", ":", "database", "}", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'POST'", ",", "data", "=", "data", ",", "...
Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean
[ "Create", "a", "database", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L472-L490
220,227
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_database
def delete_database(self, database): """Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean """ url = "db/{0}".format(database) self.request( url=url, method='...
python
def delete_database(self, database): """Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean """ url = "db/{0}".format(database) self.request( url=url, method='...
[ "def", "delete_database", "(", "self", ",", "database", ")", ":", "url", "=", "\"db/{0}\"", ".", "format", "(", "database", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expected_response_code", "=", "204", ")...
Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean
[ "Drop", "a", "database", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L492-L507
220,228
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_list_database
def get_list_database(self): """Get the list of databases.""" url = "db" response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
python
def get_list_database(self): """Get the list of databases.""" url = "db" response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_list_database", "(", "self", ")", ":", "url", "=", "\"db\"", "response", "=", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'GET'", ",", "expected_response_code", "=", "200", ")", "return", "response", ".", "json", "(",...
Get the list of databases.
[ "Get", "the", "list", "of", "databases", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L512-L522
220,229
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_series
def delete_series(self, series): """Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean """ url = "db/{0}/series/{1}".format( self._database, series ) self.req...
python
def delete_series(self, series): """Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean """ url = "db/{0}/series/{1}".format( self._database, series ) self.req...
[ "def", "delete_series", "(", "self", ",", "series", ")", ":", "url", "=", "\"db/{0}/series/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "series", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "e...
Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean
[ "Drop", "a", "series", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L536-L554
220,230
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_list_cluster_admins
def get_list_cluster_admins(self): """Get list of cluster admins.""" response = self.request( url="cluster_admins", method='GET', expected_response_code=200 ) return response.json()
python
def get_list_cluster_admins(self): """Get list of cluster admins.""" response = self.request( url="cluster_admins", method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_list_cluster_admins", "(", "self", ")", ":", "response", "=", "self", ".", "request", "(", "url", "=", "\"cluster_admins\"", ",", "method", "=", "'GET'", ",", "expected_response_code", "=", "200", ")", "return", "response", ".", "json", "(", ")" ...
Get list of cluster admins.
[ "Get", "list", "of", "cluster", "admins", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L597-L605
220,231
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.add_cluster_admin
def add_cluster_admin(self, new_username, new_password): """Add cluster admin.""" data = { 'name': new_username, 'password': new_password } self.request( url="cluster_admins", method='POST', data=data, expected_resp...
python
def add_cluster_admin(self, new_username, new_password): """Add cluster admin.""" data = { 'name': new_username, 'password': new_password } self.request( url="cluster_admins", method='POST', data=data, expected_resp...
[ "def", "add_cluster_admin", "(", "self", ",", "new_username", ",", "new_password", ")", ":", "data", "=", "{", "'name'", ":", "new_username", ",", "'password'", ":", "new_password", "}", "self", ".", "request", "(", "url", "=", "\"cluster_admins\"", ",", "me...
Add cluster admin.
[ "Add", "cluster", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L607-L621
220,232
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.update_cluster_admin_password
def update_cluster_admin_password(self, username, new_password): """Update cluster admin password.""" url = "cluster_admins/{0}".format(username) data = { 'password': new_password } self.request( url=url, method='POST', data=data,...
python
def update_cluster_admin_password(self, username, new_password): """Update cluster admin password.""" url = "cluster_admins/{0}".format(username) data = { 'password': new_password } self.request( url=url, method='POST', data=data,...
[ "def", "update_cluster_admin_password", "(", "self", ",", "username", ",", "new_password", ")", ":", "url", "=", "\"cluster_admins/{0}\"", ".", "format", "(", "username", ")", "data", "=", "{", "'password'", ":", "new_password", "}", "self", ".", "request", "(...
Update cluster admin password.
[ "Update", "cluster", "admin", "password", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L623-L638
220,233
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_cluster_admin
def delete_cluster_admin(self, username): """Delete cluster admin.""" url = "cluster_admins/{0}".format(username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
python
def delete_cluster_admin(self, username): """Delete cluster admin.""" url = "cluster_admins/{0}".format(username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
[ "def", "delete_cluster_admin", "(", "self", ",", "username", ")", ":", "url", "=", "\"cluster_admins/{0}\"", ".", "format", "(", "username", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expected_response_code", "...
Delete cluster admin.
[ "Delete", "cluster", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L640-L650
220,234
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.alter_database_admin
def alter_database_admin(self, username, is_admin): """Alter the database admin.""" url = "db/{0}/users/{1}".format(self._database, username) data = {'admin': is_admin} self.request( url=url, method='POST', data=data, expected_response_co...
python
def alter_database_admin(self, username, is_admin): """Alter the database admin.""" url = "db/{0}/users/{1}".format(self._database, username) data = {'admin': is_admin} self.request( url=url, method='POST', data=data, expected_response_co...
[ "def", "alter_database_admin", "(", "self", ",", "username", ",", "is_admin", ")", ":", "url", "=", "\"db/{0}/users/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "username", ")", "data", "=", "{", "'admin'", ":", "is_admin", "}", "self", ".", ...
Alter the database admin.
[ "Alter", "the", "database", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L660-L673
220,235
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_database_users
def get_database_users(self): """Get list of database users.""" url = "db/{0}/users".format(self._database) response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
python
def get_database_users(self): """Get list of database users.""" url = "db/{0}/users".format(self._database) response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_database_users", "(", "self", ")", ":", "url", "=", "\"db/{0}/users\"", ".", "format", "(", "self", ".", "_database", ")", "response", "=", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'GET'", ",", "expected_response_cod...
Get list of database users.
[ "Get", "list", "of", "database", "users", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L733-L743
220,236
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.add_database_user
def add_database_user(self, new_username, new_password, permissions=None): """Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple """ url = "db/{0}/users".format(self._database) data = { 'name': new_username, 'password': new_password ...
python
def add_database_user(self, new_username, new_password, permissions=None): """Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple """ url = "db/{0}/users".format(self._database) data = { 'name': new_username, 'password': new_password ...
[ "def", "add_database_user", "(", "self", ",", "new_username", ",", "new_password", ",", "permissions", "=", "None", ")", ":", "url", "=", "\"db/{0}/users\"", ".", "format", "(", "self", ".", "_database", ")", "data", "=", "{", "'name'", ":", "new_username", ...
Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple
[ "Add", "database", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L745-L772
220,237
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_database_user
def delete_database_user(self, username): """Delete database user.""" url = "db/{0}/users/{1}".format(self._database, username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
python
def delete_database_user(self, username): """Delete database user.""" url = "db/{0}/users/{1}".format(self._database, username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
[ "def", "delete_database_user", "(", "self", ",", "username", ")", ":", "url", "=", "\"db/{0}/users/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "username", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ...
Delete database user.
[ "Delete", "database", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L815-L825
220,238
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.send_packet
def send_packet(self, packet): """Send a UDP packet along the wire.""" data = json.dumps(packet) byte = data.encode('utf-8') self.udp_socket.sendto(byte, (self._host, self._udp_port))
python
def send_packet(self, packet): """Send a UDP packet along the wire.""" data = json.dumps(packet) byte = data.encode('utf-8') self.udp_socket.sendto(byte, (self._host, self._udp_port))
[ "def", "send_packet", "(", "self", ",", "packet", ")", ":", "data", "=", "json", ".", "dumps", "(", "packet", ")", "byte", "=", "data", ".", "encode", "(", "'utf-8'", ")", "self", ".", "udp_socket", ".", "sendto", "(", "byte", ",", "(", "self", "."...
Send a UDP packet along the wire.
[ "Send", "a", "UDP", "packet", "along", "the", "wire", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L839-L843
220,239
influxdata/influxdb-python
influxdb/influxdb08/dataframe_client.py
DataFrameClient.query
def query(self, query, time_precision='s', chunked=False): """Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', '...
python
def query(self, query, time_precision='s', chunked=False): """Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', '...
[ "def", "query", "(", "self", ",", "query", ",", "time_precision", "=", "'s'", ",", "chunked", "=", "False", ")", ":", "result", "=", "InfluxDBClient", ".", "query", "(", "self", ",", "query", "=", "query", ",", "time_precision", "=", "time_precision", ",...
Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=Fal...
[ "Query", "data", "into", "DataFrames", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/dataframe_client.py#L85-L108
220,240
groveco/django-sql-explorer
explorer/forms.py
SqlField.validate
def validate(self, value): """ Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model. """ query = Query(sql=value) passes_blacklist, failing_words = query.passes_blacklist() error = MSG_FAILED_BLACKLIST % ', '.join(failing_words)...
python
def validate(self, value): """ Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model. """ query = Query(sql=value) passes_blacklist, failing_words = query.passes_blacklist() error = MSG_FAILED_BLACKLIST % ', '.join(failing_words)...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "query", "=", "Query", "(", "sql", "=", "value", ")", "passes_blacklist", ",", "failing_words", "=", "query", ".", "passes_blacklist", "(", ")", "error", "=", "MSG_FAILED_BLACKLIST", "%", "', '", ".",...
Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model.
[ "Ensure", "that", "the", "SQL", "passes", "the", "blacklist", "." ]
622b96354e1d7ae7f7105ae90b8da3247e028623
https://github.com/groveco/django-sql-explorer/blob/622b96354e1d7ae7f7105ae90b8da3247e028623/explorer/forms.py#L11-L28
220,241
groveco/django-sql-explorer
explorer/schema.py
build_schema_info
def build_schema_info(connection_alias): """ Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("...
python
def build_schema_info(connection_alias): """ Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("...
[ "def", "build_schema_info", "(", "connection_alias", ")", ":", "connection", "=", "get_valid_connection", "(", "connection_alias", ")", "ret", "=", "[", "]", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "tables_to_introspect", "=", "connec...
Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("db_column_name", "DbFieldType"), ...
[ "Construct", "schema", "information", "via", "engine", "-", "specific", "queries", "of", "the", "tables", "in", "the", "DB", "." ]
622b96354e1d7ae7f7105ae90b8da3247e028623
https://github.com/groveco/django-sql-explorer/blob/622b96354e1d7ae7f7105ae90b8da3247e028623/explorer/schema.py#L52-L85
220,242
CodeReclaimers/neat-python
neat/graphs.py
creates_cycle
def creates_cycle(connections, test): """ Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'. """ i, o = test if i == o: return True visited = {o} while True: num_add...
python
def creates_cycle(connections, test): """ Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'. """ i, o = test if i == o: return True visited = {o} while True: num_add...
[ "def", "creates_cycle", "(", "connections", ",", "test", ")", ":", "i", ",", "o", "=", "test", "if", "i", "==", "o", ":", "return", "True", "visited", "=", "{", "o", "}", "while", "True", ":", "num_added", "=", "0", "for", "a", ",", "b", "in", ...
Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'.
[ "Returns", "true", "if", "the", "addition", "of", "the", "test", "connection", "would", "create", "a", "cycle", "assuming", "that", "no", "cycle", "already", "exists", "in", "the", "graph", "represented", "by", "connections", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/graphs.py#L3-L24
220,243
CodeReclaimers/neat-python
examples/xor/evolve-feedforward-threaded.py
run
def run(config_file): """load the config, create a population, evolve and show the result""" # Load configuration. config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_file) # Create the population, which is the top-level object for...
python
def run(config_file): """load the config, create a population, evolve and show the result""" # Load configuration. config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_file) # Create the population, which is the top-level object for...
[ "def", "run", "(", "config_file", ")", ":", "# Load configuration.", "config", "=", "neat", ".", "Config", "(", "neat", ".", "DefaultGenome", ",", "neat", ".", "DefaultReproduction", ",", "neat", ".", "DefaultSpeciesSet", ",", "neat", ".", "DefaultStagnation", ...
load the config, create a population, evolve and show the result
[ "load", "the", "config", "create", "a", "population", "evolve", "and", "show", "the", "result" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/evolve-feedforward-threaded.py#L49-L85
220,244
CodeReclaimers/neat-python
examples/memory-variable/visualize.py
plot_stats
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'): """ Plots the population's average and best fitness. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return generation = range(len(statistics....
python
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'): """ Plots the population's average and best fitness. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return generation = range(len(statistics....
[ "def", "plot_stats", "(", "statistics", ",", "ylog", "=", "False", ",", "view", "=", "False", ",", "filename", "=", "'avg_fitness.svg'", ")", ":", "if", "plt", "is", "None", ":", "warnings", ".", "warn", "(", "\"This display is not available due to a missing opt...
Plots the population's average and best fitness.
[ "Plots", "the", "population", "s", "average", "and", "best", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/memory-variable/visualize.py#L12-L40
220,245
CodeReclaimers/neat-python
examples/memory-variable/visualize.py
plot_species
def plot_species(statistics, view=False, filename='speciation.svg'): """ Visualizes speciation throughout evolution. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return species_sizes = statistics.get_species_sizes() ...
python
def plot_species(statistics, view=False, filename='speciation.svg'): """ Visualizes speciation throughout evolution. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return species_sizes = statistics.get_species_sizes() ...
[ "def", "plot_species", "(", "statistics", ",", "view", "=", "False", ",", "filename", "=", "'speciation.svg'", ")", ":", "if", "plt", "is", "None", ":", "warnings", ".", "warn", "(", "\"This display is not available due to a missing optional dependency (matplotlib)\"", ...
Visualizes speciation throughout evolution.
[ "Visualizes", "speciation", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/memory-variable/visualize.py#L89-L111
220,246
CodeReclaimers/neat-python
neat/checkpoint.py
Checkpointer.save_checkpoint
def save_checkpoint(self, config, population, species_set, generation): """ Save the current simulation state. """ filename = '{0}{1}'.format(self.filename_prefix, generation) print("Saving checkpoint to {0}".format(filename)) with gzip.open(filename, 'w', compresslevel=5) as f: ...
python
def save_checkpoint(self, config, population, species_set, generation): """ Save the current simulation state. """ filename = '{0}{1}'.format(self.filename_prefix, generation) print("Saving checkpoint to {0}".format(filename)) with gzip.open(filename, 'w', compresslevel=5) as f: ...
[ "def", "save_checkpoint", "(", "self", ",", "config", ",", "population", ",", "species_set", ",", "generation", ")", ":", "filename", "=", "'{0}{1}'", ".", "format", "(", "self", ".", "filename_prefix", ",", "generation", ")", "print", "(", "\"Saving checkpoin...
Save the current simulation state.
[ "Save", "the", "current", "simulation", "state", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/checkpoint.py#L64-L71
220,247
CodeReclaimers/neat-python
neat/checkpoint.py
Checkpointer.restore_checkpoint
def restore_checkpoint(filename): """Resumes the simulation from a previous saved point.""" with gzip.open(filename) as f: generation, config, population, species_set, rndstate = pickle.load(f) random.setstate(rndstate) return Population(config, (population, species_s...
python
def restore_checkpoint(filename): """Resumes the simulation from a previous saved point.""" with gzip.open(filename) as f: generation, config, population, species_set, rndstate = pickle.load(f) random.setstate(rndstate) return Population(config, (population, species_s...
[ "def", "restore_checkpoint", "(", "filename", ")", ":", "with", "gzip", ".", "open", "(", "filename", ")", "as", "f", ":", "generation", ",", "config", ",", "population", ",", "species_set", ",", "rndstate", "=", "pickle", ".", "load", "(", "f", ")", "...
Resumes the simulation from a previous saved point.
[ "Resumes", "the", "simulation", "from", "a", "previous", "saved", "point", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/checkpoint.py#L74-L79
220,248
CodeReclaimers/neat-python
neat/distributed.py
host_is_local
def host_is_local(hostname, port=22): # no port specified, just use the ssh port """ Returns True if the hostname points to the localhost, otherwise False. """ hostname = socket.getfqdn(hostname) if hostname in ("localhost", "0.0.0.0", "127.0.0.1", "1.0.0.127.in-addr.arpa", "1.0....
python
def host_is_local(hostname, port=22): # no port specified, just use the ssh port """ Returns True if the hostname points to the localhost, otherwise False. """ hostname = socket.getfqdn(hostname) if hostname in ("localhost", "0.0.0.0", "127.0.0.1", "1.0.0.127.in-addr.arpa", "1.0....
[ "def", "host_is_local", "(", "hostname", ",", "port", "=", "22", ")", ":", "# no port specified, just use the ssh port", "hostname", "=", "socket", ".", "getfqdn", "(", "hostname", ")", "if", "hostname", "in", "(", "\"localhost\"", ",", "\"0.0.0.0\"", ",", "\"12...
Returns True if the hostname points to the localhost, otherwise False.
[ "Returns", "True", "if", "the", "hostname", "points", "to", "the", "localhost", "otherwise", "False", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L105-L124
220,249
CodeReclaimers/neat-python
neat/distributed.py
_determine_mode
def _determine_mode(addr, mode): """ Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' ar...
python
def _determine_mode(addr, mode): """ Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' ar...
[ "def", "_determine_mode", "(", "addr", ",", "mode", ")", ":", "if", "isinstance", "(", "addr", ",", "tuple", ")", ":", "host", "=", "addr", "[", "0", "]", "elif", "type", "(", "addr", ")", "==", "type", "(", "b\"binary_string\"", ")", ":", "host", ...
Returns the mode which should be used. If mode is MODE_AUTO, this is determined by checking if 'addr' points to the local host. If it does, return MODE_PRIMARY, else return MODE_SECONDARY. If mode is either MODE_PRIMARY or MODE_SECONDARY, return the 'mode' argument. Otherwise, a ValueError is raised.
[ "Returns", "the", "mode", "which", "should", "be", "used", ".", "If", "mode", "is", "MODE_AUTO", "this", "is", "determined", "by", "checking", "if", "addr", "points", "to", "the", "local", "host", ".", "If", "it", "does", "return", "MODE_PRIMARY", "else", ...
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L127-L149
220,250
CodeReclaimers/neat-python
neat/distributed.py
chunked
def chunked(data, chunksize): """ Returns a list of chunks containing at most ``chunksize`` elements of data. """ if chunksize < 1: raise ValueError("Chunksize must be at least 1!") if int(chunksize) != chunksize: raise ValueError("Chunksize needs to be an integer") res = [] ...
python
def chunked(data, chunksize): """ Returns a list of chunks containing at most ``chunksize`` elements of data. """ if chunksize < 1: raise ValueError("Chunksize must be at least 1!") if int(chunksize) != chunksize: raise ValueError("Chunksize needs to be an integer") res = [] ...
[ "def", "chunked", "(", "data", ",", "chunksize", ")", ":", "if", "chunksize", "<", "1", ":", "raise", "ValueError", "(", "\"Chunksize must be at least 1!\"", ")", "if", "int", "(", "chunksize", ")", "!=", "chunksize", ":", "raise", "ValueError", "(", "\"Chun...
Returns a list of chunks containing at most ``chunksize`` elements of data.
[ "Returns", "a", "list", "of", "chunks", "containing", "at", "most", "chunksize", "elements", "of", "data", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L152-L169
220,251
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager.start
def start(self): """Starts or connects to the manager.""" if self.mode == MODE_PRIMARY: i = self._start() else: i = self._connect() self.manager = i
python
def start(self): """Starts or connects to the manager.""" if self.mode == MODE_PRIMARY: i = self._start() else: i = self._connect() self.manager = i
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "MODE_PRIMARY", ":", "i", "=", "self", ".", "_start", "(", ")", "else", ":", "i", "=", "self", ".", "_connect", "(", ")", "self", ".", "manager", "=", "i" ]
Starts or connects to the manager.
[ "Starts", "or", "connects", "to", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L195-L201
220,252
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager.set_secondary_state
def set_secondary_state(self, value): """Sets the value for 'secondary_state'.""" if value not in (_STATE_RUNNING, _STATE_SHUTDOWN, _STATE_FORCED_SHUTDOWN): raise ValueError( "State {!r} is invalid - needs to be one of _STATE_RUNNING, _STATE_SHUTDOWN, or _STATE_FORCED_SHUTDOW...
python
def set_secondary_state(self, value): """Sets the value for 'secondary_state'.""" if value not in (_STATE_RUNNING, _STATE_SHUTDOWN, _STATE_FORCED_SHUTDOWN): raise ValueError( "State {!r} is invalid - needs to be one of _STATE_RUNNING, _STATE_SHUTDOWN, or _STATE_FORCED_SHUTDOW...
[ "def", "set_secondary_state", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "(", "_STATE_RUNNING", ",", "_STATE_SHUTDOWN", ",", "_STATE_FORCED_SHUTDOWN", ")", ":", "raise", "ValueError", "(", "\"State {!r} is invalid - needs to be one of _STATE_RUNNIN...
Sets the value for 'secondary_state'.
[ "Sets", "the", "value", "for", "secondary_state", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L207-L216
220,253
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._get_manager_class
def _get_manager_class(self, register_callables=False): """ Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments. """ class _EvaluatorSyncManager(managers.BaseManager): """ A custom Bas...
python
def _get_manager_class(self, register_callables=False): """ Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments. """ class _EvaluatorSyncManager(managers.BaseManager): """ A custom Bas...
[ "def", "_get_manager_class", "(", "self", ",", "register_callables", "=", "False", ")", ":", "class", "_EvaluatorSyncManager", "(", "managers", ".", "BaseManager", ")", ":", "\"\"\"\n A custom BaseManager.\n Please see the documentation of `multiprocessing` ...
Returns a new 'Manager' subclass with registered methods. If 'register_callable' is True, defines the 'callable' arguments.
[ "Returns", "a", "new", "Manager", "subclass", "with", "registered", "methods", ".", "If", "register_callable", "is", "True", "defines", "the", "callable", "arguments", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L225-L282
220,254
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._connect
def _connect(self): """Connects to the manager.""" cls = self._get_manager_class(register_callables=False) ins = cls(address=self.addr, authkey=self.authkey) ins.connect() return ins
python
def _connect(self): """Connects to the manager.""" cls = self._get_manager_class(register_callables=False) ins = cls(address=self.addr, authkey=self.authkey) ins.connect() return ins
[ "def", "_connect", "(", "self", ")", ":", "cls", "=", "self", ".", "_get_manager_class", "(", "register_callables", "=", "False", ")", "ins", "=", "cls", "(", "address", "=", "self", ".", "addr", ",", "authkey", "=", "self", ".", "authkey", ")", "ins",...
Connects to the manager.
[ "Connects", "to", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L284-L289
220,255
CodeReclaimers/neat-python
neat/distributed.py
_ExtendedManager._start
def _start(self): """Starts the manager.""" cls = self._get_manager_class(register_callables=True) ins = cls(address=self.addr, authkey=self.authkey) ins.start() return ins
python
def _start(self): """Starts the manager.""" cls = self._get_manager_class(register_callables=True) ins = cls(address=self.addr, authkey=self.authkey) ins.start() return ins
[ "def", "_start", "(", "self", ")", ":", "cls", "=", "self", ".", "_get_manager_class", "(", "register_callables", "=", "True", ")", "ins", "=", "cls", "(", "address", "=", "self", ".", "addr", ",", "authkey", "=", "self", ".", "authkey", ")", "ins", ...
Starts the manager.
[ "Starts", "the", "manager", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L291-L296
220,256
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._start_primary
def _start_primary(self): """Start as the primary""" self.em.start() self.em.set_secondary_state(_STATE_RUNNING) self._set_shared_instances()
python
def _start_primary(self): """Start as the primary""" self.em.start() self.em.set_secondary_state(_STATE_RUNNING) self._set_shared_instances()
[ "def", "_start_primary", "(", "self", ")", ":", "self", ".", "em", ".", "start", "(", ")", "self", ".", "em", ".", "set_secondary_state", "(", "_STATE_RUNNING", ")", "self", ".", "_set_shared_instances", "(", ")" ]
Start as the primary
[ "Start", "as", "the", "primary" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L452-L456
220,257
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._set_shared_instances
def _set_shared_instances(self): """Sets attributes from the shared instances.""" self.inqueue = self.em.get_inqueue() self.outqueue = self.em.get_outqueue() self.namespace = self.em.get_namespace()
python
def _set_shared_instances(self): """Sets attributes from the shared instances.""" self.inqueue = self.em.get_inqueue() self.outqueue = self.em.get_outqueue() self.namespace = self.em.get_namespace()
[ "def", "_set_shared_instances", "(", "self", ")", ":", "self", ".", "inqueue", "=", "self", ".", "em", ".", "get_inqueue", "(", ")", "self", ".", "outqueue", "=", "self", ".", "em", ".", "get_outqueue", "(", ")", "self", ".", "namespace", "=", "self", ...
Sets attributes from the shared instances.
[ "Sets", "attributes", "from", "the", "shared", "instances", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L463-L467
220,258
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._reset_em
def _reset_em(self): """Resets self.em and the shared instances.""" self.em = _ExtendedManager(self.addr, self.authkey, mode=self.mode, start=False) self.em.start() self._set_shared_instances()
python
def _reset_em(self): """Resets self.em and the shared instances.""" self.em = _ExtendedManager(self.addr, self.authkey, mode=self.mode, start=False) self.em.start() self._set_shared_instances()
[ "def", "_reset_em", "(", "self", ")", ":", "self", ".", "em", "=", "_ExtendedManager", "(", "self", ".", "addr", ",", "self", ".", "authkey", ",", "mode", "=", "self", ".", "mode", ",", "start", "=", "False", ")", "self", ".", "em", ".", "start", ...
Resets self.em and the shared instances.
[ "Resets", "self", ".", "em", "and", "the", "shared", "instances", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L469-L473
220,259
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator._secondary_loop
def _secondary_loop(self, reconnect=False): """The worker loop for the secondary nodes.""" if self.num_workers > 1: pool = multiprocessing.Pool(self.num_workers) else: pool = None should_reconnect = True while should_reconnect: i = 0 ...
python
def _secondary_loop(self, reconnect=False): """The worker loop for the secondary nodes.""" if self.num_workers > 1: pool = multiprocessing.Pool(self.num_workers) else: pool = None should_reconnect = True while should_reconnect: i = 0 ...
[ "def", "_secondary_loop", "(", "self", ",", "reconnect", "=", "False", ")", ":", "if", "self", ".", "num_workers", ">", "1", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "self", ".", "num_workers", ")", "else", ":", "pool", "=", "None", "shou...
The worker loop for the secondary nodes.
[ "The", "worker", "loop", "for", "the", "secondary", "nodes", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L475-L555
220,260
CodeReclaimers/neat-python
neat/distributed.py
DistributedEvaluator.evaluate
def evaluate(self, genomes, config): """ Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode. """ if self.mode != MODE_PRIMARY: raise ModeError("Not in primary mode!") tasks = [(genome_id, genome, co...
python
def evaluate(self, genomes, config): """ Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode. """ if self.mode != MODE_PRIMARY: raise ModeError("Not in primary mode!") tasks = [(genome_id, genome, co...
[ "def", "evaluate", "(", "self", ",", "genomes", ",", "config", ")", ":", "if", "self", ".", "mode", "!=", "MODE_PRIMARY", ":", "raise", "ModeError", "(", "\"Not in primary mode!\"", ")", "tasks", "=", "[", "(", "genome_id", ",", "genome", ",", "config", ...
Evaluates the genomes. This method raises a ModeError if the DistributedEvaluator is not in primary mode.
[ "Evaluates", "the", "genomes", ".", "This", "method", "raises", "a", "ModeError", "if", "the", "DistributedEvaluator", "is", "not", "in", "primary", "mode", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L557-L583
220,261
CodeReclaimers/neat-python
neat/reproduction.py
DefaultReproduction.reproduce
def reproduce(self, config, species, pop_size, generation): """ Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents. """ # TODO: I don't like this modification of the species and stagnation objects, # because it requires inte...
python
def reproduce(self, config, species, pop_size, generation): """ Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents. """ # TODO: I don't like this modification of the species and stagnation objects, # because it requires inte...
[ "def", "reproduce", "(", "self", ",", "config", ",", "species", ",", "pop_size", ",", "generation", ")", ":", "# TODO: I don't like this modification of the species and stagnation objects,", "# because it requires internal knowledge of the objects.", "# Filter out stagnated species, ...
Handles creation of genomes, either from scratch or by sexual or asexual reproduction from parents.
[ "Handles", "creation", "of", "genomes", "either", "from", "scratch", "or", "by", "sexual", "or", "asexual", "reproduction", "from", "parents", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/reproduction.py#L84-L188
220,262
CodeReclaimers/neat-python
neat/population.py
Population.run
def run(self, fitness_function, n=None): """ Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, ...
python
def run(self, fitness_function, n=None): """ Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, ...
[ "def", "run", "(", "self", ",", "fitness_function", ",", "n", "=", "None", ")", ":", "if", "self", ".", "config", ".", "no_fitness_termination", "and", "(", "n", "is", "None", ")", ":", "raise", "RuntimeError", "(", "\"Cannot have no generational limit with no...
Runs NEAT's genetic algorithm for at most n generations. If n is None, run until solution is found or extinction occurs. The user-provided fitness_function must take only two arguments: 1. The population as a list of (genome id, genome) tuples. 2. The current configuration obje...
[ "Runs", "NEAT", "s", "genetic", "algorithm", "for", "at", "most", "n", "generations", ".", "If", "n", "is", "None", "run", "until", "solution", "is", "found", "or", "extinction", "occurs", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/population.py#L59-L136
220,263
CodeReclaimers/neat-python
neat/genes.py
BaseGene.crossover
def crossover(self, gene2): """ Creates a new gene randomly inheriting attributes from its parents.""" assert self.key == gene2.key # Note: we use "a if random() > 0.5 else b" instead of choice((a, b)) # here because `choice` is substantially slower. new_gene = self.__class__(se...
python
def crossover(self, gene2): """ Creates a new gene randomly inheriting attributes from its parents.""" assert self.key == gene2.key # Note: we use "a if random() > 0.5 else b" instead of choice((a, b)) # here because `choice` is substantially slower. new_gene = self.__class__(se...
[ "def", "crossover", "(", "self", ",", "gene2", ")", ":", "assert", "self", ".", "key", "==", "gene2", ".", "key", "# Note: we use \"a if random() > 0.5 else b\" instead of choice((a, b))", "# here because `choice` is substantially slower.", "new_gene", "=", "self", ".", "...
Creates a new gene randomly inheriting attributes from its parents.
[ "Creates", "a", "new", "gene", "randomly", "inheriting", "attributes", "from", "its", "parents", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genes.py#L60-L73
220,264
CodeReclaimers/neat-python
examples/circuits/evolve.py
CircuitGenome.distance
def distance(self, other, config): """ Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation. """ # Compute node gene distance component. node_distance = 0.0 if self.nodes or oth...
python
def distance(self, other, config): """ Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation. """ # Compute node gene distance component. node_distance = 0.0 if self.nodes or oth...
[ "def", "distance", "(", "self", ",", "other", ",", "config", ")", ":", "# Compute node gene distance component.", "node_distance", "=", "0.0", "if", "self", ".", "nodes", "or", "other", ".", "nodes", ":", "disjoint_nodes", "=", "0", "for", "k2", "in", "iterk...
Returns the genetic distance between this genome and the other. This distance value is used to compute genome compatibility for speciation.
[ "Returns", "the", "genetic", "distance", "between", "this", "genome", "and", "the", "other", ".", "This", "distance", "value", "is", "used", "to", "compute", "genome", "compatibility", "for", "speciation", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/circuits/evolve.py#L227-L273
220,265
CodeReclaimers/neat-python
neat/ctrnn/__init__.py
CTRNN.advance
def advance(self, inputs, advance_time, time_step=None): """ Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time. """ final_time_seconds = self.time_seconds + advance_time # Use half of the m...
python
def advance(self, inputs, advance_time, time_step=None): """ Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time. """ final_time_seconds = self.time_seconds + advance_time # Use half of the m...
[ "def", "advance", "(", "self", ",", "inputs", ",", "advance_time", ",", "time_step", "=", "None", ")", ":", "final_time_seconds", "=", "self", ".", "time_seconds", "+", "advance_time", "# Use half of the max allowed time step if none is given.", "if", "time_step", "is...
Advance the simulation by the given amount of time, assuming that inputs are constant at the given values during the simulated time.
[ "Advance", "the", "simulation", "by", "the", "given", "amount", "of", "time", "assuming", "that", "inputs", "are", "constant", "at", "the", "given", "values", "during", "the", "simulated", "time", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/ctrnn/__init__.py#L53-L87
220,266
CodeReclaimers/neat-python
neat/stagnation.py
DefaultStagnation.update
def update(self, species_set, generation): """ Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured speci...
python
def update(self, species_set, generation): """ Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured speci...
[ "def", "update", "(", "self", ",", "species_set", ",", "generation", ")", ":", "species_data", "=", "[", "]", "for", "sid", ",", "s", "in", "iteritems", "(", "species_set", ".", "species", ")", ":", "if", "s", ".", "fitness_history", ":", "prev_fitness",...
Required interface method. Updates species fitness history information, checking for ones that have not improved in max_stagnation generations, and - unless it would result in the number of species dropping below the configured species_elitism parameter if they were removed, in which cas...
[ "Required", "interface", "method", ".", "Updates", "species", "fitness", "history", "information", "checking", "for", "ones", "that", "have", "not", "improved", "in", "max_stagnation", "generations", "and", "-", "unless", "it", "would", "result", "in", "the", "n...
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/stagnation.py#L30-L79
220,267
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.start
def start(self): """Starts the worker threads""" if self.working: return self.working = True for i in range(self.num_workers): w = threading.Thread( name="Worker Thread #{i}".format(i=i), target=self._worker, ) ...
python
def start(self): """Starts the worker threads""" if self.working: return self.working = True for i in range(self.num_workers): w = threading.Thread( name="Worker Thread #{i}".format(i=i), target=self._worker, ) ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "working", ":", "return", "self", ".", "working", "=", "True", "for", "i", "in", "range", "(", "self", ".", "num_workers", ")", ":", "w", "=", "threading", ".", "Thread", "(", "name", "=", ...
Starts the worker threads
[ "Starts", "the", "worker", "threads" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L51-L63
220,268
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.stop
def stop(self): """Stops the worker threads and waits for them to finish""" self.working = False for w in self.workers: w.join() self.workers = []
python
def stop(self): """Stops the worker threads and waits for them to finish""" self.working = False for w in self.workers: w.join() self.workers = []
[ "def", "stop", "(", "self", ")", ":", "self", ".", "working", "=", "False", "for", "w", "in", "self", ".", "workers", ":", "w", ".", "join", "(", ")", "self", ".", "workers", "=", "[", "]" ]
Stops the worker threads and waits for them to finish
[ "Stops", "the", "worker", "threads", "and", "waits", "for", "them", "to", "finish" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L65-L70
220,269
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator._worker
def _worker(self): """The worker function""" while self.working: try: genome_id, genome, config = self.inqueue.get( block=True, timeout=0.2, ) except queue.Empty: continue f = ...
python
def _worker(self): """The worker function""" while self.working: try: genome_id, genome, config = self.inqueue.get( block=True, timeout=0.2, ) except queue.Empty: continue f = ...
[ "def", "_worker", "(", "self", ")", ":", "while", "self", ".", "working", ":", "try", ":", "genome_id", ",", "genome", ",", "config", "=", "self", ".", "inqueue", ".", "get", "(", "block", "=", "True", ",", "timeout", "=", "0.2", ",", ")", "except"...
The worker function
[ "The", "worker", "function" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L72-L83
220,270
CodeReclaimers/neat-python
neat/threaded.py
ThreadedEvaluator.evaluate
def evaluate(self, genomes, config): """Evaluate the genomes""" if not self.working: self.start() p = 0 for genome_id, genome in genomes: p += 1 self.inqueue.put((genome_id, genome, config)) # assign the fitness back to each genome whi...
python
def evaluate(self, genomes, config): """Evaluate the genomes""" if not self.working: self.start() p = 0 for genome_id, genome in genomes: p += 1 self.inqueue.put((genome_id, genome, config)) # assign the fitness back to each genome whi...
[ "def", "evaluate", "(", "self", ",", "genomes", ",", "config", ")", ":", "if", "not", "self", ".", "working", ":", "self", ".", "start", "(", ")", "p", "=", "0", "for", "genome_id", ",", "genome", "in", "genomes", ":", "p", "+=", "1", "self", "."...
Evaluate the genomes
[ "Evaluate", "the", "genomes" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/threaded.py#L85-L98
220,271
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNeuron.advance
def advance(self, dt_msec): """ Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d """ # TODO: Make the time step adjustable, and choose an appro...
python
def advance(self, dt_msec): """ Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d """ # TODO: Make the time step adjustable, and choose an appro...
[ "def", "advance", "(", "self", ",", "dt_msec", ")", ":", "# TODO: Make the time step adjustable, and choose an appropriate", "# numerical integration method to maintain stability.", "# TODO: The need to catch overflows indicates that the current method is", "# not stable for all possible netwo...
Advances simulation time by the given time step in milliseconds. v' = 0.04 * v^2 + 5v + 140 - u + I u' = a * (b * v - u) if v >= 30 then v <- c, u <- u + d
[ "Advances", "simulation", "time", "by", "the", "given", "time", "step", "in", "milliseconds", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L90-L118
220,272
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNeuron.reset
def reset(self): """Resets all state variables.""" self.v = self.c self.u = self.b * self.v self.fired = 0.0 self.current = self.bias
python
def reset(self): """Resets all state variables.""" self.v = self.c self.u = self.b * self.v self.fired = 0.0 self.current = self.bias
[ "def", "reset", "(", "self", ")", ":", "self", ".", "v", "=", "self", ".", "c", "self", ".", "u", "=", "self", ".", "b", "*", "self", ".", "v", "self", ".", "fired", "=", "0.0", "self", ".", "current", "=", "self", ".", "bias" ]
Resets all state variables.
[ "Resets", "all", "state", "variables", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L120-L125
220,273
CodeReclaimers/neat-python
neat/iznn/__init__.py
IZNN.set_inputs
def set_inputs(self, inputs): """Assign input voltages.""" if len(inputs) != len(self.inputs): raise RuntimeError( "Number of inputs {0:d} does not match number of input nodes {1:d}".format( len(inputs), len(self.inputs))) for i, v in zip(self.inpu...
python
def set_inputs(self, inputs): """Assign input voltages.""" if len(inputs) != len(self.inputs): raise RuntimeError( "Number of inputs {0:d} does not match number of input nodes {1:d}".format( len(inputs), len(self.inputs))) for i, v in zip(self.inpu...
[ "def", "set_inputs", "(", "self", ",", "inputs", ")", ":", "if", "len", "(", "inputs", ")", "!=", "len", "(", "self", ".", "inputs", ")", ":", "raise", "RuntimeError", "(", "\"Number of inputs {0:d} does not match number of input nodes {1:d}\"", ".", "format", "...
Assign input voltages.
[ "Assign", "input", "voltages", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/iznn/__init__.py#L136-L143
220,274
CodeReclaimers/neat-python
examples/xor/evolve-spiking.py
compute_output
def compute_output(t0, t1): '''Compute the network's output based on the "time to first spike" of the two output neurons.''' if t0 is None or t1 is None: # If neither of the output neurons fired within the allotted time, # give a response which produces a large error. return -1.0 els...
python
def compute_output(t0, t1): '''Compute the network's output based on the "time to first spike" of the two output neurons.''' if t0 is None or t1 is None: # If neither of the output neurons fired within the allotted time, # give a response which produces a large error. return -1.0 els...
[ "def", "compute_output", "(", "t0", ",", "t1", ")", ":", "if", "t0", "is", "None", "or", "t1", "is", "None", ":", "# If neither of the output neurons fired within the allotted time,", "# give a response which produces a large error.", "return", "-", "1.0", "else", ":", ...
Compute the network's output based on the "time to first spike" of the two output neurons.
[ "Compute", "the", "network", "s", "output", "based", "on", "the", "time", "to", "first", "spike", "of", "the", "two", "output", "neurons", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/evolve-spiking.py#L19-L30
220,275
CodeReclaimers/neat-python
neat/species.py
DefaultSpeciesSet.speciate
def speciate(self, config, population, generation): """ Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be...
python
def speciate(self, config, population, generation): """ Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be...
[ "def", "speciate", "(", "self", ",", "config", ",", "population", ",", "generation", ")", ":", "assert", "isinstance", "(", "population", ",", "dict", ")", "compatibility_threshold", "=", "self", ".", "species_set_config", ".", "compatibility_threshold", "# Find t...
Place genomes into species by genetic similarity. Note that this method assumes the current representatives of the species are from the old generation, and that after speciation has been performed, the old representatives should be dropped and replaced with representatives from the new generati...
[ "Place", "genomes", "into", "species", "by", "genetic", "similarity", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/species.py#L65-L139
220,276
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.get_average_cross_validation_fitness
def get_average_cross_validation_fitness(self): # pragma: no cover """Get the per-generation average cross_validation fitness.""" avg_cross_validation_fitness = [] for stats in self.generation_cross_validation_statistics: scores = [] for fitness in stats.values(): ...
python
def get_average_cross_validation_fitness(self): # pragma: no cover """Get the per-generation average cross_validation fitness.""" avg_cross_validation_fitness = [] for stats in self.generation_cross_validation_statistics: scores = [] for fitness in stats.values(): ...
[ "def", "get_average_cross_validation_fitness", "(", "self", ")", ":", "# pragma: no cover", "avg_cross_validation_fitness", "=", "[", "]", "for", "stats", "in", "self", ".", "generation_cross_validation_statistics", ":", "scores", "=", "[", "]", "for", "fitness", "in"...
Get the per-generation average cross_validation fitness.
[ "Get", "the", "per", "-", "generation", "average", "cross_validation", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L62-L71
220,277
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.best_unique_genomes
def best_unique_genomes(self, n): """Returns the most n fit genomes, with no duplication.""" best_unique = {} for g in self.most_fit_genomes: best_unique[g.key] = g best_unique_list = list(best_unique.values()) def key(genome): return genome.fitness ...
python
def best_unique_genomes(self, n): """Returns the most n fit genomes, with no duplication.""" best_unique = {} for g in self.most_fit_genomes: best_unique[g.key] = g best_unique_list = list(best_unique.values()) def key(genome): return genome.fitness ...
[ "def", "best_unique_genomes", "(", "self", ",", "n", ")", ":", "best_unique", "=", "{", "}", "for", "g", "in", "self", ".", "most_fit_genomes", ":", "best_unique", "[", "g", ".", "key", "]", "=", "g", "best_unique_list", "=", "list", "(", "best_unique", ...
Returns the most n fit genomes, with no duplication.
[ "Returns", "the", "most", "n", "fit", "genomes", "with", "no", "duplication", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L73-L83
220,278
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.best_genomes
def best_genomes(self, n): """Returns the n most fit genomes ever seen.""" def key(g): return g.fitness return sorted(self.most_fit_genomes, key=key, reverse=True)[:n]
python
def best_genomes(self, n): """Returns the n most fit genomes ever seen.""" def key(g): return g.fitness return sorted(self.most_fit_genomes, key=key, reverse=True)[:n]
[ "def", "best_genomes", "(", "self", ",", "n", ")", ":", "def", "key", "(", "g", ")", ":", "return", "g", ".", "fitness", "return", "sorted", "(", "self", ".", "most_fit_genomes", ",", "key", "=", "key", ",", "reverse", "=", "True", ")", "[", ":", ...
Returns the n most fit genomes ever seen.
[ "Returns", "the", "n", "most", "fit", "genomes", "ever", "seen", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L85-L90
220,279
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_genome_fitness
def save_genome_fitness(self, delimiter=' ', filename='fitness_history.csv', with_cross_validation=False): """ Saves the population's best and average fitness. """ with open(filename, 'w') as f: w = csv.write...
python
def save_genome_fitness(self, delimiter=' ', filename='fitness_history.csv', with_cross_validation=False): """ Saves the population's best and average fitness. """ with open(filename, 'w') as f: w = csv.write...
[ "def", "save_genome_fitness", "(", "self", ",", "delimiter", "=", "' '", ",", "filename", "=", "'fitness_history.csv'", ",", "with_cross_validation", "=", "False", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv",...
Saves the population's best and average fitness.
[ "Saves", "the", "population", "s", "best", "and", "average", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L101-L122
220,280
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_species_count
def save_species_count(self, delimiter=' ', filename='speciation.csv'): """ Log speciation throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_sizes(): w.writerow(s)
python
def save_species_count(self, delimiter=' ', filename='speciation.csv'): """ Log speciation throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_sizes(): w.writerow(s)
[ "def", "save_species_count", "(", "self", ",", "delimiter", "=", "' '", ",", "filename", "=", "'speciation.csv'", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv", ".", "writer", "(", "f", ",", "delimiter", ...
Log speciation throughout evolution.
[ "Log", "speciation", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L124-L129
220,281
CodeReclaimers/neat-python
neat/statistics.py
StatisticsReporter.save_species_fitness
def save_species_fitness(self, delimiter=' ', null_value='NA', filename='species_fitness.csv'): """ Log species' average fitness throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_fitness(null_value): ...
python
def save_species_fitness(self, delimiter=' ', null_value='NA', filename='species_fitness.csv'): """ Log species' average fitness throughout evolution. """ with open(filename, 'w') as f: w = csv.writer(f, delimiter=delimiter) for s in self.get_species_fitness(null_value): ...
[ "def", "save_species_fitness", "(", "self", ",", "delimiter", "=", "' '", ",", "null_value", "=", "'NA'", ",", "filename", "=", "'species_fitness.csv'", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "w", "=", "csv", ".", "...
Log species' average fitness throughout evolution.
[ "Log", "species", "average", "fitness", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/statistics.py#L131-L136
220,282
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.configure_new
def configure_new(self, config): """Configure a new genome based on the given configuration.""" # Create node genes for the output pins. for node_key in config.output_keys: self.nodes[node_key] = self.create_node(config, node_key) # Add hidden nodes if requested. if...
python
def configure_new(self, config): """Configure a new genome based on the given configuration.""" # Create node genes for the output pins. for node_key in config.output_keys: self.nodes[node_key] = self.create_node(config, node_key) # Add hidden nodes if requested. if...
[ "def", "configure_new", "(", "self", ",", "config", ")", ":", "# Create node genes for the output pins.", "for", "node_key", "in", "config", ".", "output_keys", ":", "self", ".", "nodes", "[", "node_key", "]", "=", "self", ".", "create_node", "(", "config", ",...
Configure a new genome based on the given configuration.
[ "Configure", "a", "new", "genome", "based", "on", "the", "given", "configuration", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L175-L232
220,283
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.configure_crossover
def configure_crossover(self, genome1, genome2, config): """ Configure a new genome by crossover from two parent genomes. """ assert isinstance(genome1.fitness, (int, float)) assert isinstance(genome2.fitness, (int, float)) if genome1.fitness > genome2.fitness: parent1, paren...
python
def configure_crossover(self, genome1, genome2, config): """ Configure a new genome by crossover from two parent genomes. """ assert isinstance(genome1.fitness, (int, float)) assert isinstance(genome2.fitness, (int, float)) if genome1.fitness > genome2.fitness: parent1, paren...
[ "def", "configure_crossover", "(", "self", ",", "genome1", ",", "genome2", ",", "config", ")", ":", "assert", "isinstance", "(", "genome1", ".", "fitness", ",", "(", "int", ",", "float", ")", ")", "assert", "isinstance", "(", "genome2", ".", "fitness", "...
Configure a new genome by crossover from two parent genomes.
[ "Configure", "a", "new", "genome", "by", "crossover", "from", "two", "parent", "genomes", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L234-L265
220,284
CodeReclaimers/neat-python
neat/genome.py
DefaultGenome.connect_full_direct
def connect_full_direct(self, config): """ Create a fully-connected genome, including direct input-output connections. """ for input_id, output_id in self.compute_full_connections(config, True): connection = self.create_connection(config, input_id, output_id) self.connections[con...
python
def connect_full_direct(self, config): """ Create a fully-connected genome, including direct input-output connections. """ for input_id, output_id in self.compute_full_connections(config, True): connection = self.create_connection(config, input_id, output_id) self.connections[con...
[ "def", "connect_full_direct", "(", "self", ",", "config", ")", ":", "for", "input_id", ",", "output_id", "in", "self", ".", "compute_full_connections", "(", "config", ",", "True", ")", ":", "connection", "=", "self", ".", "create_connection", "(", "config", ...
Create a fully-connected genome, including direct input-output connections.
[ "Create", "a", "fully", "-", "connected", "genome", "including", "direct", "input", "-", "output", "connections", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/genome.py#L541-L545
220,285
CodeReclaimers/neat-python
neat/config.py
ConfigParameter.interpret
def interpret(self, config_dict): """ Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors. """ value = config_dict.get(self.name) if value is None: if self.default is None: ...
python
def interpret(self, config_dict): """ Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors. """ value = config_dict.get(self.name) if value is None: if self.default is None: ...
[ "def", "interpret", "(", "self", ",", "config_dict", ")", ":", "value", "=", "config_dict", ".", "get", "(", "self", ".", "name", ")", "if", "value", "is", "None", ":", "if", "self", ".", "default", "is", "None", ":", "raise", "RuntimeError", "(", "'...
Converts the config_parser output into the proper type, supplies defaults if available and needed, and checks for some errors.
[ "Converts", "the", "config_parser", "output", "into", "the", "proper", "type", "supplies", "defaults", "if", "available", "and", "needed", "and", "checks", "for", "some", "errors", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/config.py#L47-L84
220,286
CodeReclaimers/neat-python
examples/xor/visualize.py
plot_spikes
def plot_spikes(spikes, view=False, filename=None, title=None): """ Plots the trains for a single spiking neuron. """ t_values = [t for t, I, v, u, f in spikes] v_values = [v for t, I, v, u, f in spikes] u_values = [u for t, I, v, u, f in spikes] I_values = [I for t, I, v, u, f in spikes] f_valu...
python
def plot_spikes(spikes, view=False, filename=None, title=None): """ Plots the trains for a single spiking neuron. """ t_values = [t for t, I, v, u, f in spikes] v_values = [v for t, I, v, u, f in spikes] u_values = [u for t, I, v, u, f in spikes] I_values = [I for t, I, v, u, f in spikes] f_valu...
[ "def", "plot_spikes", "(", "spikes", ",", "view", "=", "False", ",", "filename", "=", "None", ",", "title", "=", "None", ")", ":", "t_values", "=", "[", "t", "for", "t", ",", "I", ",", "v", ",", "u", ",", "f", "in", "spikes", "]", "v_values", "...
Plots the trains for a single spiking neuron.
[ "Plots", "the", "trains", "for", "a", "single", "spiking", "neuron", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/visualize.py#L42-L88
220,287
carpedm20/fbchat
fbchat/_client.py
Client.isLoggedIn
def isLoggedIn(self): """ Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool """ # Send a request to the login url, to see if we're directed to the home page r = self._cleanGet(self.req_url.LOGIN, all...
python
def isLoggedIn(self): """ Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool """ # Send a request to the login url, to see if we're directed to the home page r = self._cleanGet(self.req_url.LOGIN, all...
[ "def", "isLoggedIn", "(", "self", ")", ":", "# Send a request to the login url, to see if we're directed to the home page", "r", "=", "self", ".", "_cleanGet", "(", "self", ".", "req_url", ".", "LOGIN", ",", "allow_redirects", "=", "False", ")", "return", "\"Location\...
Sends a request to Facebook to check the login status :return: True if the client is still logged in :rtype: bool
[ "Sends", "a", "request", "to", "Facebook", "to", "check", "the", "login", "status" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L426-L435
220,288
carpedm20/fbchat
fbchat/_client.py
Client.setSession
def setSession(self, session_cookies): """Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool """ # Quick check to see if...
python
def setSession(self, session_cookies): """Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool """ # Quick check to see if...
[ "def", "setSession", "(", "self", ",", "session_cookies", ")", ":", "# Quick check to see if session_cookies is formatted properly", "if", "not", "session_cookies", "or", "\"c_user\"", "not", "in", "session_cookies", ":", "return", "False", "try", ":", "# Load cookies int...
Loads session cookies :param session_cookies: A dictionay containing session cookies :type session_cookies: dict :return: False if `session_cookies` does not contain proper cookies :rtype: bool
[ "Loads", "session", "cookies" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L445-L467
220,289
carpedm20/fbchat
fbchat/_client.py
Client.logout
def logout(self): """ Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool """ if not hasattr(self, "_fb_h"): h_r...
python
def logout(self): """ Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool """ if not hasattr(self, "_fb_h"): h_r...
[ "def", "logout", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_fb_h\"", ")", ":", "h_r", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "MODERN_SETTINGS_MENU", ",", "{", "\"pmid\"", ":", "\"4\"", "}", ")", "self",...
Safely logs out the client :param timeout: See `requests timeout <http://docs.python-requests.org/en/master/user/advanced/#timeouts>`_ :return: True if the action was successful :rtype: bool
[ "Safely", "logs", "out", "the", "client" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L506-L524
220,290
carpedm20/fbchat
fbchat/_client.py
Client._getThread
def _getThread(self, given_thread_id=None, given_thread_type=None): """ Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple ...
python
def _getThread(self, given_thread_id=None, given_thread_type=None): """ Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple ...
[ "def", "_getThread", "(", "self", ",", "given_thread_id", "=", "None", ",", "given_thread_type", "=", "None", ")", ":", "if", "given_thread_id", "is", "None", ":", "if", "self", ".", "_default_thread_id", "is", "not", "None", ":", "return", "self", ".", "_...
Checks if thread ID is given, checks if default is set and returns correct values :raises ValueError: If thread ID is not given and there is no default :return: Thread ID and thread type :rtype: tuple
[ "Checks", "if", "thread", "ID", "is", "given", "checks", "if", "default", "is", "set", "and", "returns", "correct", "values" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L534-L548
220,291
carpedm20/fbchat
fbchat/_client.py
Client.setDefaultThread
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._def...
python
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._def...
[ "def", "setDefaultThread", "(", "self", ",", "thread_id", ",", "thread_type", ")", ":", "self", ".", "_default_thread_id", "=", "thread_id", "self", ".", "_default_thread_type", "=", "thread_type" ]
Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType
[ "Sets", "default", "thread", "to", "send", "messages", "to" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L550-L559
220,292
carpedm20/fbchat
fbchat/_client.py
Client.fetchThreads
def fetchThreads(self, thread_location, before=None, after=None, limit=None): """ Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread b...
python
def fetchThreads(self, thread_location, before=None, after=None, limit=None): """ Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread b...
[ "def", "fetchThreads", "(", "self", ",", "thread_location", ",", "before", "=", "None", ",", "after", "=", "None", ",", "limit", "=", "None", ")", ":", "threads", "=", "[", "]", "last_thread_timestamp", "=", "None", "while", "True", ":", "# break if limit ...
Get all threads in thread_location. Threads will be sorted from newest to oldest. :param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER :param before: Fetch only thread before this epoch (in ms) (default all threads) :param after: Fetch only thread after this ...
[ "Get", "all", "threads", "in", "thread_location", ".", "Threads", "will", "be", "sorted", "from", "newest", "to", "oldest", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L577-L628
220,293
carpedm20/fbchat
fbchat/_client.py
Client.fetchAllUsersFromThreads
def fetchAllUsersFromThreads(self, threads): """ Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ users =...
python
def fetchAllUsersFromThreads(self, threads): """ Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ users =...
[ "def", "fetchAllUsersFromThreads", "(", "self", ",", "threads", ")", ":", "users", "=", "[", "]", "users_to_fetch", "=", "[", "]", "# It's more efficient to fetch all users in one request", "for", "thread", "in", "threads", ":", "if", "thread", ".", "type", "==", ...
Get all users involved in threads. :param threads: models.Thread: List of threads to check for users :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed
[ "Get", "all", "users", "involved", "in", "threads", "." ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L630-L654
220,294
carpedm20/fbchat
fbchat/_client.py
Client.fetchAllUsers
def fetchAllUsers(self): """ Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ data = {"viewer": self._uid} j = self._post( self.req_url.ALL_U...
python
def fetchAllUsers(self): """ Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed """ data = {"viewer": self._uid} j = self._post( self.req_url.ALL_U...
[ "def", "fetchAllUsers", "(", "self", ")", ":", "data", "=", "{", "\"viewer\"", ":", "self", ".", "_uid", "}", "j", "=", "self", ".", "_post", "(", "self", ".", "req_url", ".", "ALL_USERS", ",", "query", "=", "data", ",", "fix_request", "=", "True", ...
Gets all users the client is currently chatting with :return: :class:`models.User` objects :rtype: list :raises: FBchatException if request failed
[ "Gets", "all", "users", "the", "client", "is", "currently", "chatting", "with" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L656-L678
220,295
carpedm20/fbchat
fbchat/_client.py
Client.searchForPages
def searchForPages(self, name, limit=10): """ Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed """ params = {"search": name, "li...
python
def searchForPages(self, name, limit=10): """ Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed """ params = {"search": name, "li...
[ "def", "searchForPages", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "Gr...
Find and get page by its name :param name: Name of the page :return: :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "page", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L695-L707
220,296
carpedm20/fbchat
fbchat/_client.py
Client.searchForGroups
def searchForGroups(self, name, limit=10): """ Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatEx...
python
def searchForGroups(self, name, limit=10): """ Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatEx...
[ "def", "searchForGroups", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "G...
Find and get group thread by its name :param name: Name of the group thread :param limit: The max. amount of groups to fetch :return: :class:`models.Group` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "group", "thread", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L709-L722
220,297
carpedm20/fbchat
fbchat/_client.py
Client.searchForThreads
def searchForThreads(self, name, limit=10): """ Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance ...
python
def searchForThreads(self, name, limit=10): """ Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance ...
[ "def", "searchForThreads", "(", "self", ",", "name", ",", "limit", "=", "10", ")", ":", "params", "=", "{", "\"search\"", ":", "name", ",", "\"limit\"", ":", "limit", "}", "j", "=", "self", ".", "graphql_request", "(", "GraphQL", "(", "query", "=", "...
Find and get a thread by its name :param name: Name of the thread :param limit: The max. amount of groups to fetch :return: :class:`models.User`, :class:`models.Group` and :class:`models.Page` objects, ordered by relevance :rtype: list :raises: FBchatException if request failed
[ "Find", "and", "get", "a", "thread", "by", "its", "name" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L724-L754
220,298
carpedm20/fbchat
fbchat/_client.py
Client.searchForMessageIDs
def searchForMessageIDs(self, query, offset=0, limit=5, thread_id=None): """ Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to ...
python
def searchForMessageIDs(self, query, offset=0, limit=5, thread_id=None): """ Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to ...
[ "def", "searchForMessageIDs", "(", "self", ",", "query", ",", "offset", "=", "0", ",", "limit", "=", "5", ",", "thread_id", "=", "None", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "None", ")", "dat...
Find and get message IDs by query :param query: Text to search for :param offset: Number of messages to skip :param limit: Max. number of messages to retrieve :param thread_id: User/Group ID to search in. See :ref:`intro_threads` :type offset: int :type limit: int ...
[ "Find", "and", "get", "message", "IDs", "by", "query" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L756-L786
220,299
carpedm20/fbchat
fbchat/_client.py
Client.search
def search(self, query, fetch_messages=False, thread_limit=5, message_limit=5): """ Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threa...
python
def search(self, query, fetch_messages=False, thread_limit=5, message_limit=5): """ Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threa...
[ "def", "search", "(", "self", ",", "query", ",", "fetch_messages", "=", "False", ",", "thread_limit", "=", "5", ",", "message_limit", "=", "5", ")", ":", "data", "=", "{", "\"query\"", ":", "query", ",", "\"snippetLimit\"", ":", "thread_limit", "}", "j",...
Searches for messages in all threads :param query: Text to search for :param fetch_messages: Whether to fetch :class:`models.Message` objects or IDs only :param thread_limit: Max. number of threads to retrieve :param message_limit: Max. number of messages to retrieve :type threa...
[ "Searches", "for", "messages", "in", "all", "threads" ]
f480d68b5773473e6daba7f66075ee30e8d737a8
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L811-L839