Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
in_normal_range
(dt: datetime.datetime)
Check if DateTime is in normal range
Check if DateTime is in normal range
def in_normal_range(dt: datetime.datetime): """Check if DateTime is in normal range """ return dt <= datetime.datetime(2105, 12, 31, 23, 59, 59, 999999) and dt >= datetime.datetime(1970, 1, 1, 0, 0, 0)
[ "def", "in_normal_range", "(", "dt", ":", "datetime", ".", "datetime", ")", ":", "return", "dt", "<=", "datetime", ".", "datetime", "(", "2105", ",", "12", ",", "31", ",", "23", ",", "59", ",", "59", ",", "999999", ")", "and", "dt", ">=", "datetime...
[ 9, 0 ]
[ 12, 117 ]
python
en
['en', 'en', 'en']
True
years_range
(stress=False, padding=(0, 0))
Returns a set of year values used for testing.
Returns a set of year values used for testing.
def years_range(stress=False, padding=(0, 0)): """Returns a set of year values used for testing. """ return range(1925+padding[0], 2283-padding[1]) if stress else (1927, 2000, 2281)
[ "def", "years_range", "(", "stress", "=", "False", ",", "padding", "=", "(", "0", ",", "0", ")", ")", ":", "return", "range", "(", "1925", "+", "padding", "[", "0", "]", ",", "2283", "-", "padding", "[", "1", "]", ")", "if", "stress", "else", "...
[ 15, 0 ]
[ 18, 84 ]
python
en
['en', 'en', 'en']
True
timezones_range
(stress=False)
Returns a set of timezone values used for testing.
Returns a set of timezone values used for testing.
def timezones_range(stress=False): """Returns a set of timezone values used for testing. """ if stress: return pytz.all_timezones else: return ['UTC', 'Asia/Novosibirsk', 'America/Denver']
[ "def", "timezones_range", "(", "stress", "=", "False", ")", ":", "if", "stress", ":", "return", "pytz", ".", "all_timezones", "else", ":", "return", "[", "'UTC'", ",", "'Asia/Novosibirsk'", ",", "'America/Denver'", "]" ]
[ 21, 0 ]
[ 27, 60 ]
python
en
['en', 'en', 'en']
True
insert_check_datetime
(self, datetime, expected, precision=0, timezone="UTC")
Check how a particular datetime value works with different functions that accept DateTime64 data type. :param datetime: datetime string :param expected: expected result :param precision: time precision, default: 0 :param timezone: timezone, default: UTC
Check how a particular datetime value works with different functions that accept DateTime64 data type.
def insert_check_datetime(self, datetime, expected, precision=0, timezone="UTC"): """Check how a particular datetime value works with different functions that accept DateTime64 data type. :param datetime: datetime string :param expected: expected result :param precision: time precision, default: 0 ...
[ "def", "insert_check_datetime", "(", "self", ",", "datetime", ",", "expected", ",", "precision", "=", "0", ",", "timezone", "=", "\"UTC\"", ")", ":", "with", "create_table", "(", "timezone", ",", "self", ".", "context", ".", "node", ")", ":", "with", "Wh...
[ 40, 0 ]
[ 54, 44 ]
python
en
['en', 'en', 'en']
True
datetime_generator
(year, microseconds=False)
Helper generator
Helper generator
def datetime_generator(year, microseconds=False): """Helper generator """ date = datetime.datetime(year, 1, 1, 0, 0, 0) if microseconds: date = datetime.datetime(year, 1, 1, 0, 0, 0, 123000) while not (date.month == 12 and date.day == 31): yield date date = date + datetime.ti...
[ "def", "datetime_generator", "(", "year", ",", "microseconds", "=", "False", ")", ":", "date", "=", "datetime", ".", "datetime", "(", "year", ",", "1", ",", "1", ",", "0", ",", "0", ",", "0", ")", "if", "microseconds", ":", "date", "=", "datetime", ...
[ 57, 0 ]
[ 65, 79 ]
python
de
['de', 'ku', 'en']
False
select_dates_in_year
(year, stress=False, microseconds=False)
Returns various datetimes in a year that are to be checked
Returns various datetimes in a year that are to be checked
def select_dates_in_year(year, stress=False, microseconds=False): """Returns various datetimes in a year that are to be checked """ if not stress: dates = [datetime.datetime(year, 1, 1, 0, 0, 0), datetime.datetime(year, 12, 31, 23, 59, 59)] if microseconds: dates = [datetime.date...
[ "def", "select_dates_in_year", "(", "year", ",", "stress", "=", "False", ",", "microseconds", "=", "False", ")", ":", "if", "not", "stress", ":", "dates", "=", "[", "datetime", ".", "datetime", "(", "year", ",", "1", ",", "1", ",", "0", ",", "0", "...
[ 68, 0 ]
[ 79, 39 ]
python
en
['en', 'en', 'en']
True
select_check_datetime
(self, datetime, expected, precision=0, timezone="UTC")
Check how a particular datetime value works with different functions that accept DateTime64 data type. :param datetime: datetime string :param expected: expected result :param precision: time precision, default: 0 :param timezone: timezone, default: UTC
Check how a particular datetime value works with different functions that accept DateTime64 data type.
def select_check_datetime(self, datetime, expected, precision=0, timezone="UTC"): """Check how a particular datetime value works with different functions that accept DateTime64 data type. :param datetime: datetime string :param expected: expected result :param precision: time precision, default: 0 ...
[ "def", "select_check_datetime", "(", "self", ",", "datetime", ",", "expected", ",", "precision", "=", "0", ",", "timezone", "=", "\"UTC\"", ")", ":", "with", "When", "(", "\"I use toDateTime64\"", ")", ":", "r", "=", "self", ".", "context", ".", "node", ...
[ 83, 0 ]
[ 96, 44 ]
python
en
['en', 'en', 'en']
True
exec_query
(self, request, expected=None, exitcode=None)
Execute a query and check expected result. :param request: query string :param expected: result string :param exitcode: exitcode
Execute a query and check expected result. :param request: query string :param expected: result string :param exitcode: exitcode
def exec_query(self, request, expected=None, exitcode=None): """Execute a query and check expected result. :param request: query string :param expected: result string :param exitcode: exitcode """ r = self.context.node.query(request) if expected is not None: with Then(f"output shoul...
[ "def", "exec_query", "(", "self", ",", "request", ",", "expected", "=", "None", ",", "exitcode", "=", "None", ")", ":", "r", "=", "self", ".", "context", ".", "node", ".", "query", "(", "request", ")", "if", "expected", "is", "not", "None", ":", "w...
[ 100, 0 ]
[ 114, 50 ]
python
en
['en', 'en', 'en']
True
walk_datetime_in_incrementing_steps
(self, date, hrs_range=(0, 24), step=1, timezone="UTC", precision=0)
Sweep time starting from some start date. The time is incremented in steps specified by the `step` parameter (default: 1 min). :param hrs_range: range in hours :param step: step in minutes
Sweep time starting from some start date. The time is incremented in steps specified by the `step` parameter (default: 1 min).
def walk_datetime_in_incrementing_steps(self, date, hrs_range=(0, 24), step=1, timezone="UTC", precision=0): """Sweep time starting from some start date. The time is incremented in steps specified by the `step` parameter (default: 1 min). :param hrs_range: range in hours :param step: step in minute...
[ "def", "walk_datetime_in_incrementing_steps", "(", "self", ",", "date", ",", "hrs_range", "=", "(", "0", ",", "24", ")", ",", "step", "=", "1", ",", "timezone", "=", "\"UTC\"", ",", "precision", "=", "0", ")", ":", "stress", "=", "self", ".", "context"...
[ 118, 0 ]
[ 144, 23 ]
python
en
['en', 'en', 'en']
True
walk_datetime_in_decrementing_steps
(self, date, hrs_range=(23, 0), step=1, timezone="UTC", precision=0)
Sweep time starting from some start date. The time is decremented in steps specified by the `step` parameter (default: 1 min). :param date: string :param hrs_range: range in hours :param step: step in minutes :param timezone: String
Sweep time starting from some start date. The time is decremented in steps specified by the `step` parameter (default: 1 min).
def walk_datetime_in_decrementing_steps(self, date, hrs_range=(23, 0), step=1, timezone="UTC", precision=0): """Sweep time starting from some start date. The time is decremented in steps specified by the `step` parameter (default: 1 min). :param date: string :param hrs_range: range in hours :pa...
[ "def", "walk_datetime_in_decrementing_steps", "(", "self", ",", "date", ",", "hrs_range", "=", "(", "23", ",", "0", ")", ",", "step", "=", "1", ",", "timezone", "=", "\"UTC\"", ",", "precision", "=", "0", ")", ":", "stress", "=", "self", ".", "context"...
[ 148, 0 ]
[ 175, 23 ]
python
en
['en', 'en', 'en']
True
test_ttl_alter_delete
(started_cluster, name, engine)
Copyright 2019, Altinity LTD Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distrib...
Copyright 2019, Altinity LTD Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distrib...
def test_ttl_alter_delete(started_cluster, name, engine): """Copyright 2019, Altinity LTD Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless req...
[ "def", "test_ttl_alter_delete", "(", "started_cluster", ",", "name", ",", "engine", ")", ":", "\"\"\"Check compatibility with old TTL delete expressions to make sure\n that:\n * alter modify of column's TTL delete expression works\n * alter to add new columns works\n * alter modify t...
[ 232, 0 ]
[ 287, 43 ]
python
en
['en', 'pl', 'en']
True
Responses.get
(self, request: Request)
Returns all form responses by form ID.
Returns all form responses by form ID.
async def get(self, request: Request) -> JSONResponse: """Returns all form responses by form ID.""" if not await request.state.db.forms.find_one( {"_id": request.path_params["form_id"]} ): return JSONResponse({"error": "not_found"}, 404) cursor = request.state.db...
[ "async", "def", "get", "(", "self", ",", "request", ":", "Request", ")", "->", "JSONResponse", ":", "if", "not", "await", "request", ".", "state", ".", "db", ".", "forms", ".", "find_one", "(", "{", "\"_id\"", ":", "request", ".", "path_params", "[", ...
[ 31, 4 ]
[ 44, 72 ]
python
en
['en', 'en', 'en']
True
Responses.delete
(self, request: Request)
Bulk deletes form responses by IDs.
Bulk deletes form responses by IDs.
async def delete(self, request: Request) -> JSONResponse: """Bulk deletes form responses by IDs.""" if not await request.state.db.forms.find_one( {"_id": request.path_params["form_id"]} ): return JSONResponse({"error": "not_found"}, status_code=404) data = await ...
[ "async", "def", "delete", "(", "self", ",", "request", ":", "Request", ")", "->", "JSONResponse", ":", "if", "not", "await", "request", ".", "state", ".", "db", ".", "forms", ".", "find_one", "(", "{", "\"_id\"", ":", "request", ".", "path_params", "["...
[ 56, 4 ]
[ 103, 45 ]
python
en
['en', 'en', 'en']
True
User.is_authenticated
(self)
Returns True because user is always authenticated at this stage.
Returns True because user is always authenticated at this stage.
def is_authenticated(self) -> bool: """Returns True because user is always authenticated at this stage.""" return True
[ "def", "is_authenticated", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 13, 4 ]
[ 15, 19 ]
python
en
['en', 'en', 'en']
True
User.display_name
(self)
Return username and discriminator as display name.
Return username and discriminator as display name.
def display_name(self) -> str: """Return username and discriminator as display name.""" return f"{self.payload['username']}#{self.payload['discriminator']}"
[ "def", "display_name", "(", "self", ")", "->", "str", ":", "return", "f\"{self.payload['username']}#{self.payload['discriminator']}\"" ]
[ 18, 4 ]
[ 20, 76 ]
python
en
['en', 'ceb', 'en']
True
parse_args
()
define the working dir
define the working dir
def parse_args(): """define the working dir""" parser = argparse.ArgumentParser() parser.add_argument('--path', '-p', default='', help='image path') parser.add_argument('--threshold', '-t', default=cfg.pixel_threshold, ...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--path'", ",", "'-p'", ",", "default", "=", "''", ",", "help", "=", "'image path'", ")", "parser", ".", "add_argument", ...
[ 19, 0 ]
[ 28, 30 ]
python
en
['en', 'de', 'en']
True
search_index_pytorch
(index, x, k, D=None, I=None)
call the search function of an index with pytorch tensor I/O (CPU and GPU supported)
call the search function of an index with pytorch tensor I/O (CPU and GPU supported)
def search_index_pytorch(index, x, k, D=None, I=None): """call the search function of an index with pytorch tensor I/O (CPU and GPU supported)""" assert x.is_contiguous() n, d = x.size() assert d == index.d if D is None: D = torch.empty((n, k), dtype=torch.float32, device=x.device) ...
[ "def", "search_index_pytorch", "(", "index", ",", "x", ",", "k", ",", "D", "=", "None", ",", "I", "=", "None", ")", ":", "assert", "x", ".", "is_contiguous", "(", ")", "n", ",", "d", "=", "x", ".", "size", "(", ")", "assert", "d", "==", "index"...
[ 26, 0 ]
[ 49, 15 ]
python
en
['en', 'en', 'en']
True
main
()
Main function. Parses cmd line args and runs in the specified mode.
Main function. Parses cmd line args and runs in the specified mode.
def main(): """Main function. Parses cmd line args and runs in the specified mode. """ args = get_options() generate_visualisations(args.query_db, args.ref_db, args.distances, args.rank_fit, ...
[ "def", "main", "(", ")", ":", "args", "=", "get_options", "(", ")", "generate_visualisations", "(", "args", ".", "query_db", ",", "args", ".", "ref_db", ",", "args", ".", "distances", ",", "args", ".", "rank_fit", ",", "args", ".", "threads", ",", "arg...
[ 592, 0 ]
[ 628, 40 ]
python
en
['en', 'en', 'en']
True
convert_seconds_to_str
(secs)
r"""Convert seconds into a human-readable string following https://stackoverflow.com/a/26277340/4659293
r"""Convert seconds into a human-readable string
def convert_seconds_to_str(secs): r"""Convert seconds into a human-readable string following https://stackoverflow.com/a/26277340/4659293 """ days = secs // 86400 hours = secs // 3600 % 24 minutes = secs // 60 % 60 seconds = secs % 60 return "%d:%02d:%02d:%.03f" % (days, hours, minutes,...
[ "def", "convert_seconds_to_str", "(", "secs", ")", ":", "days", "=", "secs", "//", "86400", "hours", "=", "secs", "//", "3600", "%", "24", "minutes", "=", "secs", "//", "60", "%", "60", "seconds", "=", "secs", "%", "60", "return", "\"%d:%02d:%02d:%.03f\"...
[ 27, 0 ]
[ 36, 65 ]
python
en
['en', 'en', 'en']
True
setup_image
(image)
r"""setup the image We load in the image, if it's not already done so (converting it to gray-scale in the process), make sure it lies between 0 and 1, and make sure it's a tensor of the correct type and specified device Parameters ---------- image : str or array_like Either the path to...
r"""setup the image
def setup_image(image): r"""setup the image We load in the image, if it's not already done so (converting it to gray-scale in the process), make sure it lies between 0 and 1, and make sure it's a tensor of the correct type and specified device Parameters ---------- image : str or array_lik...
[ "def", "setup_image", "(", "image", ")", ":", "if", "isinstance", "(", "image", ",", "str", ")", ":", "print", "(", "\"Loading in reference image from %s\"", "%", "image", ")", "image", "=", "imageio", ".", "imread", "(", "image", ")", "if", "image", ".", ...
[ 39, 0 ]
[ 84, 16 ]
python
en
['en', 'ceb', 'en']
True
find_figsizes
(model_name, model, image_shape)
Find figure sizes for various outputs, based on model. This gives a best guess, can definitely still be improved. Parameters ---------- model_name : str str defining the model. Must begin with either RGC or V1. image_shape : array_like array_like giving the shape of the image. Heig...
Find figure sizes for various outputs, based on model.
def find_figsizes(model_name, model, image_shape): """Find figure sizes for various outputs, based on model. This gives a best guess, can definitely still be improved. Parameters ---------- model_name : str str defining the model. Must begin with either RGC or V1. image_shape : array_l...
[ "def", "find_figsizes", "(", "model_name", ",", "model", ",", "image_shape", ")", ":", "if", "model_name", ".", "startswith", "(", "'RGC'", ")", ":", "animate_figsize", "=", "(", "(", "3", "+", "(", "image_shape", "[", "-", "1", "]", "/", "image_shape", ...
[ 87, 0 ]
[ 184, 55 ]
python
en
['en', 'en', 'en']
True
setup_model
(model_name, scaling, image, min_ecc, max_ecc, cache_dir, normalize_dict=None)
r"""setup the model We initialize the model, with the specified parameters, and return it with the appropriate figsizes. `model_name` is constructed of several parts, for which you have several chocies: `'{visual_area}{options}_{window_type}'`: - `visual_area`: which visual area we're modeling...
r"""setup the model
def setup_model(model_name, scaling, image, min_ecc, max_ecc, cache_dir, normalize_dict=None): r"""setup the model We initialize the model, with the specified parameters, and return it with the appropriate figsizes. `model_name` is constructed of several parts, for which you have several chocies: ...
[ "def", "setup_model", "(", "model_name", ",", "scaling", ",", "image", ",", "min_ecc", ",", "max_ecc", ",", "cache_dir", ",", "normalize_dict", "=", "None", ")", ":", "if", "'gaussian'", "in", "model_name", ":", "window_type", "=", "'gaussian'", "t_width", "...
[ 187, 0 ]
[ 317, 62 ]
python
en
['en', 'bg', 'en']
True
add_center_to_image
(model, image, reference_image)
r"""Add the reference image center to an image The VentralStream class of models will do nothing to the center of the image (they don't see the fovea), so we add the fovea to the image before synthesis. Parameters ---------- model : plenoptic.simul.VentralStream The model used to creat...
r"""Add the reference image center to an image
def add_center_to_image(model, image, reference_image): r"""Add the reference image center to an image The VentralStream class of models will do nothing to the center of the image (they don't see the fovea), so we add the fovea to the image before synthesis. Parameters ---------- model : p...
[ "def", "add_center_to_image", "(", "model", ",", "image", ",", "reference_image", ")", ":", "model", "(", "image", ")", "rep", "=", "model", ".", "representation", "[", "'mean_luminance'", "]", "dummy_ones", "=", "torch", ".", "ones_like", "(", "rep", ")", ...
[ 320, 0 ]
[ 350, 65 ]
python
en
['en', 'en', 'en']
True
summary_plots
(metamer, rep_image_figsize, img_zoom)
r"""Create summary plots This creates two summary plots: 1. 'rep_image': we show, in three separate rows, the representation of the reference image, the representation of the metamer, and the representation_error at the final iteration, all plotted as images using ``metamer.model.plot_representati...
r"""Create summary plots
def summary_plots(metamer, rep_image_figsize, img_zoom): r"""Create summary plots This creates two summary plots: 1. 'rep_image': we show, in three separate rows, the representation of the reference image, the representation of the metamer, and the representation_error at the final iteration, all ...
[ "def", "summary_plots", "(", "metamer", ",", "rep_image_figsize", ",", "img_zoom", ")", ":", "rep_fig", ",", "axes", "=", "plt", ".", "subplots", "(", "3", ",", "1", ",", "figsize", "=", "rep_image_figsize", ")", "titles", "=", "[", "'Reference image |'", ...
[ 353, 0 ]
[ 406, 32 ]
python
en
['en', 'et', 'en']
True
_transform_summarized_rep
(summarized_rep)
change around the keys of the summarized_representation dictionary This makes them more readable This function makes strong assumptions about what the keys look like (see PooledVentralStreams.summarize_representation for more info on this): a single string or tuples of the form `(a, b)`, `(a, b, c), o...
change around the keys of the summarized_representation dictionary
def _transform_summarized_rep(summarized_rep): """change around the keys of the summarized_representation dictionary This makes them more readable This function makes strong assumptions about what the keys look like (see PooledVentralStreams.summarize_representation for more info on this): a singl...
[ "def", "_transform_summarized_rep", "(", "summarized_rep", ")", ":", "new_summarized_rep", "=", "{", "}", "for", "k", ",", "v", "in", "summarized_rep", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "k", ",", "tuple", ")", ":", "new_summarize...
[ 409, 0 ]
[ 445, 29 ]
python
en
['en', 'en', 'en']
True
summarize_history
(metamer, save_path, **kwargs)
r"""Generate and save summary of synthesis history In addition the `key=value` pairs passed as kwargs, we also save the following on each saved iteration (we sub-sample by a fair amount, so this will be something like every 40 iterations instead of every 1): - iteration: the current iteration ...
r"""Generate and save summary of synthesis history
def summarize_history(metamer, save_path, **kwargs): r"""Generate and save summary of synthesis history In addition the `key=value` pairs passed as kwargs, we also save the following on each saved iteration (we sub-sample by a fair amount, so this will be something like every 40 iterations instead of e...
[ "def", "summarize_history", "(", "metamer", ",", "save_path", ",", "*", "*", "kwargs", ")", ":", "num_saves", "=", "metamer", ".", "saved_signal", ".", "shape", "[", "0", "]", "summary", "=", "[", "]", "keys", "=", "[", "'loss'", ",", "'image_mse'", ",...
[ 448, 0 ]
[ 534, 21 ]
python
en
['en', 'en', 'en']
True
summarize
(metamer, save_path, **kwargs)
Generate and save a summary of performance In addition the `key=value` pairs passed as kwargs, we also save the following: - num_iterations: the number of iterations synthesis ran for, which we grab from the length of the loss (note this means it can be less than the target number of iteration...
Generate and save a summary of performance
def summarize(metamer, save_path, **kwargs): """Generate and save a summary of performance In addition the `key=value` pairs passed as kwargs, we also save the following: - num_iterations: the number of iterations synthesis ran for, which we grab from the length of the loss (note this means it c...
[ "def", "summarize", "(", "metamer", ",", "save_path", ",", "*", "*", "kwargs", ")", ":", "loss", "=", "metamer", ".", "loss", "[", "-", "1", "]", "if", "np", ".", "isnan", "(", "loss", ")", ":", "loss", "=", "metamer", ".", "loss", "[", "-", "2...
[ 537, 0 ]
[ 591, 18 ]
python
en
['en', 'en', 'en']
True
save
(save_path, metamer, animate_figsize, rep_image_figsize, img_zoom, save_all=False)
r"""save the metamer output We save several things here: - The metamer object itself, at ``save_path``. This contains, among other things, the saved image and representation over the course of synthesis. - The finished metamer image in its original float32 format (with values between 0 an...
r"""save the metamer output
def save(save_path, metamer, animate_figsize, rep_image_figsize, img_zoom, save_all=False): r"""save the metamer output We save several things here: - The metamer object itself, at ``save_path``. This contains, among other things, the saved image and representation over the course of s...
[ "def", "save", "(", "save_path", ",", "metamer", ",", "animate_figsize", ",", "rep_image_figsize", ",", "img_zoom", ",", "save_all", "=", "False", ")", ":", "print", "(", "\"Saving at %s\"", "%", "save_path", ")", "# We add the center back at the end because our gradi...
[ 594, 0 ]
[ 702, 34 ]
python
en
['en', 'en', 'en']
True
setup_initial_image
(initial_image_type, model, image)
r"""setup the initial image Parameters ---------- initial_image_type : {'white', 'pink', 'gray', 'blue'} or path to file What to use for the initial image. If 'white', we use white noise. If 'pink', we use pink noise (``pyrtools.synthetic_images.pink_noise(fract_dim=1)``). If ...
r"""setup the initial image
def setup_initial_image(initial_image_type, model, image): r"""setup the initial image Parameters ---------- initial_image_type : {'white', 'pink', 'gray', 'blue'} or path to file What to use for the initial image. If 'white', we use white noise. If 'pink', we use pink noise (``...
[ "def", "setup_initial_image", "(", "initial_image_type", ",", "model", ",", "image", ")", ":", "if", "initial_image_type", "==", "'white'", ":", "initial_image", "=", "torch", ".", "rand_like", "(", "image", ",", "dtype", "=", "torch", ".", "float32", ")", "...
[ 705, 0 ]
[ 758, 44 ]
python
en
['en', 'en', 'en']
True
setup_device
(*args, gpu_id=None)
r"""Setup device and get everything onto it This simple function checks whether ``torch.cuda.is_available()`` and ``gpu_id`` is not None. If not, we use the cpu as the device We then call a.to(device) for every a in args (so this can be called with an arbitrary number of objects, each of which just ne...
r"""Setup device and get everything onto it
def setup_device(*args, gpu_id=None): r"""Setup device and get everything onto it This simple function checks whether ``torch.cuda.is_available()`` and ``gpu_id`` is not None. If not, we use the cpu as the device We then call a.to(device) for every a in args (so this can be called with an arbitrar...
[ "def", "setup_device", "(", "*", "args", ",", "gpu_id", "=", "None", ")", ":", "if", "gpu_id", "is", "not", "None", ":", "if", "not", "torch", ".", "cuda", ".", "is_available", "(", ")", ":", "raise", "Exception", "(", "\"CUDA is not available but gpu_id i...
[ 761, 0 ]
[ 811, 39 ]
python
en
['en', 'en', 'en']
True
main
(model_name, scaling, image, seed=0, min_ecc=.5, max_ecc=15, learning_rate=1, max_iter=100, loss_thresh=1e-4, loss_change_iter=50, save_path=None, initial_image_type='white', gpu_id=None, cache_dir=None, normalize_dict=None, optimizer='SGD', fraction_removed=0, loss_change_fraction=1, loss_ch...
r"""create metamers! Given a model_name, model parameters, a target image, and some optimization parameters, we do our best to synthesize a metamer, saving the outputs after it finishes. `model_name` is constructed of several parts, for which you have several chocies: `'{visual_area}{options}_...
r"""create metamers!
def main(model_name, scaling, image, seed=0, min_ecc=.5, max_ecc=15, learning_rate=1, max_iter=100, loss_thresh=1e-4, loss_change_iter=50, save_path=None, initial_image_type='white', gpu_id=None, cache_dir=None, normalize_dict=None, optimizer='SGD', fraction_removed=0, loss_change_fraction=1,...
[ "def", "main", "(", "model_name", ",", "scaling", ",", "image", ",", "seed", "=", "0", ",", "min_ecc", "=", ".5", ",", "max_ecc", "=", "15", ",", "learning_rate", "=", "1", ",", "max_iter", "=", "100", ",", "loss_thresh", "=", "1e-4", ",", "loss_chan...
[ 814, 0 ]
[ 1154, 34 ]
python
af
['en', 'af', 'hi']
False
privileges_granted_directly
(self, node=None)
Check that a user is able to grant role with `ADMIN OPTION` privilege granted directly.
Check that a user is able to grant role with `ADMIN OPTION` privilege granted directly.
def privileges_granted_directly(self, node=None): """Check that a user is able to grant role with `ADMIN OPTION` privilege granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(test=grant_role)(grant_...
[ "def", "privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "f\"{user_...
[ 8, 0 ]
[ 19, 80 ]
python
en
['en', 'en', 'en']
True
privileges_granted_via_role
(self, node=None)
Check that a user is able to grant role with `ADMIN OPTION` privilege granted through a role.
Check that a user is able to grant role with `ADMIN OPTION` privilege granted through a role.
def privileges_granted_via_role(self, node=None): """Check that a user is able to grant role with `ADMIN OPTION` privilege granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"...
[ "def", "privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with"...
[ 22, 0 ]
[ 37, 80 ]
python
en
['en', 'en', 'en']
True
grant_role
(self, grant_target_name, user_name, node=None)
Check that user is able to execute to grant roles if and only if they have role with `ADMIN OPTION`.
Check that user is able to execute to grant roles if and only if they have role with `ADMIN OPTION`.
def grant_role(self, grant_target_name, user_name, node=None): """Check that user is able to execute to grant roles if and only if they have role with `ADMIN OPTION`. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node with Scenari...
[ "def", "grant_role", "(", "self", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node", "is", "None", ":", ...
[ 40, 0 ]
[ 111, 55 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of ADMIN OPTION.
Check the RBAC functionality of ADMIN OPTION.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of ADMIN OPTION. """ self.context.node = self.context.cluster.node(node) Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=privileges_granted_via_role, setup=instrument_clickhouse_server_lo...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "privileges_granted_directly", ",", ...
[ 119, 0 ]
[ 125, 82 ]
python
en
['en', 'en', 'en']
True
verify_ldap_user_exists
(server, username, password)
Check that LDAP user is defined on the LDAP server.
Check that LDAP user is defined on the LDAP server.
def verify_ldap_user_exists(server, username, password): """Check that LDAP user is defined on the LDAP server. """ with By("searching LDAP database"): ldap_node = current().context.cluster.node(server) r = ldap_node.command( f"ldapwhoami -H ldap://localhost -D 'cn={user_name},ou...
[ "def", "verify_ldap_user_exists", "(", "server", ",", "username", ",", "password", ")", ":", "with", "By", "(", "\"searching LDAP database\"", ")", ":", "ldap_node", "=", "current", "(", ")", ".", "context", ".", "cluster", ".", "node", "(", "server", ")", ...
[ 58, 0 ]
[ 65, 39 ]
python
en
['en', 'en', 'en']
True
create_ldap_external_user_directory_config_content
(server=None, roles=None, **kwargs)
Create LDAP external user directory configuration file content.
Create LDAP external user directory configuration file content.
def create_ldap_external_user_directory_config_content(server=None, roles=None, **kwargs): """Create LDAP external user directory configuration file content. """ return create_entries_ldap_external_user_directory_config_content(entries=[([server], [roles])], **kwargs)
[ "def", "create_ldap_external_user_directory_config_content", "(", "server", "=", "None", ",", "roles", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "create_entries_ldap_external_user_directory_config_content", "(", "entries", "=", "[", "(", "[", "server",...
[ 67, 0 ]
[ 70, 110 ]
python
en
['en', 'lb', 'en']
True
create_entries_ldap_external_user_directory_config_content
(entries, config_d_dir="/etc/clickhouse-server/config.d", config_file="ldap_external_user_directories.xml")
Create configurattion file content that contains one or more entries for the LDAP external user directory. For example, ```xml <user_directories> <ldap> <server>my_ldap_server</server> <roles> <my_local_role1 /> <m...
Create configurattion file content that contains one or more entries for the LDAP external user directory.
def create_entries_ldap_external_user_directory_config_content(entries, config_d_dir="/etc/clickhouse-server/config.d", config_file="ldap_external_user_directories.xml"): """Create configurattion file content that contains one or more entries for the LDAP external user directory. For example, ...
[ "def", "create_entries_ldap_external_user_directory_config_content", "(", "entries", ",", "config_d_dir", "=", "\"/etc/clickhouse-server/config.d\"", ",", "config_file", "=", "\"ldap_external_user_directories.xml\"", ")", ":", "uid", "=", "getuid", "(", ")", "path", "=", "o...
[ 72, 0 ]
[ 118, 57 ]
python
en
['en', 'en', 'en']
True
invalid_ldap_external_user_directory_config
(server, roles, message, tail=30, timeout=60, config=None)
Check that ClickHouse errors when trying to load invalid LDAP external user directory configuration file.
Check that ClickHouse errors when trying to load invalid LDAP external user directory configuration file.
def invalid_ldap_external_user_directory_config(server, roles, message, tail=30, timeout=60, config=None): """Check that ClickHouse errors when trying to load invalid LDAP external user directory configuration file. """ cluster = current().context.cluster node = current().context.node if config...
[ "def", "invalid_ldap_external_user_directory_config", "(", "server", ",", "roles", ",", "message", ",", "tail", "=", "30", ",", "timeout", "=", "60", ",", "config", "=", "None", ")", ":", "cluster", "=", "current", "(", ")", ".", "context", ".", "cluster",...
[ 120, 0 ]
[ 168, 37 ]
python
en
['en', 'en', 'en']
True
ldap_external_user_directory
(server, roles, config_d_dir="/etc/clickhouse-server/config.d", config_file=None, timeout=60, restart=True, config=None)
Add LDAP external user directory.
Add LDAP external user directory.
def ldap_external_user_directory(server, roles, config_d_dir="/etc/clickhouse-server/config.d", config_file=None, timeout=60, restart=True, config=None): """Add LDAP external user directory. """ if config_file is None: config_file = f"ldap_external_user_directory_{getuid()}.xml" if confi...
[ "def", "ldap_external_user_directory", "(", "server", ",", "roles", ",", "config_d_dir", "=", "\"/etc/clickhouse-server/config.d\"", ",", "config_file", "=", "None", ",", "timeout", "=", "60", ",", "restart", "=", "True", ",", "config", "=", "None", ")", ":", ...
[ 171, 0 ]
[ 179, 46 ]
python
da
['da', 'lb', 'en']
False
login
(servers, directory_server, *users, config=None)
Configure LDAP server and LDAP external user directory and try to login and execute a query
Configure LDAP server and LDAP external user directory and try to login and execute a query
def login(servers, directory_server, *users, config=None): """Configure LDAP server and LDAP external user directory and try to login and execute a query""" with ldap_servers(servers): with rbac_roles(f"role_{getuid()}") as roles: with ldap_external_user_directory(server=servers[director...
[ "def", "login", "(", "servers", ",", "directory_server", ",", "*", "users", ",", "config", "=", "None", ")", ":", "with", "ldap_servers", "(", "servers", ")", ":", "with", "rbac_roles", "(", "f\"role_{getuid()}\"", ")", "as", "roles", ":", "with", "ldap_ex...
[ 181, 0 ]
[ 193, 66 ]
python
en
['en', 'su', 'en']
True
decrypt
(self)
Check decrypting column when reading data from a table.
Check decrypting column when reading data from a table.
def decrypt(self): """Check decrypting column when reading data from a table. """ node = self.context.node key = f"{'1' * 64}" iv = f"{'2' * 64}" aad = "some random aad" for mode, key_len, iv_len, aad_len in modes: with Example(f"""mode={mode.strip("'")} key={key_len} iv={iv_len} aa...
[ "def", "decrypt", "(", "self", ")", ":", "node", "=", "self", ".", "context", ".", "node", "key", "=", "f\"{'1' * 64}\"", "iv", "=", "f\"{'2' * 64}\"", "aad", "=", "\"some random aad\"", "for", "mode", ",", "key_len", ",", "iv_len", ",", "aad_len", "in", ...
[ 25, 0 ]
[ 63, 82 ]
python
en
['en', 'en', 'en']
True
decrypt_multiple
(self, count=1000)
Check decrypting column when reading multiple entries encrypted with the same parameters for the same user from a table.
Check decrypting column when reading multiple entries encrypted with the same parameters for the same user from a table.
def decrypt_multiple(self, count=1000): """Check decrypting column when reading multiple entries encrypted with the same parameters for the same user from a table. """ node = self.context.node key = f"{'1' * 64}" iv = f"{'2' * 64}" aad = "some random aad" for mode, key_len, iv_len, ...
[ "def", "decrypt_multiple", "(", "self", ",", "count", "=", "1000", ")", ":", "node", "=", "self", ".", "context", ".", "node", "key", "=", "f\"{'1' * 64}\"", "iv", "=", "f\"{'2' * 64}\"", "aad", "=", "\"some random aad\"", "for", "mode", ",", "key_len", ",...
[ 66, 0 ]
[ 105, 70 ]
python
en
['en', 'en', 'en']
True
decrypt_unique
(self)
Check decrypting column when reading multiple entries encrypted with the different parameters for each user from a table.
Check decrypting column when reading multiple entries encrypted with the different parameters for each user from a table.
def decrypt_unique(self): """Check decrypting column when reading multiple entries encrypted with the different parameters for each user from a table. """ node = self.context.node key = f"{'1' * 64}" iv = f"{'2' * 64}" aad = "some random aad" with table("user_table", """ ...
[ "def", "decrypt_unique", "(", "self", ")", ":", "node", "=", "self", ".", "context", ".", "node", "key", "=", "f\"{'1' * 64}\"", "iv", "=", "f\"{'2' * 64}\"", "aad", "=", "\"some random aad\"", "with", "table", "(", "\"user_table\"", ",", "\"\"\"\n CR...
[ 108, 0 ]
[ 175, 62 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check encryption functions when used during table querying.
Check encryption functions when used during table querying.
def feature(self, node="clickhouse1"): """Check encryption functions when used during table querying. """ self.context.node = self.context.cluster.node(node) for scenario in loads(current_module(), Scenario): Scenario(run=scenario, flags=TE)
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "for", "scenario", "in", "loads", "(", "current_module", "(",...
[ 179, 0 ]
[ 185, 40 ]
python
en
['en', 'en', 'en']
True
set_env
(**environ)
Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u'test/plugins'): ... "PLUGINS_DIR" in os.environ True >>> "PLUGINS_DIR" in os.environ False
Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u'test/plugins'): ... "PLUGINS_DIR" in os.environ True >>> "PLUGINS_DIR" in os.environ False
def set_env(**environ): """ Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u'test/plugins'): ... "PLUGINS_DIR" in os.environ True >>> "PLUGINS_DIR" in os.environ False """ old_environ = dict(os.environ) os.environ.update(environ) try: ...
[ "def", "set_env", "(", "*", "*", "environ", ")", ":", "old_environ", "=", "dict", "(", "os", ".", "environ", ")", "os", ".", "environ", ".", "update", "(", "environ", ")", "try", ":", "yield", "finally", ":", "os", ".", "environ", ".", "clear", "("...
[ 43, 0 ]
[ 58, 38 ]
python
en
['en', 'error', 'th']
False
setupDBFuncs
(args, min_count, qc_dict)
Wraps common database access functions from sketchlib and mash, to try and make their API more similar Args: args (argparse.opts) Parsed command lines options min_count (int) Minimum k-mer count for reads qc_dict (dict) Table of parameters for QC func...
Wraps common database access functions from sketchlib and mash, to try and make their API more similar
def setupDBFuncs(args, min_count, qc_dict): """Wraps common database access functions from sketchlib and mash, to try and make their API more similar Args: args (argparse.opts) Parsed command lines options min_count (int) Minimum k-mer count for reads qc_dict...
[ "def", "setupDBFuncs", "(", "args", ",", "min_count", ",", "qc_dict", ")", ":", "from", ".", "sketchlib", "import", "checkSketchlibVersion", "from", ".", "sketchlib", "import", "createDatabaseDir", "from", ".", "sketchlib", "import", "joinDBs", "from", ".", "ske...
[ 62, 0 ]
[ 111, 18 ]
python
en
['en', 'en', 'en']
True
storePickle
(rlist, qlist, self, X, pklName)
Saves core and accessory distances in a .npy file, names in a .pkl Called during ``--create-db`` Args: rlist (list) List of reference sequence names (for :func:`~iterDistRows`) qlist (list) List of query sequence names (for :func:`~iterDistRows`) self (bool) ...
Saves core and accessory distances in a .npy file, names in a .pkl
def storePickle(rlist, qlist, self, X, pklName): """Saves core and accessory distances in a .npy file, names in a .pkl Called during ``--create-db`` Args: rlist (list) List of reference sequence names (for :func:`~iterDistRows`) qlist (list) List of query sequence n...
[ "def", "storePickle", "(", "rlist", ",", "qlist", ",", "self", ",", "X", ",", "pklName", ")", ":", "with", "open", "(", "pklName", "+", "\".pkl\"", ",", "'wb'", ")", "as", "pickle_file", ":", "pickle", ".", "dump", "(", "[", "rlist", ",", "qlist", ...
[ 113, 0 ]
[ 132, 32 ]
python
en
['en', 'en', 'en']
True
readPickle
(pklName, enforce_self=False, distances=True)
Loads core and accessory distances saved by :func:`~storePickle` Called during ``--fit-model`` Args: pklName (str) Prefix for saved files enforce_self (bool) Error if self == False [default = True] distances (bool) Read the distance matr...
Loads core and accessory distances saved by :func:`~storePickle`
def readPickle(pklName, enforce_self=False, distances=True): """Loads core and accessory distances saved by :func:`~storePickle` Called during ``--fit-model`` Args: pklName (str) Prefix for saved files enforce_self (bool) Error if self == False [default...
[ "def", "readPickle", "(", "pklName", ",", "enforce_self", "=", "False", ",", "distances", "=", "True", ")", ":", "with", "open", "(", "pklName", "+", "\".pkl\"", ",", "'rb'", ")", "as", "pickle_file", ":", "rlist", ",", "qlist", ",", "self", "=", "pick...
[ 135, 0 ]
[ 171, 32 ]
python
en
['en', 'en', 'en']
True
iterDistRows
(refSeqs, querySeqs, self=True)
Gets the ref and query ID for each row of the distance matrix Returns an iterable with ref and query ID pairs by row. Args: refSeqs (list) List of reference sequence names. querySeqs (list) List of query sequence names. self (bool) Whether a self-com...
Gets the ref and query ID for each row of the distance matrix
def iterDistRows(refSeqs, querySeqs, self=True): """Gets the ref and query ID for each row of the distance matrix Returns an iterable with ref and query ID pairs by row. Args: refSeqs (list) List of reference sequence names. querySeqs (list) List of query sequence n...
[ "def", "iterDistRows", "(", "refSeqs", ",", "querySeqs", ",", "self", "=", "True", ")", ":", "if", "self", ":", "if", "refSeqs", "!=", "querySeqs", ":", "raise", "RuntimeError", "(", "'refSeqs must equal querySeqs for db building (self = true)'", ")", "for", "i", ...
[ 174, 0 ]
[ 201, 33 ]
python
en
['en', 'en', 'en']
True
listDistInts
(refSeqs, querySeqs, self=True)
Gets the ref and query ID for each row of the distance matrix Returns an iterable with ref and query ID pairs by row. Args: refSeqs (list) List of reference sequence names. querySeqs (list) List of query sequence names. self (bool) Whether a self-com...
Gets the ref and query ID for each row of the distance matrix
def listDistInts(refSeqs, querySeqs, self=True): """Gets the ref and query ID for each row of the distance matrix Returns an iterable with ref and query ID pairs by row. Args: refSeqs (list) List of reference sequence names. querySeqs (list) List of query sequence n...
[ "def", "listDistInts", "(", "refSeqs", ",", "querySeqs", ",", "self", "=", "True", ")", ":", "num_ref", "=", "len", "(", "refSeqs", ")", "num_query", "=", "len", "(", "querySeqs", ")", "if", "self", ":", "if", "refSeqs", "!=", "querySeqs", ":", "raise"...
[ 204, 0 ]
[ 236, 26 ]
python
en
['en', 'en', 'en']
True
qcDistMat
(distMat, refList, queryList, ref_db, prefix, qc_dict)
Checks distance matrix for outliers. Args: distMat (np.array) Core and accessory distances refList (list) Reference labels queryList (list) Query labels (or refList if self) ref_db (str) Prefix of reference database prefix (str...
Checks distance matrix for outliers.
def qcDistMat(distMat, refList, queryList, ref_db, prefix, qc_dict): """Checks distance matrix for outliers. Args: distMat (np.array) Core and accessory distances refList (list) Reference labels queryList (list) Query labels (or refList if self) ...
[ "def", "qcDistMat", "(", "distMat", ",", "refList", ",", "queryList", ",", "ref_db", ",", "prefix", ",", "qc_dict", ")", ":", "# avoid circular import", "from", ".", "prune_db", "import", "prune_distance_matrix", "from", ".", "sketchlib", "import", "removeFromDB",...
[ 239, 0 ]
[ 335, 37 ]
python
en
['en', 'en', 'en']
True
readIsolateTypeFromCsv
(clustCSV, mode = 'clusters', return_dict = False)
Read cluster definitions from CSV file. Args: clustCSV (str) File name of CSV with isolate assignments return_type (str) If True, return a dict with sample->cluster instead of sets Returns: clusters (dict) Dictionary of cluster assignment...
Read cluster definitions from CSV file.
def readIsolateTypeFromCsv(clustCSV, mode = 'clusters', return_dict = False): """Read cluster definitions from CSV file. Args: clustCSV (str) File name of CSV with isolate assignments return_type (str) If True, return a dict with sample->cluster instead of se...
[ "def", "readIsolateTypeFromCsv", "(", "clustCSV", ",", "mode", "=", "'clusters'", ",", "return_dict", "=", "False", ")", ":", "# data structures", "if", "return_dict", ":", "clusters", "=", "defaultdict", "(", "dict", ")", "else", ":", "clusters", "=", "{", ...
[ 338, 0 ]
[ 390, 19 ]
python
en
['en', 'en', 'en']
True
joinClusterDicts
(d1, d2)
Join two dictionaries returned by :func:`~readIsolateTypeFromCsv` with return_dict = True. Useful for concatenating ref and query assignments Args: d1 (dict of dicts) First dictionary to concat d2 (dict of dicts) Second dictionary to concat Returns: d1 (dict...
Join two dictionaries returned by :func:`~readIsolateTypeFromCsv` with return_dict = True. Useful for concatenating ref and query assignments
def joinClusterDicts(d1, d2): """Join two dictionaries returned by :func:`~readIsolateTypeFromCsv` with return_dict = True. Useful for concatenating ref and query assignments Args: d1 (dict of dicts) First dictionary to concat d2 (dict of dicts) Second dictionary to ...
[ "def", "joinClusterDicts", "(", "d1", ",", "d2", ")", ":", "if", "d1", ".", "keys", "(", ")", "!=", "d2", ".", "keys", "(", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"Cluster columns not compatible\\n\"", ")", "sys", ".", "exit", "(", "1",...
[ 393, 0 ]
[ 416, 13 ]
python
en
['en', 'en', 'en']
True
update_distance_matrices
(refList, distMat, queryList = None, query_ref_distMat = None, query_query_distMat = None, threads = 1)
Convert distances from long form (1 matrix with n_comparisons rows and 2 columns) to a square form (2 NxN matrices), with merging of query distances if necessary. Args: refList (list) List of references distMat (numpy.array) Two column long form list of core and accessor...
Convert distances from long form (1 matrix with n_comparisons rows and 2 columns) to a square form (2 NxN matrices), with merging of query distances if necessary.
def update_distance_matrices(refList, distMat, queryList = None, query_ref_distMat = None, query_query_distMat = None, threads = 1): """Convert distances from long form (1 matrix with n_comparisons rows and 2 columns) to a square form (2 NxN matrices), with merging of query distance...
[ "def", "update_distance_matrices", "(", "refList", ",", "distMat", ",", "queryList", "=", "None", ",", "query_ref_distMat", "=", "None", ",", "query_query_distMat", "=", "None", ",", "threads", "=", "1", ")", ":", "seqLabels", "=", "refList", "if", "queryList"...
[ 419, 0 ]
[ 468, 37 ]
python
en
['en', 'en', 'en']
True
readRfile
(rFile, oneSeq=False)
Reads in files for sketching. Names and sequence, tab separated Args: rFile (str) File with locations of assembly files to be sketched oneSeq (bool) Return only the first sequence listed, rather than a list (used with mash) Returns: names (list) ...
Reads in files for sketching. Names and sequence, tab separated
def readRfile(rFile, oneSeq=False): """Reads in files for sketching. Names and sequence, tab separated Args: rFile (str) File with locations of assembly files to be sketched oneSeq (bool) Return only the first sequence listed, rather than a list (used with ma...
[ "def", "readRfile", "(", "rFile", ",", "oneSeq", "=", "False", ")", ":", "names", "=", "[", "]", "sequences", "=", "[", "]", "with", "open", "(", "rFile", ",", "'rU'", ")", "as", "refFile", ":", "for", "refLine", "in", "refFile", ":", "rFields", "=...
[ 470, 0 ]
[ 531, 29 ]
python
en
['en', 'en', 'en']
True
isolateNameToLabel
(names)
Function to process isolate names to labels appropriate for visualisation. Args: names (list) List of isolate names. Returns: labels (list) List of isolate labels.
Function to process isolate names to labels appropriate for visualisation.
def isolateNameToLabel(names): """Function to process isolate names to labels appropriate for visualisation. Args: names (list) List of isolate names. Returns: labels (list) List of isolate labels. """ # useful to have as a function in case we # want ...
[ "def", "isolateNameToLabel", "(", "names", ")", ":", "# useful to have as a function in case we", "# want to remove certain characters", "labels", "=", "[", "name", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", ".", "replace", "(", "'.'", ",", "'_'", ")", ...
[ 533, 0 ]
[ 548, 17 ]
python
en
['en', 'en', 'en']
True
transformLine
(s, mean0, mean1)
Return x and y co-ordinates for traversing along a line between mean0 and mean1, parameterised by a single scalar distance s from the start point mean0. Args: s (float) Distance along line from mean0 mean0 (numpy.array) Start position of line (x0, y0) mean1 (nump...
Return x and y co-ordinates for traversing along a line between mean0 and mean1, parameterised by a single scalar distance s from the start point mean0.
def transformLine(s, mean0, mean1): """Return x and y co-ordinates for traversing along a line between mean0 and mean1, parameterised by a single scalar distance s from the start point mean0. Args: s (float) Distance along line from mean0 mean0 (numpy.array) Start po...
[ "def", "transformLine", "(", "s", ",", "mean0", ",", "mean1", ")", ":", "dx", "=", "mean1", "[", "0", "]", "-", "mean0", "[", "0", "]", "dy", "=", "mean1", "[", "1", "]", "-", "mean0", "[", "1", "]", "ds", "=", "np", ".", "sqrt", "(", "dx",...
[ 569, 0 ]
[ 592, 27 ]
python
en
['en', 'en', 'en']
True
decisionBoundary
(intercept, gradient)
Returns the co-ordinates where the triangle the decision boundary forms meets the x- and y-axes. Args: intercept (numpy.array) Cartesian co-ordinates of point along line (:func:`~transformLine`) which intercepts the boundary gradient (float) Gradient of the l...
Returns the co-ordinates where the triangle the decision boundary forms meets the x- and y-axes.
def decisionBoundary(intercept, gradient): """Returns the co-ordinates where the triangle the decision boundary forms meets the x- and y-axes. Args: intercept (numpy.array) Cartesian co-ordinates of point along line (:func:`~transformLine`) which intercepts the boundary ...
[ "def", "decisionBoundary", "(", "intercept", ",", "gradient", ")", ":", "x", "=", "intercept", "[", "0", "]", "+", "intercept", "[", "1", "]", "*", "gradient", "y", "=", "intercept", "[", "1", "]", "+", "intercept", "[", "0", "]", "/", "gradient", ...
[ 595, 0 ]
[ 613, 16 ]
python
en
['en', 'en', 'en']
True
check_and_set_gpu
(use_gpu, gpu_lib, quit_on_fail = False)
Check GPU libraries can be loaded and set managed memory. Args: use_gpu (bool) Whether GPU packages have been requested gpu_lib (bool) Whether GPU packages are available Returns: use_gpu (bool) Whether GPU packages can be used
Check GPU libraries can be loaded and set managed memory.
def check_and_set_gpu(use_gpu, gpu_lib, quit_on_fail = False): """Check GPU libraries can be loaded and set managed memory. Args: use_gpu (bool) Whether GPU packages have been requested gpu_lib (bool) Whether GPU packages are available Returns: use_gpu (bool)...
[ "def", "check_and_set_gpu", "(", "use_gpu", ",", "gpu_lib", ",", "quit_on_fail", "=", "False", ")", ":", "# load CUDA libraries", "if", "use_gpu", "and", "not", "gpu_lib", ":", "if", "quit_on_fail", ":", "sys", ".", "stderr", ".", "write", "(", "'Unable to loa...
[ 615, 0 ]
[ 647, 18 ]
python
en
['en', 'en', 'en']
True
read_rlist_from_distance_pickle
(fn, allow_non_self = True)
Return the list of reference sequences from a distance pickle. Args: fn (str) Name of distance pickle allow_non_self (bool) Whether non-self distance datasets are permissible Returns: rlist (list) List of reference sequence names
Return the list of reference sequences from a distance pickle.
def read_rlist_from_distance_pickle(fn, allow_non_self = True): """Return the list of reference sequences from a distance pickle. Args: fn (str) Name of distance pickle allow_non_self (bool) Whether non-self distance datasets are permissible Returns: rlist (l...
[ "def", "read_rlist_from_distance_pickle", "(", "fn", ",", "allow_non_self", "=", "True", ")", ":", "with", "open", "(", "fn", ",", "'rb'", ")", "as", "pickle_file", ":", "rlist", ",", "qlist", ",", "self", "=", "pickle", ".", "load", "(", "pickle_file", ...
[ 649, 0 ]
[ 667, 16 ]
python
en
['en', 'en', 'en']
True
_plot_true_params
(ax, proportionality_factor, critical_scaling)
r"""Plot the true parameters on the parameter plot. We plot the real values as a black square and update the legend so it includes that square. This only makes sense for simulation, since otherwise we don't know what the true values are. Parameters ---------- ax : axis The axis contain...
r"""Plot the true parameters on the parameter plot.
def _plot_true_params(ax, proportionality_factor, critical_scaling): r"""Plot the true parameters on the parameter plot. We plot the real values as a black square and update the legend so it includes that square. This only makes sense for simulation, since otherwise we don't know what the true values a...
[ "def", "_plot_true_params", "(", "ax", ",", "proportionality_factor", ",", "critical_scaling", ")", ":", "ax", ".", "scatter", "(", "critical_scaling", ",", "proportionality_factor", ",", "marker", "=", "'s'", ",", "label", "=", "'true value'", ",", "color", "="...
[ 9, 0 ]
[ 32, 13 ]
python
en
['en', 'en', 'en']
True
test_optimization
(proportionality_factor=5, critical_scaling=.2, scaling=torch.logspace(-1, -.3, steps=9), n_opt=10, use_multiproc=True, n_processes=None, lr=.001, scheduler=True, max_iter=10000)
r"""Test whether fit_psychophysical_parameters works. This simulates data with the specified parameters (for the given scaling values) and runs ``curve_fit.fit_psychophysical_parameters`` ``n_opt`` times to see how good our optimization procedure is. It looks like, should run optimization multiple tim...
r"""Test whether fit_psychophysical_parameters works.
def test_optimization(proportionality_factor=5, critical_scaling=.2, scaling=torch.logspace(-1, -.3, steps=9), n_opt=10, use_multiproc=True, n_processes=None, lr=.001, scheduler=True, max_iter=10000): r"""Test whether fit_psychophysical_parameters wo...
[ "def", "test_optimization", "(", "proportionality_factor", "=", "5", ",", "critical_scaling", "=", ".2", ",", "scaling", "=", "torch", ".", "logspace", "(", "-", "1", ",", "-", ".3", ",", "steps", "=", "9", ")", ",", "n_opt", "=", "10", ",", "use_multi...
[ 35, 0 ]
[ 127, 29 ]
python
en
['en', 'en', 'en']
True
test_num_trials
(num_trials, num_bootstraps, proportionality_factor=5, critical_scaling=.2, scaling=torch.logspace(-1, -.3, steps=9), use_multiproc=True, n_processes=None, lr=.001, scheduler=True, max_iter=10000)
r"""Test how many trials we need to be confident in our parameter estimates. We generate the true proportion correct at each scaling value for the specified parameters, then simulate ``num_trials`` psychophysical trials at each scaling value by sampling that many times from a Bernoulli distribution wit...
r"""Test how many trials we need to be confident in our parameter estimates.
def test_num_trials(num_trials, num_bootstraps, proportionality_factor=5, critical_scaling=.2, scaling=torch.logspace(-1, -.3, steps=9), use_multiproc=True, n_processes=None, lr=.001, scheduler=True, max_iter=10000): r"""Test how many trials we need to be ...
[ "def", "test_num_trials", "(", "num_trials", ",", "num_bootstraps", ",", "proportionality_factor", "=", "5", ",", "critical_scaling", "=", ".2", ",", "scaling", "=", "torch", ".", "logspace", "(", "-", "1", ",", "-", ".3", ",", "steps", "=", "9", ")", ",...
[ 130, 0 ]
[ 235, 29 ]
python
en
['en', 'en', 'en']
True
TestAddBase.test_add_vector_create_collection
(self, connect, collection)
target: test add vector, then create collection again method: add vector and create collection expected: status not ok
target: test add vector, then create collection again method: add vector and create collection expected: status not ok
def test_add_vector_create_collection(self, connect, collection): ''' target: test add vector, then create collection again method: add vector and create collection expected: status not ok ''' vector = gen_single_vector(dim) status, ids = connect.insert(collection...
[ "def", "test_add_vector_create_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "param", "=...
[ 38, 4 ]
[ 51, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_has_collection
(self, connect, collection)
target: test add vector, then check collection existence method: add vector and call Hascollection expected: collection exists, status ok
target: test add vector, then check collection existence method: add vector and call Hascollection expected: collection exists, status ok
def test_add_vector_has_collection(self, connect, collection): ''' target: test add vector, then check collection existence method: add vector and call Hascollection expected: collection exists, status ok ''' vector = gen_single_vector(dim) status, ids = connect.i...
[ "def", "test_add_vector_has_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "assert", "ass...
[ 53, 4 ]
[ 61, 57 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_drop_collection_add_vector
(self, connect, collection)
target: test add vector after collection deleted method: delete collection and add vector expected: status not ok
target: test add vector after collection deleted method: delete collection and add vector expected: status not ok
def test_drop_collection_add_vector(self, connect, collection): ''' target: test add vector after collection deleted method: delete collection and add vector expected: status not ok ''' status = connect.drop_collection(collection) vector = gen_single_vector(dim) ...
[ "def", "test_drop_collection_add_vector", "(", "self", ",", "connect", ",", "collection", ")", ":", "status", "=", "connect", ".", "drop_collection", "(", "collection", ")", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "conne...
[ 64, 4 ]
[ 73, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_drop_collection_add_vector_another
(self, connect, collection)
target: test add vector to collection_1 after collection_2 deleted method: delete collection_2 and add vector to collection_1 expected: status ok
target: test add vector to collection_1 after collection_2 deleted method: delete collection_2 and add vector to collection_1 expected: status ok
def test_drop_collection_add_vector_another(self, connect, collection): ''' target: test add vector to collection_1 after collection_2 deleted method: delete collection_2 and add vector to collection_1 expected: status ok ''' param = {'collection_name': gen_unique_str(), ...
[ "def", "test_drop_collection_add_vector_another", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_size", "...
[ 76, 4 ]
[ 90, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_drop_collection
(self, connect, collection)
target: test delete collection after add vector method: add vector and delete collection expected: status ok
target: test delete collection after add vector method: add vector and delete collection expected: status ok
def test_add_vector_drop_collection(self, connect, collection): ''' target: test delete collection after add vector method: add vector and delete collection expected: status ok ''' vector = gen_single_vector(dim) status, ids = connect.insert(collection, vector) ...
[ "def", "test_add_vector_drop_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "status", "="...
[ 93, 4 ]
[ 102, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_delete_another_collection
(self, connect, collection)
target: test delete collection_1 collection after add vector to collection_2 method: add vector and delete collection expected: status ok
target: test delete collection_1 collection after add vector to collection_2 method: add vector and delete collection expected: status ok
def test_add_vector_delete_another_collection(self, connect, collection): ''' target: test delete collection_1 collection after add vector to collection_2 method: add vector and delete collection expected: status ok ''' param = {'collection_name': gen_unique_str(), ...
[ "def", "test_add_vector_delete_another_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_size", ...
[ 105, 4 ]
[ 118, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_drop_collection
(self, connect, collection)
target: test delete collection after add vector for a while method: add vector, sleep, and delete collection expected: status ok
target: test delete collection after add vector for a while method: add vector, sleep, and delete collection expected: status ok
def test_add_vector_sleep_drop_collection(self, connect, collection): ''' target: test delete collection after add vector for a while method: add vector, sleep, and delete collection expected: status ok ''' vector = gen_single_vector(dim) status, ids = connect.ins...
[ "def", "test_add_vector_sleep_drop_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "assert",...
[ 121, 4 ]
[ 132, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_delete_another_collection
(self, connect, collection)
target: test delete collection_1 collection after add vector to collection_2 for a while method: add vector , sleep, and delete collection expected: status ok
target: test delete collection_1 collection after add vector to collection_2 for a while method: add vector , sleep, and delete collection expected: status ok
def test_add_vector_sleep_delete_another_collection(self, connect, collection): ''' target: test delete collection_1 collection after add vector to collection_2 for a while method: add vector , sleep, and delete collection expected: status ok ''' param = {'collection_name...
[ "def", "test_add_vector_sleep_delete_another_collection", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_si...
[ 135, 4 ]
[ 150, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_create_index_add_vector
(self, connect, collection, get_simple_index)
target: test add vector after build index method: build index and add vector expected: status ok
target: test add vector after build index method: build index and add vector expected: status ok
def test_create_index_add_vector(self, connect, collection, get_simple_index): ''' target: test add vector after build index method: build index and add vector expected: status ok ''' index_param = get_simple_index["index_param"] index_type = get_simple_index["ind...
[ "def", "test_create_index_add_vector", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]", "status", ...
[ 153, 4 ]
[ 164, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_create_index_add_vector_another
(self, connect, collection, get_simple_index)
target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok
target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok
def test_create_index_add_vector_another(self, connect, collection, get_simple_index): ''' target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok ''' index_param = get_simple_index["index_param"] ...
[ "def", "test_create_index_add_vector_another", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]", "p...
[ 167, 4 ]
[ 184, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_create_index
(self, connect, collection, get_simple_index)
target: test build index add after vector method: add vector and build index expected: status ok
target: test build index add after vector method: add vector and build index expected: status ok
def test_add_vector_create_index(self, connect, collection, get_simple_index): ''' target: test build index add after vector method: add vector and build index expected: status ok ''' index_param = get_simple_index["index_param"] index_type = get_simple_index["ind...
[ "def", "test_add_vector_create_index", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]", "logging",...
[ 187, 4 ]
[ 199, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_create_index_another
(self, connect, collection, get_simple_index)
target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok
target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok
def test_add_vector_create_index_another(self, connect, collection, get_simple_index): ''' target: test add vector to collection_2 after build index for collection_1 method: build index and add vector expected: status ok ''' index_param = get_simple_index["index_param"] ...
[ "def", "test_add_vector_create_index_another", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]", "p...
[ 202, 4 ]
[ 218, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_create_index
(self, connect, collection, get_simple_index)
target: test build index add after vector for a while method: add vector and build index expected: status ok
target: test build index add after vector for a while method: add vector and build index expected: status ok
def test_add_vector_sleep_create_index(self, connect, collection, get_simple_index): ''' target: test build index add after vector for a while method: add vector and build index expected: status ok ''' index_param = get_simple_index["index_param"] index_type = get...
[ "def", "test_add_vector_sleep_create_index", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]", "vec...
[ 221, 4 ]
[ 233, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_create_index_another
(self, connect, collection, get_simple_index)
target: test add vector to collection_2 after build index for collection_1 for a while method: build index and add vector expected: status ok
target: test add vector to collection_2 after build index for collection_1 for a while method: build index and add vector expected: status ok
def test_add_vector_sleep_create_index_another(self, connect, collection, get_simple_index): ''' target: test add vector to collection_2 after build index for collection_1 for a while method: build index and add vector expected: status ok ''' index_param = get_simple_inde...
[ "def", "test_add_vector_sleep_create_index_another", "(", "self", ",", "connect", ",", "collection", ",", "get_simple_index", ")", ":", "index_param", "=", "get_simple_index", "[", "\"index_param\"", "]", "index_type", "=", "get_simple_index", "[", "\"index_type\"", "]"...
[ 236, 4 ]
[ 253, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_search_vector_add_vector
(self, connect, collection)
target: test add vector after search collection method: search collection and add vector expected: status ok
target: test add vector after search collection method: search collection and add vector expected: status ok
def test_search_vector_add_vector(self, connect, collection): ''' target: test add vector after search collection method: search collection and add vector expected: status ok ''' vector = gen_single_vector(dim) status, result = connect.search(collection, 1, vector...
[ "def", "test_search_vector_add_vector", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "result", "=", "connect", ".", "search", "(", "collection", ",", "1", ",", "vector", ")", ...
[ 256, 4 ]
[ 265, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_search_vector_add_vector_another
(self, connect, collection)
target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok
target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok
def test_search_vector_add_vector_another(self, connect, collection): ''' target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok ''' param = {'collection_name': gen_unique_str(), 'dim...
[ "def", "test_search_vector_add_vector_another", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_size", ","...
[ 268, 4 ]
[ 282, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_search_vector
(self, connect, collection)
target: test search vector after add vector method: add vector and search collection expected: status ok
target: test search vector after add vector method: add vector and search collection expected: status ok
def test_add_vector_search_vector(self, connect, collection): ''' target: test search vector after add vector method: add vector and search collection expected: status ok ''' vector = gen_single_vector(dim) status, ids = connect.insert(collection, vector) ...
[ "def", "test_add_vector_search_vector", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "assert", "stat...
[ 285, 4 ]
[ 296, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_search_vector_another
(self, connect, collection)
target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok
target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok
def test_add_vector_search_vector_another(self, connect, collection): ''' target: test add vector to collection_1 after search collection_2 method: search collection and add vector expected: status ok ''' param = {'collection_name': gen_unique_str(), 'dim...
[ "def", "test_add_vector_search_vector_another", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_size", ","...
[ 299, 4 ]
[ 313, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_search_vector
(self, connect, collection)
target: test search vector after add vector after a while method: add vector, sleep, and search collection expected: status ok
target: test search vector after add vector after a while method: add vector, sleep, and search collection expected: status ok
def test_add_vector_sleep_search_vector(self, connect, collection): ''' target: test search vector after add vector after a while method: add vector, sleep, and search collection expected: status ok ''' vector = gen_single_vector(dim) status, ids = connect.insert(...
[ "def", "test_add_vector_sleep_search_vector", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vector", ")", "connect", ...
[ 316, 4 ]
[ 326, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_sleep_search_vector_another
(self, connect, collection)
target: test add vector to collection_1 after search collection_2 a while method: search collection , sleep, and add vector expected: status ok
target: test add vector to collection_1 after search collection_2 a while method: search collection , sleep, and add vector expected: status ok
def test_add_vector_sleep_search_vector_another(self, connect, collection): ''' target: test add vector to collection_1 after search collection_2 a while method: search collection , sleep, and add vector expected: status ok ''' param = {'collection_name': gen_unique_str()...
[ "def", "test_add_vector_sleep_search_vector_another", "(", "self", ",", "connect", ",", "collection", ")", ":", "param", "=", "{", "'collection_name'", ":", "gen_unique_str", "(", ")", ",", "'dimension'", ":", "dim", ",", "'index_file_size'", ":", "index_file_size",...
[ 329, 4 ]
[ 344, 26 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_ids
(self, connect, collection)
target: test add vectors in collection, use customize ids method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count
target: test add vectors in collection, use customize ids method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count
def test_insert_ids(self, connect, collection): ''' target: test add vectors in collection, use customize ids method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count ...
[ "def", "test_insert_ids", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "top_k", "=", "1", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "ids", "=", "[", "i", "for", "i", "in", "range", "(", "nq", ")", "]"...
[ 353, 4 ]
[ 370, 39 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_twice_ids_no_ids
(self, connect, collection)
target: check the result of insert, with params ids and no ids method: test add vectors twice, use customize ids first, and then use no ids expected: status not OK
target: check the result of insert, with params ids and no ids method: test add vectors twice, use customize ids first, and then use no ids expected: status not OK
def test_insert_twice_ids_no_ids(self, connect, collection): ''' target: check the result of insert, with params ids and no ids method: test add vectors twice, use customize ids first, and then use no ids expected: status not OK ''' nq = 5; top_k = 1; vectors = g...
[ "def", "test_insert_twice_ids_no_ids", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "top_k", "=", "1", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "ids", "=", "[", "i", "for", "i", "in", "range", "(", "nq",...
[ 373, 4 ]
[ 387, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_twice_not_ids_ids
(self, connect, collection)
target: check the result of insert, with params ids and no ids method: test add vectors twice, use not ids first, and then use customize ids expected: status not OK
target: check the result of insert, with params ids and no ids method: test add vectors twice, use not ids first, and then use customize ids expected: status not OK
def test_insert_twice_not_ids_ids(self, connect, collection): ''' target: check the result of insert, with params ids and no ids method: test add vectors twice, use not ids first, and then use customize ids expected: status not OK ''' nq = 5; top_k = 1; vectors =...
[ "def", "test_insert_twice_not_ids_ids", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "top_k", "=", "1", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "ids", "=", "[", "i", "for", "i", "in", "range", "(", "nq"...
[ 390, 4 ]
[ 404, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_ids_length_not_match
(self, connect, collection)
target: test add vectors in collection, use customize ids, len(ids) != len(vectors) method: create collection and add vectors in it expected: raise an exception
target: test add vectors in collection, use customize ids, len(ids) != len(vectors) method: create collection and add vectors in it expected: raise an exception
def test_insert_ids_length_not_match(self, connect, collection): ''' target: test add vectors in collection, use customize ids, len(ids) != len(vectors) method: create collection and add vectors in it expected: raise an exception ''' nq = 5 vectors = gen_vectors(n...
[ "def", "test_insert_ids_length_not_match", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "ids", "=", "[", "i", "for", "i", "in", "range", "(", "1", ",", "nq", ")",...
[ 407, 4 ]
[ 417, 66 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_ids_invalid
(self, connect, collection, get_vector_id)
target: test add vectors in collection, use customize ids, which are not int64 method: create collection and add vectors in it expected: raise an exception
target: test add vectors in collection, use customize ids, which are not int64 method: create collection and add vectors in it expected: raise an exception
def test_insert_ids_invalid(self, connect, collection, get_vector_id): ''' target: test add vectors in collection, use customize ids, which are not int64 method: create collection and add vectors in it expected: raise an exception ''' nq = 5 vectors = gen_vectors(...
[ "def", "test_insert_ids_invalid", "(", "self", ",", "connect", ",", "collection", ",", "get_vector_id", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "vector_id", "=", "get_vector_id", "ids", "=", "[", "vector_id", "f...
[ 427, 4 ]
[ 438, 52 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert
(self, connect, collection)
target: test add vectors in collection created before method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count
target: test add vectors in collection created before method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count
def test_insert(self, connect, collection): ''' target: test add vectors in collection created before method: create collection and add vectors in it, check the ids returned and the collection length after vectors added expected: the length of ids and the collection row count '''...
[ "def", "test_insert", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vectors", ")", "a...
[ 441, 4 ]
[ 451, 29 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_tag
(self, connect, collection)
target: test add vectors in collection created before method: create collection and add vectors in it, with the partition_tag param expected: the collection row count equals to nq
target: test add vectors in collection created before method: create collection and add vectors in it, with the partition_tag param expected: the collection row count equals to nq
def test_insert_tag(self, connect, collection): ''' target: test add vectors in collection created before method: create collection and add vectors in it, with the partition_tag param expected: the collection row count equals to nq ''' nq = 5 vectors = gen_vectors...
[ "def", "test_insert_tag", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", "=", "connect", ".", "create_partition", "(", "collection", ",", "tag", ")", "status"...
[ 454, 4 ]
[ 465, 29 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_tag_A
(self, connect, collection)
target: test add vectors in collection created before method: create partition and add vectors in it expected: the collection row count equals to nq
target: test add vectors in collection created before method: create partition and add vectors in it expected: the collection row count equals to nq
def test_insert_tag_A(self, connect, collection): ''' target: test add vectors in collection created before method: create partition and add vectors in it expected: the collection row count equals to nq ''' nq = 5 vectors = gen_vectors(nq, dim) status = co...
[ "def", "test_insert_tag_A", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", "=", "connect", ".", "create_partition", "(", "collection", ",", "tag", ")", "statu...
[ 468, 4 ]
[ 479, 29 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_tag_not_existed
(self, connect, collection)
target: test add vectors in collection created before method: create collection and add vectors in it, with the not existed partition_tag param expected: status not ok
target: test add vectors in collection created before method: create collection and add vectors in it, with the not existed partition_tag param expected: status not ok
def test_insert_tag_not_existed(self, connect, collection): ''' target: test add vectors in collection created before method: create collection and add vectors in it, with the not existed partition_tag param expected: status not ok ''' nq = 5 vectors = gen_vectors...
[ "def", "test_insert_tag_not_existed", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", "vecto...
[ 482, 4 ]
[ 491, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_tag_not_existed_A
(self, connect, collection)
target: test add vectors in collection created before method: create partition, add vectors with the not existed partition_tag param expected: status not ok
target: test add vectors in collection created before method: create partition, add vectors with the not existed partition_tag param expected: status not ok
def test_insert_tag_not_existed_A(self, connect, collection): ''' target: test add vectors in collection created before method: create partition, add vectors with the not existed partition_tag param expected: status not ok ''' nq = 5 vectors = gen_vectors(nq, dim)...
[ "def", "test_insert_tag_not_existed_A", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "new_tag", "=", "\"new_tag\"", "status", "=", "connect", ".", "create_partition", "("...
[ 494, 4 ]
[ 505, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_tag_existed
(self, connect, collection)
target: test add vectors in collection created before method: create collection and add vectors in it repeatly, with the partition_tag param expected: the collection row count equals to nq
target: test add vectors in collection created before method: create collection and add vectors in it repeatly, with the partition_tag param expected: the collection row count equals to nq
def test_insert_tag_existed(self, connect, collection): ''' target: test add vectors in collection created before method: create collection and add vectors in it repeatly, with the partition_tag param expected: the collection row count equals to nq ''' nq = 5 vect...
[ "def", "test_insert_tag_existed", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", "=", "connect", ".", "create_partition", "(", "collection", ",", "tag", ")", ...
[ 508, 4 ]
[ 521, 33 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_without_connect
(self, dis_connect, collection)
target: test add vectors without connection method: create collection and add vectors in it, check if added successfully expected: raise exception
target: test add vectors without connection method: create collection and add vectors in it, check if added successfully expected: raise exception
def test_insert_without_connect(self, dis_connect, collection): ''' target: test add vectors without connection method: create collection and add vectors in it, check if added successfully expected: raise exception ''' nq = 5 vectors = gen_vectors(nq, dim) ...
[ "def", "test_insert_without_connect", "(", "self", ",", "dis_connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "with", "pytest", ".", "raises", "(", "Exception", ")", "as", "e", ":", "status...
[ 524, 4 ]
[ 533, 65 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_collection_not_existed
(self, connect)
target: test add vectors in collection, which not existed before method: add vectors collection not existed, check the status expected: status not ok
target: test add vectors in collection, which not existed before method: add vectors collection not existed, check the status expected: status not ok
def test_add_collection_not_existed(self, connect): ''' target: test add vectors in collection, which not existed before method: add vectors collection not existed, check the status expected: status not ok ''' nq = 5 vector = gen_single_vector(dim) status,...
[ "def", "test_add_collection_not_existed", "(", "self", ",", "connect", ")", ":", "nq", "=", "5", "vector", "=", "gen_single_vector", "(", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "gen_unique_str", "(", "\"not_exist_collection\"", "...
[ 535, 4 ]
[ 545, 22 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_dim_not_matched
(self, connect, collection)
target: test add vector, the vector dimension is not equal to the collection dimension method: the vector dimension is half of the collection dimension, check the status expected: status not ok
target: test add vector, the vector dimension is not equal to the collection dimension method: the vector dimension is half of the collection dimension, check the status expected: status not ok
def test_add_vector_dim_not_matched(self, connect, collection): ''' target: test add vector, the vector dimension is not equal to the collection dimension method: the vector dimension is half of the collection dimension, check the status expected: status not ok ''' vector...
[ "def", "test_add_vector_dim_not_matched", "(", "self", ",", "connect", ",", "collection", ")", ":", "vector", "=", "gen_single_vector", "(", "int", "(", "dim", ")", "//", "2", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ","...
[ 547, 4 ]
[ 555, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_insert_dim_not_matched
(self, connect, collection)
target: test add vectors, the vector dimension is not equal to the collection dimension method: the vectors dimension is half of the collection dimension, check the status expected: status not ok
target: test add vectors, the vector dimension is not equal to the collection dimension method: the vectors dimension is half of the collection dimension, check the status expected: status not ok
def test_insert_dim_not_matched(self, connect, collection): ''' target: test add vectors, the vector dimension is not equal to the collection dimension method: the vectors dimension is half of the collection dimension, check the status expected: status not ok ''' nq = 5 ...
[ "def", "test_insert_dim_not_matched", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "int", "(", "dim", ")", "//", "2", ")", "status", ",", "ids", "=", "connect", ".", "insert", ...
[ 557, 4 ]
[ 566, 30 ]
python
en
['en', 'error', 'th']
False
TestAddBase.test_add_vector_query_after_sleep
(self, connect, collection)
target: test add vectors, and search it after sleep method: set vector[0][1] as query vectors expected: status ok and result length is 1
target: test add vectors, and search it after sleep method: set vector[0][1] as query vectors expected: status ok and result length is 1
def test_add_vector_query_after_sleep(self, connect, collection): ''' target: test add vectors, and search it after sleep method: set vector[0][1] as query vectors expected: status ok and result length is 1 ''' nq = 5 vectors = gen_vectors(nq, dim) status,...
[ "def", "test_add_vector_query_after_sleep", "(", "self", ",", "connect", ",", "collection", ")", ":", "nq", "=", "5", "vectors", "=", "gen_vectors", "(", "nq", ",", "dim", ")", "status", ",", "ids", "=", "connect", ".", "insert", "(", "collection", ",", ...
[ 568, 4 ]
[ 580, 31 ]
python
en
['en', 'error', 'th']
False