hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2b352de8451836b4d3296b8a01b6bec124770a3f | Gumbachi/colorBOT | cogs/color/info.py | [
"MIT"
] | Python | draw_colors | <not_specific> | def draw_colors(colors):
"""Draw the colors in the current set"""
rows = math.ceil(len(colors) / 3) # amt of rows needed
row_height = 50
column_width = 300
columns = 3
img = Image.new(mode='RGBA',
size=(columns * column_width, rows * row_height),... | Draw the colors in the current set | Draw the colors in the current set | [
"Draw",
"the",
"colors",
"in",
"the",
"current",
"set"
] | def draw_colors(colors):
rows = math.ceil(len(colors) / 3)
row_height = 50
column_width = 300
columns = 3
img = Image.new(mode='RGBA',
size=(columns * column_width, rows * row_height),
color=(0, 0, 0, 0))
draw = ImageDraw.... | [
"def",
"draw_colors",
"(",
"colors",
")",
":",
"rows",
"=",
"math",
".",
"ceil",
"(",
"len",
"(",
"colors",
")",
"/",
"3",
")",
"row_height",
"=",
"50",
"column_width",
"=",
"300",
"columns",
"=",
"3",
"img",
"=",
"Image",
".",
"new",
"(",
"mode",
... | Draw the colors in the current set | [
"Draw",
"the",
"colors",
"in",
"the",
"current",
"set"
] | [
"\"\"\"Draw the colors in the current set\"\"\"",
"# amt of rows needed",
"# set image for drawing",
"# draws and labels boxes",
"# draw boxes",
"# 0,1,2 repeating",
"# increment every 3 elements",
"# origin to draw boxes",
"# width of text",
"# cut text until it fits",
"# Make text readable",
... | [
{
"param": "colors",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "colors",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2b352de8451836b4d3296b8a01b6bec124770a3f | Gumbachi/colorBOT | cogs/color/info.py | [
"MIT"
] | Python | show_colors | <not_specific> | async def show_colors(self, ctx):
"""Display an image of equipped colors."""
colors = db.get(ctx.guild.id, "colors")
if not colors:
return await ctx.send(embed=Embed(title="You have no colors"))
await ctx.send(file=self.draw_colors(colors)) | Display an image of equipped colors. | Display an image of equipped colors. | [
"Display",
"an",
"image",
"of",
"equipped",
"colors",
"."
] | async def show_colors(self, ctx):
colors = db.get(ctx.guild.id, "colors")
if not colors:
return await ctx.send(embed=Embed(title="You have no colors"))
await ctx.send(file=self.draw_colors(colors)) | [
"async",
"def",
"show_colors",
"(",
"self",
",",
"ctx",
")",
":",
"colors",
"=",
"db",
".",
"get",
"(",
"ctx",
".",
"guild",
".",
"id",
",",
"\"colors\"",
")",
"if",
"not",
"colors",
":",
"return",
"await",
"ctx",
".",
"send",
"(",
"embed",
"=",
... | Display an image of equipped colors. | [
"Display",
"an",
"image",
"of",
"equipped",
"colors",
"."
] | [
"\"\"\"Display an image of equipped colors.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
2b352de8451836b4d3296b8a01b6bec124770a3f | Gumbachi/colorBOT | cogs/color/info.py | [
"MIT"
] | Python | show_colors_in_detail | null | async def show_colors_in_detail(self, ctx):
"""Show what the database thinks colors are (For testing/support)."""
colors = db.get(ctx.guild.id, "colors")
cinfo = Embed(title="Detailed Color Info", description="")
for color in colors:
members = [bot.get_user(id).name for id in... | Show what the database thinks colors are (For testing/support). | Show what the database thinks colors are (For testing/support). | [
"Show",
"what",
"the",
"database",
"thinks",
"colors",
"are",
"(",
"For",
"testing",
"/",
"support",
")",
"."
] | async def show_colors_in_detail(self, ctx):
colors = db.get(ctx.guild.id, "colors")
cinfo = Embed(title="Detailed Color Info", description="")
for color in colors:
members = [bot.get_user(id).name for id in color["members"]]
cinfo.add_field(
name=color["na... | [
"async",
"def",
"show_colors_in_detail",
"(",
"self",
",",
"ctx",
")",
":",
"colors",
"=",
"db",
".",
"get",
"(",
"ctx",
".",
"guild",
".",
"id",
",",
"\"colors\"",
")",
"cinfo",
"=",
"Embed",
"(",
"title",
"=",
"\"Detailed Color Info\"",
",",
"descripti... | Show what the database thinks colors are (For testing/support). | [
"Show",
"what",
"the",
"database",
"thinks",
"colors",
"are",
"(",
"For",
"testing",
"/",
"support",
")",
"."
] | [
"\"\"\"Show what the database thinks colors are (For testing/support).\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a7c67a3eacd1e06ed1c05872f62d5bf229001207 | hjkornn-phys/fsdl-text-recognizer-2021-labs | lab9/text_recognizer/paragraph_text_recognizer.py | [
"MIT"
] | Python | predict | str | def predict(self, image: Union[str, Path, Image.Image]) -> str:
"""Predict/infer text in input image (which can be a file path)."""
image_pil = image
if not isinstance(image, Image.Image):
image_pil = util.read_image_pil(image, grayscale=True)
image_pil = resize_image(image_... | Predict/infer text in input image (which can be a file path). | Predict/infer text in input image (which can be a file path). | [
"Predict",
"/",
"infer",
"text",
"in",
"input",
"image",
"(",
"which",
"can",
"be",
"a",
"file",
"path",
")",
"."
] | def predict(self, image: Union[str, Path, Image.Image]) -> str:
image_pil = image
if not isinstance(image, Image.Image):
image_pil = util.read_image_pil(image, grayscale=True)
image_pil = resize_image(image_pil, IMAGE_SCALE_FACTOR)
image_tensor = self.transform(image_pil)
... | [
"def",
"predict",
"(",
"self",
",",
"image",
":",
"Union",
"[",
"str",
",",
"Path",
",",
"Image",
".",
"Image",
"]",
")",
"->",
"str",
":",
"image_pil",
"=",
"image",
"if",
"not",
"isinstance",
"(",
"image",
",",
"Image",
".",
"Image",
")",
":",
... | Predict/infer text in input image (which can be a file path). | [
"Predict",
"/",
"infer",
"text",
"in",
"input",
"image",
"(",
"which",
"can",
"be",
"a",
"file",
"path",
")",
"."
] | [
"\"\"\"Predict/infer text in input image (which can be a file path).\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "image",
"type": "Union[str, Path, Image.Image]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "image",
"type": "Union[str, Path, Image.Image]",
"docstring": null,... |
be4397514cbfed9cc269738e56afbf7012f375e8 | dwalin93/RoutingAlgorithms | A_Star_1.py | [
"MIT"
] | Python | astar_path_Kasia | <not_specific> | def astar_path_Kasia(G, source, target, scenario, coordDict): # weight=GlobalScore and add later LocalScore
"""Returns a list of nodes in a shortest path between source and target
using the A* ("A-star") algorithm.
Heurestic function changed to include the dictionairy with the coordinates
Weig... | Returns a list of nodes in a shortest path between source and target
using the A* ("A-star") algorithm.
Heurestic function changed to include the dictionairy with the coordinates
Weights used in the function include distant and local scores of the edges
| Returns a list of nodes in a shortest path between source and target
using the A* ("A-star") algorithm.
Heurestic function changed to include the dictionairy with the coordinates
Weights used in the function include distant and local scores of the edges | [
"Returns",
"a",
"list",
"of",
"nodes",
"in",
"a",
"shortest",
"path",
"between",
"source",
"and",
"target",
"using",
"the",
"A",
"*",
"(",
"\"",
"A",
"-",
"star",
"\"",
")",
"algorithm",
".",
"Heurestic",
"function",
"changed",
"to",
"include",
"the",
... | def astar_path_Kasia(G, source, target, scenario, coordDict):
def heuristic_Kasia(theNode, theTarget, coordDict):
nodeX = coordDict[theNode][0]
nodeY = coordDict[theNode][1]
targetX = coordDict[theTarget][0]
targetY = coordDict[theTarget][1]
distanceToTarget = math.sqrt(math... | [
"def",
"astar_path_Kasia",
"(",
"G",
",",
"source",
",",
"target",
",",
"scenario",
",",
"coordDict",
")",
":",
"def",
"heuristic_Kasia",
"(",
"theNode",
",",
"theTarget",
",",
"coordDict",
")",
":",
"nodeX",
"=",
"coordDict",
"[",
"theNode",
"]",
"[",
"... | Returns a list of nodes in a shortest path between source and target
using the A* ("A-star") algorithm. | [
"Returns",
"a",
"list",
"of",
"nodes",
"in",
"a",
"shortest",
"path",
"between",
"source",
"and",
"target",
"using",
"the",
"A",
"*",
"(",
"\"",
"A",
"-",
"star",
"\"",
")",
"algorithm",
"."
] | [
"# weight=GlobalScore and add later LocalScore",
"\"\"\"Returns a list of nodes in a shortest path between source and target\n using the A* (\"A-star\") algorithm.\n \n Heurestic function changed to include the dictionairy with the coordinates\n \n Weights used in the function include distant and l... | [
{
"param": "G",
"type": null
},
{
"param": "source",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "scenario",
"type": null
},
{
"param": "coordDict",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "G",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens": []... |
e134913ea462438d14c20ea65c3fa5d6d7a5ff68 | acetylsalicyl/SlicerRawImageGuess | RawImageGuess/RawImageGuess.py | [
"BSD-2-Clause"
] | Python | runTest | null | def runTest(self):
"""Run as few or as many tests as needed here.
"""
self.setUp()
self.test_RawImageGuess1() | Run as few or as many tests as needed here.
| Run as few or as many tests as needed here. | [
"Run",
"as",
"few",
"or",
"as",
"many",
"tests",
"as",
"needed",
"here",
"."
] | def runTest(self):
self.setUp()
self.test_RawImageGuess1() | [
"def",
"runTest",
"(",
"self",
")",
":",
"self",
".",
"setUp",
"(",
")",
"self",
".",
"test_RawImageGuess1",
"(",
")"
] | Run as few or as many tests as needed here. | [
"Run",
"as",
"few",
"or",
"as",
"many",
"tests",
"as",
"needed",
"here",
"."
] | [
"\"\"\"Run as few or as many tests as needed here.\r\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | copy_config | <not_specific> | def copy_config(self, overwrite=False,
new_ext='.new'):
'''Copy a user editable config file to the target directory.
Args:
overwrite (bool, optional): Copy the config files to
target directory even if it already exists. Default to False
n... | Copy a user editable config file to the target directory.
Args:
overwrite (bool, optional): Copy the config files to
target directory even if it already exists. Default to False
new_dir (str, optional): If user_config_path exists and overwrite
is False copy t... | Copy a user editable config file to the target directory. | [
"Copy",
"a",
"user",
"editable",
"config",
"file",
"to",
"the",
"target",
"directory",
"."
] | def copy_config(self, overwrite=False,
new_ext='.new'):
if self.directory_map is None:
error_str = "No source directory available."
raise ValueError(error_str)
self.directory_map.copy_file(self.config_file_name,
overw... | [
"def",
"copy_config",
"(",
"self",
",",
"overwrite",
"=",
"False",
",",
"new_ext",
"=",
"'.new'",
")",
":",
"if",
"self",
".",
"directory_map",
"is",
"None",
":",
"error_str",
"=",
"\"No source directory available.\"",
"raise",
"ValueError",
"(",
"error_str",
... | Copy a user editable config file to the target directory. | [
"Copy",
"a",
"user",
"editable",
"config",
"file",
"to",
"the",
"target",
"directory",
"."
] | [
"'''Copy a user editable config file to the target directory.\n\n Args:\n overwrite (bool, optional): Copy the config files to\n target directory even if it already exists. Default to False\n new_dir (str, optional): If user_config_path exists and overwrite\n i... | [
{
"param": "self",
"type": null
},
{
"param": "overwrite",
"type": null
},
{
"param": "new_ext",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overwrite",
"type": null,
"docstring": "Copy the config files to\nt... |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | make_head_foot_bar | <not_specific> | def make_head_foot_bar(cls, header_title, bar_width, bar_char='*'):
'''Make header and footer strings consisting of a bar of characters of
fixed width, with a title embeded in the header bar.
Args:
header_title (str): The title to be placed in the header bar.
bar_width ... | Make header and footer strings consisting of a bar of characters of
fixed width, with a title embeded in the header bar.
Args:
header_title (str): The title to be placed in the header bar.
bar_width (int): The number of characters in the header and
footer.
... | Make header and footer strings consisting of a bar of characters of
fixed width, with a title embeded in the header bar. | [
"Make",
"header",
"and",
"footer",
"strings",
"consisting",
"of",
"a",
"bar",
"of",
"characters",
"of",
"fixed",
"width",
"with",
"a",
"title",
"embeded",
"in",
"the",
"header",
"bar",
"."
] | def make_head_foot_bar(cls, header_title, bar_width, bar_char='*'):
title_space = ' {} '.format(header_title)
header = "{0:{1}^{2}}".format(title_space, bar_char[0], bar_width)
footer = bar_char * bar_width
return (header, footer) | [
"def",
"make_head_foot_bar",
"(",
"cls",
",",
"header_title",
",",
"bar_width",
",",
"bar_char",
"=",
"'*'",
")",
":",
"title_space",
"=",
"' {} '",
".",
"format",
"(",
"header_title",
")",
"header",
"=",
"\"{0:{1}^{2}}\"",
".",
"format",
"(",
"title_space",
... | Make header and footer strings consisting of a bar of characters of
fixed width, with a title embeded in the header bar. | [
"Make",
"header",
"and",
"footer",
"strings",
"consisting",
"of",
"a",
"bar",
"of",
"characters",
"of",
"fixed",
"width",
"with",
"a",
"title",
"embeded",
"in",
"the",
"header",
"bar",
"."
] | [
"'''Make header and footer strings consisting of a bar of characters of\n fixed width, with a title embeded in the header bar.\n\n Args:\n header_title (str): The title to be placed in the header bar.\n bar_width (int): The number of characters in the header and\n fo... | [
{
"param": "cls",
"type": null
},
{
"param": "header_title",
"type": null
},
{
"param": "bar_width",
"type": null
},
{
"param": "bar_char",
"type": null
}
] | {
"returns": [
{
"docstring": "Tuple containing the strings (header, footer).",
"docstring_tokens": [
"Tuple",
"containing",
"the",
"strings",
"(",
"header",
"footer",
")",
"."
],
"type": "tuple"
}
],
"raises":... |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | copy_config | <not_specific> | def copy_config(self, overwrite=False,
new_ext='.new'):
'''Copy a user editable config file to the target directory.
Args:
overwrite (bool, optional): Copy the config files to
target directory even if it already exists. Default to False
n... | Copy a user editable config file to the target directory.
Args:
overwrite (bool, optional): Copy the config files to
target directory even if it already exists. Default to False
new_dir (str, optional): If user_config_path exists and overwrite
is False copy t... | Copy a user editable config file to the target directory. | [
"Copy",
"a",
"user",
"editable",
"config",
"file",
"to",
"the",
"target",
"directory",
"."
] | def copy_config(self, overwrite=False,
new_ext='.new'):
super(ReadINI, self).copy_config(overwrite, new_ext)
if self.validation_file_name is None: return
self.directory_map.copy_file(self.validation_file_name,
overwrite=overwrite,
... | [
"def",
"copy_config",
"(",
"self",
",",
"overwrite",
"=",
"False",
",",
"new_ext",
"=",
"'.new'",
")",
":",
"super",
"(",
"ReadINI",
",",
"self",
")",
".",
"copy_config",
"(",
"overwrite",
",",
"new_ext",
")",
"if",
"self",
".",
"validation_file_name",
"... | Copy a user editable config file to the target directory. | [
"Copy",
"a",
"user",
"editable",
"config",
"file",
"to",
"the",
"target",
"directory",
"."
] | [
"'''Copy a user editable config file to the target directory.\n\n Args:\n overwrite (bool, optional): Copy the config files to\n target directory even if it already exists. Default to False\n new_dir (str, optional): If user_config_path exists and overwrite\n i... | [
{
"param": "self",
"type": null
},
{
"param": "overwrite",
"type": null
},
{
"param": "new_ext",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overwrite",
"type": null,
"docstring": "Copy the config files to\nt... |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | _type_fails | <not_specific> | def _type_fails(self, results):
'''Create strings with the specific validation errors.
Args:
results: The results of a ConfigObj.validate call.
Results:
list: A list of strings containing the validation errors.
'''
log_lines = []
# Iterate th... | Create strings with the specific validation errors.
Args:
results: The results of a ConfigObj.validate call.
Results:
list: A list of strings containing the validation errors.
| Create strings with the specific validation errors. | [
"Create",
"strings",
"with",
"the",
"specific",
"validation",
"errors",
"."
] | def _type_fails(self, results):
log_lines = []
for key, value in results.iteritems():
if issubclass(type(value), ValidateError):
log_str = (' - Key "{}" failed with error:\n'
' {}').format(key, value)
log_lines.append(log_str)
... | [
"def",
"_type_fails",
"(",
"self",
",",
"results",
")",
":",
"log_lines",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"results",
".",
"iteritems",
"(",
")",
":",
"if",
"issubclass",
"(",
"type",
"(",
"value",
")",
",",
"ValidateError",
")",
":",... | Create strings with the specific validation errors. | [
"Create",
"strings",
"with",
"the",
"specific",
"validation",
"errors",
"."
] | [
"'''Create strings with the specific validation errors.\n\n Args:\n results: The results of a ConfigObj.validate call.\n\n Results:\n list: A list of strings containing the validation errors.\n\n '''",
"# Iterate through the failures in the config file"
] | [
{
"param": "self",
"type": null
},
{
"param": "results",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "results",
"type": null,
"docstring": "The results of a ConfigObj.va... |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | read | <not_specific> | def read(self):
'''Load the YAML configuration file.'''
# Get the file path
yaml_config_path = self.get_config_path()
with open(yaml_config_path, 'r') as conf:
config_dict = yaml.load(conf, Loader=Loader)
return config_dict | Load the YAML configuration file. | Load the YAML configuration file. | [
"Load",
"the",
"YAML",
"configuration",
"file",
"."
] | def read(self):
yaml_config_path = self.get_config_path()
with open(yaml_config_path, 'r') as conf:
config_dict = yaml.load(conf, Loader=Loader)
return config_dict | [
"def",
"read",
"(",
"self",
")",
":",
"yaml_config_path",
"=",
"self",
".",
"get_config_path",
"(",
")",
"with",
"open",
"(",
"yaml_config_path",
",",
"'r'",
")",
"as",
"conf",
":",
"config_dict",
"=",
"yaml",
".",
"load",
"(",
"conf",
",",
"Loader",
"... | Load the YAML configuration file. | [
"Load",
"the",
"YAML",
"configuration",
"file",
"."
] | [
"'''Load the YAML configuration file.'''",
"# Get the file path"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | write | <not_specific> | def write(self, obj_to_serialise, default_flow_style=False):
'''Write the YAML configuration file.'''
# Write the file
yaml_config_path = self.get_config_path()
# Ensure target directory exists
self.target_dir.makedir()
with open(yaml_c... | Write the YAML configuration file. | Write the YAML configuration file. | [
"Write",
"the",
"YAML",
"configuration",
"file",
"."
] | def write(self, obj_to_serialise, default_flow_style=False):
yaml_config_path = self.get_config_path()
self.target_dir.makedir()
with open(yaml_config_path, 'w') as yaml_file:
yaml.dump(obj_to_serialise,
yaml_file,
default_flow_style=defaul... | [
"def",
"write",
"(",
"self",
",",
"obj_to_serialise",
",",
"default_flow_style",
"=",
"False",
")",
":",
"yaml_config_path",
"=",
"self",
".",
"get_config_path",
"(",
")",
"self",
".",
"target_dir",
".",
"makedir",
"(",
")",
"with",
"open",
"(",
"yaml_config... | Write the YAML configuration file. | [
"Write",
"the",
"YAML",
"configuration",
"file",
"."
] | [
"'''Write the YAML configuration file.'''",
"# Write the file",
"# Ensure target directory exists"
] | [
{
"param": "self",
"type": null
},
{
"param": "obj_to_serialise",
"type": null
},
{
"param": "default_flow_style",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obj_to_serialise",
"type": null,
"docstring": null,
"docstrin... |
26c616423db1dba4d49fa4464ccbff59d0a3d8e2 | H0R5E/polite | polite/configuration.py | [
"MIT"
] | Python | configure_logger | <not_specific> | def configure_logger(cls, log_config_dict):
'''Load the logging configuration file.'''
# Configure the logger
dictConfig(log_config_dict)
return | Load the logging configuration file. | Load the logging configuration file. | [
"Load",
"the",
"logging",
"configuration",
"file",
"."
] | def configure_logger(cls, log_config_dict):
dictConfig(log_config_dict)
return | [
"def",
"configure_logger",
"(",
"cls",
",",
"log_config_dict",
")",
":",
"dictConfig",
"(",
"log_config_dict",
")",
"return"
] | Load the logging configuration file. | [
"Load",
"the",
"logging",
"configuration",
"file",
"."
] | [
"'''Load the logging configuration file.'''",
"# Configure the logger"
] | [
{
"param": "cls",
"type": null
},
{
"param": "log_config_dict",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "log_config_dict",
"type": null,
"docstring": null,
"docstring_... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | add_tag_based_on_content | null | def add_tag_based_on_content(input_file: Path, tag: str, content: str):
"""
not all notebook editors are good with tags, but papermill uses it
to find the parameters cell.
This injects tag to the file based on the content of a cell
"""
with open(input_file) as f:
nb = json.load(f)
c... |
not all notebook editors are good with tags, but papermill uses it
to find the parameters cell.
This injects tag to the file based on the content of a cell
| not all notebook editors are good with tags, but papermill uses it
to find the parameters cell.
This injects tag to the file based on the content of a cell | [
"not",
"all",
"notebook",
"editors",
"are",
"good",
"with",
"tags",
"but",
"papermill",
"uses",
"it",
"to",
"find",
"the",
"parameters",
"cell",
".",
"This",
"injects",
"tag",
"to",
"the",
"file",
"based",
"on",
"the",
"content",
"of",
"a",
"cell"
] | def add_tag_based_on_content(input_file: Path, tag: str, content: str):
with open(input_file) as f:
nb = json.load(f)
change = False
for n, cell in enumerate(nb["cells"]):
if cell["cell_type"] == "code":
if cell["source"] and content in "".join(cell["source"]):
ta... | [
"def",
"add_tag_based_on_content",
"(",
"input_file",
":",
"Path",
",",
"tag",
":",
"str",
",",
"content",
":",
"str",
")",
":",
"with",
"open",
"(",
"input_file",
")",
"as",
"f",
":",
"nb",
"=",
"json",
".",
"load",
"(",
"f",
")",
"change",
"=",
"... | not all notebook editors are good with tags, but papermill uses it
to find the parameters cell. | [
"not",
"all",
"notebook",
"editors",
"are",
"good",
"with",
"tags",
"but",
"papermill",
"uses",
"it",
"to",
"find",
"the",
"parameters",
"cell",
"."
] | [
"\"\"\"\n not all notebook editors are good with tags, but papermill uses it\n to find the parameters cell.\n This injects tag to the file based on the content of a cell\n \"\"\""
] | [
{
"param": "input_file",
"type": "Path"
},
{
"param": "tag",
"type": "str"
},
{
"param": "content",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_file",
"type": "Path",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "str",
"docstring": null,
"docstring_to... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | papermill | null | def papermill(self, slug, params, rerun: bool = True):
"""
execute the notebook with the parameters
to the papermill storage folder
"""
# need bit here that checks the parameters are right
actual_path = self.raw_path()
if rerun is False:
print("Not pap... |
execute the notebook with the parameters
to the papermill storage folder
| execute the notebook with the parameters
to the papermill storage folder | [
"execute",
"the",
"notebook",
"with",
"the",
"parameters",
"to",
"the",
"papermill",
"storage",
"folder"
] | def papermill(self, slug, params, rerun: bool = True):
actual_path = self.raw_path()
if rerun is False:
print("Not papermilling, just copying current file")
shutil.copy(self.raw_path(), self.papermill_path(slug))
else:
add_tag_based_on_content(actual_path, "pa... | [
"def",
"papermill",
"(",
"self",
",",
"slug",
",",
"params",
",",
"rerun",
":",
"bool",
"=",
"True",
")",
":",
"actual_path",
"=",
"self",
".",
"raw_path",
"(",
")",
"if",
"rerun",
"is",
"False",
":",
"print",
"(",
"\"Not papermilling, just copying current... | execute the notebook with the parameters
to the papermill storage folder | [
"execute",
"the",
"notebook",
"with",
"the",
"parameters",
"to",
"the",
"papermill",
"storage",
"folder"
] | [
"\"\"\"\n execute the notebook with the parameters\n to the papermill storage folder\n \"\"\"",
"# need bit here that checks the parameters are right"
] | [
{
"param": "self",
"type": null
},
{
"param": "slug",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "rerun",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slug",
"type": null,
"docstring": null,
"docstring_tokens": [... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | rendered_filename | <not_specific> | def rendered_filename(self, slug: str, ext: str = ".md"):
"""
the location the html or file is output to
"""
name = self._parent.name
output_folder = Path("_render", "_parts", name, slug)
if output_folder.exists() is False:
output_folder.mkdir(parents=True)
... |
the location the html or file is output to
| the location the html or file is output to | [
"the",
"location",
"the",
"html",
"or",
"file",
"is",
"output",
"to"
] | def rendered_filename(self, slug: str, ext: str = ".md"):
name = self._parent.name
output_folder = Path("_render", "_parts", name, slug)
if output_folder.exists() is False:
output_folder.mkdir(parents=True)
return output_folder / (self.name + ext) | [
"def",
"rendered_filename",
"(",
"self",
",",
"slug",
":",
"str",
",",
"ext",
":",
"str",
"=",
"\".md\"",
")",
":",
"name",
"=",
"self",
".",
"_parent",
".",
"name",
"output_folder",
"=",
"Path",
"(",
"\"_render\"",
",",
"\"_parts\"",
",",
"name",
",",... | the location the html or file is output to | [
"the",
"location",
"the",
"html",
"or",
"file",
"is",
"output",
"to"
] | [
"\"\"\"\n the location the html or file is output to\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "slug",
"type": "str"
},
{
"param": "ext",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slug",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | render | null | def render(self, slug: str, hide_input: bool = True):
"""
render papermilled version to a file
"""
include_input = not hide_input
input_path = self.papermill_path(slug)
exporters.render_to_markdown(
input_path,
self.rendered_filename(slug, ".md"),
... |
render papermilled version to a file
| render papermilled version to a file | [
"render",
"papermilled",
"version",
"to",
"a",
"file"
] | def render(self, slug: str, hide_input: bool = True):
include_input = not hide_input
input_path = self.papermill_path(slug)
exporters.render_to_markdown(
input_path,
self.rendered_filename(slug, ".md"),
clear_and_execute=False,
include_input=includ... | [
"def",
"render",
"(",
"self",
",",
"slug",
":",
"str",
",",
"hide_input",
":",
"bool",
"=",
"True",
")",
":",
"include_input",
"=",
"not",
"hide_input",
"input_path",
"=",
"self",
".",
"papermill_path",
"(",
"slug",
")",
"exporters",
".",
"render_to_markdo... | render papermilled version to a file | [
"render",
"papermilled",
"version",
"to",
"a",
"file"
] | [
"\"\"\"\n render papermilled version to a file\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "slug",
"type": "str"
},
{
"param": "hide_input",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slug",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | init_rendered_values | null | def init_rendered_values(self, context):
"""
for values that are going to be populated by jinja
this will populate/repopulate based on the currently known context
"""
self._rendered_data = self._data.copy()
for m_path, items in self._data["context"].items():
m... |
for values that are going to be populated by jinja
this will populate/repopulate based on the currently known context
| for values that are going to be populated by jinja
this will populate/repopulate based on the currently known context | [
"for",
"values",
"that",
"are",
"going",
"to",
"be",
"populated",
"by",
"jinja",
"this",
"will",
"populate",
"/",
"repopulate",
"based",
"on",
"the",
"currently",
"known",
"context"
] | def init_rendered_values(self, context):
self._rendered_data = self._data.copy()
for m_path, items in self._data["context"].items():
mod = import_module(m_path)
for i in items:
context[i] = getattr(mod, i)
self.params = self.get_rendered_parameters(context... | [
"def",
"init_rendered_values",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"_rendered_data",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
"for",
"m_path",
",",
"items",
"in",
"self",
".",
"_data",
"[",
"\"context\"",
"]",
".",
"items",
"("... | for values that are going to be populated by jinja
this will populate/repopulate based on the currently known context | [
"for",
"values",
"that",
"are",
"going",
"to",
"be",
"populated",
"by",
"jinja",
"this",
"will",
"populate",
"/",
"repopulate",
"based",
"on",
"the",
"currently",
"known",
"context"
] | [
"\"\"\"\n for values that are going to be populated by jinja\n this will populate/repopulate based on the currently known context\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context",
"type": null,
"docstring": null,
"docstring_tokens"... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | render | null | def render(self, context: Optional[dict] = None):
"""
render the the file through the respective papermills
"""
if context is None:
context = {}
if context:
self.init_rendered_values(context)
slug = self.slug
render_dir = Path("_render"... |
render the the file through the respective papermills
| render the the file through the respective papermills | [
"render",
"the",
"the",
"file",
"through",
"the",
"respective",
"papermills"
] | def render(self, context: Optional[dict] = None):
if context is None:
context = {}
if context:
self.init_rendered_values(context)
slug = self.slug
render_dir = Path("_render", self.name, self.slug)
if render_dir.exists() is False:
render_dir.mk... | [
"def",
"render",
"(",
"self",
",",
"context",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"if",
"context",
":",
"self",
".",
"init_rendered_values",
"(",
"context",
")",
"slu... | render the the file through the respective papermills | [
"render",
"the",
"the",
"file",
"through",
"the",
"respective",
"papermills"
] | [
"\"\"\"\n render the the file through the respective papermills\n \"\"\"",
"# papermill and render individual notebooks",
"# combine for both md and html",
"# copy resources folder",
"# convert to docx"
] | [
{
"param": "self",
"type": null
},
{
"param": "context",
"type": "Optional[dict]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context",
"type": "Optional[dict]",
"docstring": null,
"docst... |
29b82242f7d96cc725378cfee049c1021523b502 | mysociety/notebook_helper | management/render_processing.py | [
"MIT"
] | Python | upload | null | def upload(self):
"""
Upload result to service (gdrive currently)
"""
for k, v in self._data["upload"].items():
if k == "gdrive":
file_name = self._rendered_data["title"]
file_path = self.rendered_filename(".docx")
g_folder_id =... |
Upload result to service (gdrive currently)
| Upload result to service (gdrive currently) | [
"Upload",
"result",
"to",
"service",
"(",
"gdrive",
"currently",
")"
] | def upload(self):
for k, v in self._data["upload"].items():
if k == "gdrive":
file_name = self._rendered_data["title"]
file_path = self.rendered_filename(".docx")
g_folder_id = v["g_folder_id"]
g_drive_id = v["g_drive_id"]
... | [
"def",
"upload",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_data",
"[",
"\"upload\"",
"]",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"\"gdrive\"",
":",
"file_name",
"=",
"self",
".",
"_rendered_data",
"[",
"\"title\"",
"]... | Upload result to service (gdrive currently) | [
"Upload",
"result",
"to",
"service",
"(",
"gdrive",
"currently",
")"
] | [
"\"\"\"\n Upload result to service (gdrive currently)\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | add_labels | <not_specific> | def add_labels(self, labels: Dict[int, Union[str, Tuple[str, str]]]):
"""
Assign labels to clusters
Expects a dictionary of cluster number to label
Label can be a tuple of a label and a longer description
"""
new = copy.deepcopy(self)
for n, label in labels.items... |
Assign labels to clusters
Expects a dictionary of cluster number to label
Label can be a tuple of a label and a longer description
| Assign labels to clusters
Expects a dictionary of cluster number to label
Label can be a tuple of a label and a longer description | [
"Assign",
"labels",
"to",
"clusters",
"Expects",
"a",
"dictionary",
"of",
"cluster",
"number",
"to",
"label",
"Label",
"can",
"be",
"a",
"tuple",
"of",
"a",
"label",
"and",
"a",
"longer",
"description"
] | def add_labels(self, labels: Dict[int, Union[str, Tuple[str, str]]]):
new = copy.deepcopy(self)
for n, label in labels.items():
desc = ""
if isinstance(label, tuple):
desc = label[1]
label = label[0]
new.assign_name(n, label, desc)
... | [
"def",
"add_labels",
"(",
"self",
",",
"labels",
":",
"Dict",
"[",
"int",
",",
"Union",
"[",
"str",
",",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
"]",
")",
":",
"new",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"for",
"n",
",",
"label",
... | Assign labels to clusters
Expects a dictionary of cluster number to label
Label can be a tuple of a label and a longer description | [
"Assign",
"labels",
"to",
"clusters",
"Expects",
"a",
"dictionary",
"of",
"cluster",
"number",
"to",
"label",
"Label",
"can",
"be",
"a",
"tuple",
"of",
"a",
"label",
"and",
"a",
"longer",
"description"
] | [
"\"\"\"\n Assign labels to clusters\n Expects a dictionary of cluster number to label\n Label can be a tuple of a label and a longer description\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "labels",
"type": "Dict[int, Union[str, Tuple[str, str]]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "labels",
"type": "Dict[int, Union[str, Tuple[str, str]]]",
"docstri... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | plot | null | def plot(
self,
limit_columns: Optional[List[str]] = None,
only_one: Optional[Any] = None,
show_legend: bool = True,
):
"""
Plot either all possible x, y graphs for k clusters
or just the subset with the named x_var and y_var.
"""
k = self.k
... |
Plot either all possible x, y graphs for k clusters
or just the subset with the named x_var and y_var.
| Plot either all possible x, y graphs for k clusters
or just the subset with the named x_var and y_var. | [
"Plot",
"either",
"all",
"possible",
"x",
"y",
"graphs",
"for",
"k",
"clusters",
"or",
"just",
"the",
"subset",
"with",
"the",
"named",
"x_var",
"and",
"y_var",
"."
] | def plot(
self,
limit_columns: Optional[List[str]] = None,
only_one: Optional[Any] = None,
show_legend: bool = True,
):
k = self.k
df = self.df
num_rows = 3
vars = self.cols
if limit_columns:
vars = [x for x in vars if x in limit_co... | [
"def",
"plot",
"(",
"self",
",",
"limit_columns",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"only_one",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"show_legend",
":",
"bool",
"=",
"True",
",",
")",
":",
"k",
"... | Plot either all possible x, y graphs for k clusters
or just the subset with the named x_var and y_var. | [
"Plot",
"either",
"all",
"possible",
"x",
"y",
"graphs",
"for",
"k",
"clusters",
"or",
"just",
"the",
"subset",
"with",
"the",
"named",
"x_var",
"and",
"y_var",
"."
] | [
"\"\"\"\n Plot either all possible x, y graphs for k clusters\n or just the subset with the named x_var and y_var.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "limit_columns",
"type": "Optional[List[str]]"
},
{
"param": "only_one",
"type": "Optional[Any]"
},
{
"param": "show_legend",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "limit_columns",
"type": "Optional[List[str]]",
"docstring": null,
... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | _get_clusters | <not_specific> | def _get_clusters(self, k: int):
"""
fetch k means results for this cluster
"""
km = KMeans(n_clusters=k, random_state=self.default_seed)
return km.fit(self.df) |
fetch k means results for this cluster
| fetch k means results for this cluster | [
"fetch",
"k",
"means",
"results",
"for",
"this",
"cluster"
] | def _get_clusters(self, k: int):
km = KMeans(n_clusters=k, random_state=self.default_seed)
return km.fit(self.df) | [
"def",
"_get_clusters",
"(",
"self",
",",
"k",
":",
"int",
")",
":",
"km",
"=",
"KMeans",
"(",
"n_clusters",
"=",
"k",
",",
"random_state",
"=",
"self",
".",
"default_seed",
")",
"return",
"km",
".",
"fit",
"(",
"self",
".",
"df",
")"
] | fetch k means results for this cluster | [
"fetch",
"k",
"means",
"results",
"for",
"this",
"cluster"
] | [
"\"\"\"\n fetch k means results for this cluster\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "k",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "k",
"type": "int",
"docstring": null,
"docstring_tokens": [],... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | find_k | <not_specific> | def find_k(self, start: int = 15, stop: Optional[int] = None, step: int = 1):
"""
Graph the elbow and Silhouette method for finding the optimal k.
High silhouette value good.
Parameters are the search space.
"""
if start and not stop:
stop = start
... |
Graph the elbow and Silhouette method for finding the optimal k.
High silhouette value good.
Parameters are the search space.
| Graph the elbow and Silhouette method for finding the optimal k.
High silhouette value good.
Parameters are the search space. | [
"Graph",
"the",
"elbow",
"and",
"Silhouette",
"method",
"for",
"finding",
"the",
"optimal",
"k",
".",
"High",
"silhouette",
"value",
"good",
".",
"Parameters",
"are",
"the",
"search",
"space",
"."
] | def find_k(self, start: int = 15, stop: Optional[int] = None, step: int = 1):
if start and not stop:
stop = start
start = 2
def s_score(kmeans):
return silhouette_score(self.df, kmeans.labels_, metric="euclidean")
df = pd.DataFrame({"n": range(start, stop, ste... | [
"def",
"find_k",
"(",
"self",
",",
"start",
":",
"int",
"=",
"15",
",",
"stop",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"step",
":",
"int",
"=",
"1",
")",
":",
"if",
"start",
"and",
"not",
"stop",
":",
"stop",
"=",
"start",
"start",... | Graph the elbow and Silhouette method for finding the optimal k.
High silhouette value good. | [
"Graph",
"the",
"elbow",
"and",
"Silhouette",
"method",
"for",
"finding",
"the",
"optimal",
"k",
".",
"High",
"silhouette",
"value",
"good",
"."
] | [
"\"\"\"\n Graph the elbow and Silhouette method for finding the optimal k.\n High silhouette value good.\n Parameters are the search space.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "start",
"type": "int"
},
{
"param": "stop",
"type": "Optional[int]"
},
{
"param": "step",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start",
"type": "int",
"docstring": null,
"docstring_tokens":... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | raincloud | null | def raincloud(
self,
column: str,
one_value: Optional[str] = None,
groups: Optional[str] = "Cluster",
use_source: bool = True,
):
"""
raincloud plot of a variable, grouped by different clusters
"""
k = self.k
if use_source:
... |
raincloud plot of a variable, grouped by different clusters
| raincloud plot of a variable, grouped by different clusters | [
"raincloud",
"plot",
"of",
"a",
"variable",
"grouped",
"by",
"different",
"clusters"
] | def raincloud(
self,
column: str,
one_value: Optional[str] = None,
groups: Optional[str] = "Cluster",
use_source: bool = True,
):
k = self.k
if use_source:
df = self.source_df.copy()
else:
df = self.df
df["Cluster"] = se... | [
"def",
"raincloud",
"(",
"self",
",",
"column",
":",
"str",
",",
"one_value",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"groups",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"Cluster\"",
",",
"use_source",
":",
"bool",
"=",
"True",
",",
")",
... | raincloud plot of a variable, grouped by different clusters | [
"raincloud",
"plot",
"of",
"a",
"variable",
"grouped",
"by",
"different",
"clusters"
] | [
"\"\"\"\n raincloud plot of a variable, grouped by different clusters\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "column",
"type": "str"
},
{
"param": "one_value",
"type": "Optional[str]"
},
{
"param": "groups",
"type": "Optional[str]"
},
{
"param": "use_source",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "column",
"type": "str",
"docstring": null,
"docstring_tokens"... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | reverse_raincloud | null | def reverse_raincloud(self, cluster_label: str):
"""
Raincloud plot for a single cluster showing the
distribution of different variables
"""
df = self.df.copy()
df["Cluster"] = self.get_cluster_labels()
df = df.melt("Cluster")[lambda df: ~(df["variable"] == " ")]
... |
Raincloud plot for a single cluster showing the
distribution of different variables
| Raincloud plot for a single cluster showing the
distribution of different variables | [
"Raincloud",
"plot",
"for",
"a",
"single",
"cluster",
"showing",
"the",
"distribution",
"of",
"different",
"variables"
] | def reverse_raincloud(self, cluster_label: str):
df = self.df.copy()
df["Cluster"] = self.get_cluster_labels()
df = df.melt("Cluster")[lambda df: ~(df["variable"] == " ")]
df["value"] = df["value"].astype(float)
df = df[lambda df: (df["Cluster"] == cluster_label)]
df.viz.... | [
"def",
"reverse_raincloud",
"(",
"self",
",",
"cluster_label",
":",
"str",
")",
":",
"df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"df",
"[",
"\"Cluster\"",
"]",
"=",
"self",
".",
"get_cluster_labels",
"(",
")",
"df",
"=",
"df",
".",
"melt",
... | Raincloud plot for a single cluster showing the
distribution of different variables | [
"Raincloud",
"plot",
"for",
"a",
"single",
"cluster",
"showing",
"the",
"distribution",
"of",
"different",
"variables"
] | [
"\"\"\"\n Raincloud plot for a single cluster showing the\n distribution of different variables\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "cluster_label",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cluster_label",
"type": "str",
"docstring": null,
"docstring_... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | reverse_raincloud_tool | null | def reverse_raincloud_tool(self):
"""
Raincloud tool to examine clusters showing the
distribution of different variables
"""
tool = interactive(
self.reverse_raincloud, cluster_label=self.get_label_options()
)
display(tool) |
Raincloud tool to examine clusters showing the
distribution of different variables
| Raincloud tool to examine clusters showing the
distribution of different variables | [
"Raincloud",
"tool",
"to",
"examine",
"clusters",
"showing",
"the",
"distribution",
"of",
"different",
"variables"
] | def reverse_raincloud_tool(self):
tool = interactive(
self.reverse_raincloud, cluster_label=self.get_label_options()
)
display(tool) | [
"def",
"reverse_raincloud_tool",
"(",
"self",
")",
":",
"tool",
"=",
"interactive",
"(",
"self",
".",
"reverse_raincloud",
",",
"cluster_label",
"=",
"self",
".",
"get_label_options",
"(",
")",
")",
"display",
"(",
"tool",
")"
] | Raincloud tool to examine clusters showing the
distribution of different variables | [
"Raincloud",
"tool",
"to",
"examine",
"clusters",
"showing",
"the",
"distribution",
"of",
"different",
"variables"
] | [
"\"\"\"\n Raincloud tool to examine clusters showing the\n distribution of different variables\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | raincloud_tool | <not_specific> | def raincloud_tool(self, reverse: bool = False):
"""
Raincloud tool to examine variables showing the
distribution of different clusters
The reverse option flips this.
"""
if reverse:
return self.reverse_raincloud_tool()
def func(variable, comparison, ... |
Raincloud tool to examine variables showing the
distribution of different clusters
The reverse option flips this.
| Raincloud tool to examine variables showing the
distribution of different clusters
The reverse option flips this. | [
"Raincloud",
"tool",
"to",
"examine",
"variables",
"showing",
"the",
"distribution",
"of",
"different",
"clusters",
"The",
"reverse",
"option",
"flips",
"this",
"."
] | def raincloud_tool(self, reverse: bool = False):
if reverse:
return self.reverse_raincloud_tool()
def func(variable, comparison, use_source_values):
groups = "Cluster"
if comparison == "all":
comparison = None
if comparison == "none":
... | [
"def",
"raincloud_tool",
"(",
"self",
",",
"reverse",
":",
"bool",
"=",
"False",
")",
":",
"if",
"reverse",
":",
"return",
"self",
".",
"reverse_raincloud_tool",
"(",
")",
"def",
"func",
"(",
"variable",
",",
"comparison",
",",
"use_source_values",
")",
":... | Raincloud tool to examine variables showing the
distribution of different clusters
The reverse option flips this. | [
"Raincloud",
"tool",
"to",
"examine",
"variables",
"showing",
"the",
"distribution",
"of",
"different",
"clusters",
"The",
"reverse",
"option",
"flips",
"this",
"."
] | [
"\"\"\"\n Raincloud tool to examine variables showing the\n distribution of different clusters\n The reverse option flips this.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reverse",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reverse",
"type": "bool",
"docstring": null,
"docstring_token... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | label_tool | <not_specific> | def label_tool(self):
"""
tool to review how labels assigned for each cluster
"""
k = self.k
def func(cluster, sort, include_data_labels):
if sort == "Index":
sort = None
df = self.label_review(
label=cluster, sort=sort, i... |
tool to review how labels assigned for each cluster
| tool to review how labels assigned for each cluster | [
"tool",
"to",
"review",
"how",
"labels",
"assigned",
"for",
"each",
"cluster"
] | def label_tool(self):
k = self.k
def func(cluster, sort, include_data_labels):
if sort == "Index":
sort = None
df = self.label_review(
label=cluster, sort=sort, include_data=include_data_labels
)
display(df)
retu... | [
"def",
"label_tool",
"(",
"self",
")",
":",
"k",
"=",
"self",
".",
"k",
"def",
"func",
"(",
"cluster",
",",
"sort",
",",
"include_data_labels",
")",
":",
"if",
"sort",
"==",
"\"Index\"",
":",
"sort",
"=",
"None",
"df",
"=",
"self",
".",
"label_review... | tool to review how labels assigned for each cluster | [
"tool",
"to",
"review",
"how",
"labels",
"assigned",
"for",
"each",
"cluster"
] | [
"\"\"\"\n tool to review how labels assigned for each cluster\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | label_review | <not_specific> | def label_review(
self,
label: Optional[int] = 1,
sort: Optional[str] = None,
include_data: bool = True,
):
"""
Review labeled data for a cluster
"""
k = self.k
def to_count_pivot(df):
mdf = df.drop(columns=["label"]).melt()
... |
Review labeled data for a cluster
| Review labeled data for a cluster | [
"Review",
"labeled",
"data",
"for",
"a",
"cluster"
] | def label_review(
self,
label: Optional[int] = 1,
sort: Optional[str] = None,
include_data: bool = True,
):
k = self.k
def to_count_pivot(df):
mdf = df.drop(columns=["label"]).melt()
mdf["Count"] = mdf["variable"] + mdf["value"]
ret... | [
"def",
"label_review",
"(",
"self",
",",
"label",
":",
"Optional",
"[",
"int",
"]",
"=",
"1",
",",
"sort",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"include_data",
":",
"bool",
"=",
"True",
",",
")",
":",
"k",
"=",
"self",
".",
"k",
... | Review labeled data for a cluster | [
"Review",
"labeled",
"data",
"for",
"a",
"cluster"
] | [
"\"\"\"\n Review labeled data for a cluster\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "label",
"type": "Optional[int]"
},
{
"param": "sort",
"type": "Optional[str]"
},
{
"param": "include_data",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "label",
"type": "Optional[int]",
"docstring": null,
"docstrin... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | _axis_label | str | def _axis_label(self, label_txt: str) -> str:
"""
Extend axis label with extra notes
"""
txt = label_txt
if self.normalize:
txt = txt + " (normalized)"
return txt |
Extend axis label with extra notes
| Extend axis label with extra notes | [
"Extend",
"axis",
"label",
"with",
"extra",
"notes"
] | def _axis_label(self, label_txt: str) -> str:
txt = label_txt
if self.normalize:
txt = txt + " (normalized)"
return txt | [
"def",
"_axis_label",
"(",
"self",
",",
"label_txt",
":",
"str",
")",
"->",
"str",
":",
"txt",
"=",
"label_txt",
"if",
"self",
".",
"normalize",
":",
"txt",
"=",
"txt",
"+",
"\" (normalized)\"",
"return",
"txt"
] | Extend axis label with extra notes | [
"Extend",
"axis",
"label",
"with",
"extra",
"notes"
] | [
"\"\"\"\n Extend axis label with extra notes\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "label_txt",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "label_txt",
"type": "str",
"docstring": null,
"docstring_toke... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | df_with_labels | pd.DataFrame | def df_with_labels(self) -> pd.DataFrame:
"""
return the original df but with a label column attached
"""
k = self.k
df = self.source_df.copy()
df["label"] = self.get_cluster_labels(include_short=False)
df["label_id"] = self.get_cluster_label_ids()
df["lab... |
return the original df but with a label column attached
| return the original df but with a label column attached | [
"return",
"the",
"original",
"df",
"but",
"with",
"a",
"label",
"column",
"attached"
] | def df_with_labels(self) -> pd.DataFrame:
k = self.k
df = self.source_df.copy()
df["label"] = self.get_cluster_labels(include_short=False)
df["label_id"] = self.get_cluster_label_ids()
df["label_desc"] = self.get_cluster_descs()
return df | [
"def",
"df_with_labels",
"(",
"self",
")",
"->",
"pd",
".",
"DataFrame",
":",
"k",
"=",
"self",
".",
"k",
"df",
"=",
"self",
".",
"source_df",
".",
"copy",
"(",
")",
"df",
"[",
"\"label\"",
"]",
"=",
"self",
".",
"get_cluster_labels",
"(",
"include_s... | return the original df but with a label column attached | [
"return",
"the",
"original",
"df",
"but",
"with",
"a",
"label",
"column",
"attached"
] | [
"\"\"\"\n return the original df but with a label column attached\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | plot3d | null | def plot3d(
self,
x_var: Optional[str] = None,
y_var: Optional[str] = None,
z_var: Optional[str] = None,
):
k = self.k
"""
Plot either all possible x, y, z graphs for k clusters
or just the subset with the named x_var and y_var.
"""
df ... |
Plot either all possible x, y, z graphs for k clusters
or just the subset with the named x_var and y_var.
| Plot either all possible x, y, z graphs for k clusters
or just the subset with the named x_var and y_var. | [
"Plot",
"either",
"all",
"possible",
"x",
"y",
"z",
"graphs",
"for",
"k",
"clusters",
"or",
"just",
"the",
"subset",
"with",
"the",
"named",
"x_var",
"and",
"y_var",
"."
] | def plot3d(
self,
x_var: Optional[str] = None,
y_var: Optional[str] = None,
z_var: Optional[str] = None,
):
k = self.k
df = self.df
labels = self.get_cluster_labels()
combos = list(combinations(df.columns, 3))
if x_var:
combos = [x ... | [
"def",
"plot3d",
"(",
"self",
",",
"x_var",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"y_var",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"z_var",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
":",
"k",
"=",
"self"... | Plot either all possible x, y, z graphs for k clusters
or just the subset with the named x_var and y_var. | [
"Plot",
"either",
"all",
"possible",
"x",
"y",
"z",
"graphs",
"for",
"k",
"clusters",
"or",
"just",
"the",
"subset",
"with",
"the",
"named",
"x_var",
"and",
"y_var",
"."
] | [
"\"\"\"\n Plot either all possible x, y, z graphs for k clusters\n or just the subset with the named x_var and y_var.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x_var",
"type": "Optional[str]"
},
{
"param": "y_var",
"type": "Optional[str]"
},
{
"param": "z_var",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x_var",
"type": "Optional[str]",
"docstring": null,
"docstrin... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | join_distance | pd.DataFrame | def join_distance(df_label_dict: Dict[str, pd.DataFrame]) -> pd.DataFrame:
"""
Expects the results of df.space.self_distance to be put into
the dataframes in the input
Will merge multiple kinds of distance into a common dataframe
the str in the dictionary it expects is the label for the column
"... |
Expects the results of df.space.self_distance to be put into
the dataframes in the input
Will merge multiple kinds of distance into a common dataframe
the str in the dictionary it expects is the label for the column
| Expects the results of df.space.self_distance to be put into
the dataframes in the input
Will merge multiple kinds of distance into a common dataframe
the str in the dictionary it expects is the label for the column | [
"Expects",
"the",
"results",
"of",
"df",
".",
"space",
".",
"self_distance",
"to",
"be",
"put",
"into",
"the",
"dataframes",
"in",
"the",
"input",
"Will",
"merge",
"multiple",
"kinds",
"of",
"distance",
"into",
"a",
"common",
"dataframe",
"the",
"str",
"in... | def join_distance(df_label_dict: Dict[str, pd.DataFrame]) -> pd.DataFrame:
def prepare(df, label):
return (
df.set_index(list(df.columns[:2]))
.rename(columns={"distance": label})
.drop(columns=["match", "position"], errors="ignore")
)
to_join = [prepare(df, l... | [
"def",
"join_distance",
"(",
"df_label_dict",
":",
"Dict",
"[",
"str",
",",
"pd",
".",
"DataFrame",
"]",
")",
"->",
"pd",
".",
"DataFrame",
":",
"def",
"prepare",
"(",
"df",
",",
"label",
")",
":",
"return",
"(",
"df",
".",
"set_index",
"(",
"list",
... | Expects the results of df.space.self_distance to be put into
the dataframes in the input
Will merge multiple kinds of distance into a common dataframe
the str in the dictionary it expects is the label for the column | [
"Expects",
"the",
"results",
"of",
"df",
".",
"space",
".",
"self_distance",
"to",
"be",
"put",
"into",
"the",
"dataframes",
"in",
"the",
"input",
"Will",
"merge",
"multiple",
"kinds",
"of",
"distance",
"into",
"a",
"common",
"dataframe",
"the",
"str",
"in... | [
"\"\"\"\n Expects the results of df.space.self_distance to be put into\n the dataframes in the input\n Will merge multiple kinds of distance into a common dataframe\n the str in the dictionary it expects is the label for the column\n \"\"\""
] | [
{
"param": "df_label_dict",
"type": "Dict[str, pd.DataFrame]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df_label_dict",
"type": "Dict[str, pd.DataFrame]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | cluster | Cluster | def cluster(
self,
id_col: Optional[str] = None,
cols: Optional[List[str]] = None,
label_cols: Optional[List[str]] = None,
normalize: bool = True,
transform: List[Callable] = None,
k: Optional[int] = None,
) -> Cluster:
"""
returns a Cluster he... |
returns a Cluster helper object for this dataframe
| returns a Cluster helper object for this dataframe | [
"returns",
"a",
"Cluster",
"helper",
"object",
"for",
"this",
"dataframe"
] | def cluster(
self,
id_col: Optional[str] = None,
cols: Optional[List[str]] = None,
label_cols: Optional[List[str]] = None,
normalize: bool = True,
transform: List[Callable] = None,
k: Optional[int] = None,
) -> Cluster:
return Cluster(
self... | [
"def",
"cluster",
"(",
"self",
",",
"id_col",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"cols",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"label_cols",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",... | returns a Cluster helper object for this dataframe | [
"returns",
"a",
"Cluster",
"helper",
"object",
"for",
"this",
"dataframe"
] | [
"\"\"\"\n returns a Cluster helper object for this dataframe\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id_col",
"type": "Optional[str]"
},
{
"param": "cols",
"type": "Optional[List[str]]"
},
{
"param": "label_cols",
"type": "Optional[List[str]]"
},
{
"param": "normalize",
"type": "bool"
},
{
"param": "trans... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_col",
"type": "Optional[str]",
"docstring": null,
"docstri... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | self_distance | <not_specific> | def self_distance(
self,
id_col: Optional[str] = None,
cols: Optional[List] = None,
normalize: bool = False,
transform: List[callable] = None,
):
"""
Calculate the distance between all objects in a dataframe
in an n-dimensional space.
get back ... |
Calculate the distance between all objects in a dataframe
in an n-dimensional space.
get back a dataframe with two labelled columns as well as the
distance.
id_col : unique column containing an ID or similar
cols: all columns to be used in the calculation of distance
... | Calculate the distance between all objects in a dataframe
in an n-dimensional space.
get back a dataframe with two labelled columns as well as the
distance.
id_col : unique column containing an ID or similar
cols: all columns to be used in the calculation of distance
normalize: should these columns be normalised before... | [
"Calculate",
"the",
"distance",
"between",
"all",
"objects",
"in",
"a",
"dataframe",
"in",
"an",
"n",
"-",
"dimensional",
"space",
".",
"get",
"back",
"a",
"dataframe",
"with",
"two",
"labelled",
"columns",
"as",
"well",
"as",
"the",
"distance",
".",
"id_c... | def self_distance(
self,
id_col: Optional[str] = None,
cols: Optional[List] = None,
normalize: bool = False,
transform: List[callable] = None,
):
source_df = self._obj
if id_col == None:
id_col = source_df.index.name
source_df = source_... | [
"def",
"self_distance",
"(",
"self",
",",
"id_col",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"cols",
":",
"Optional",
"[",
"List",
"]",
"=",
"None",
",",
"normalize",
":",
"bool",
"=",
"False",
",",
"transform",
":",
"List",
"[",
"callable... | Calculate the distance between all objects in a dataframe
in an n-dimensional space. | [
"Calculate",
"the",
"distance",
"between",
"all",
"objects",
"in",
"a",
"dataframe",
"in",
"an",
"n",
"-",
"dimensional",
"space",
"."
] | [
"\"\"\"\n Calculate the distance between all objects in a dataframe\n in an n-dimensional space.\n get back a dataframe with two labelled columns as well as the\n distance.\n id_col : unique column containing an ID or similar\n cols: all columns to be used in the calculatio... | [
{
"param": "self",
"type": null
},
{
"param": "id_col",
"type": "Optional[str]"
},
{
"param": "cols",
"type": "Optional[List]"
},
{
"param": "normalize",
"type": "bool"
},
{
"param": "transform",
"type": "List[callable]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_col",
"type": "Optional[str]",
"docstring": null,
"docstri... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | join_distance | <not_specific> | def join_distance(
self,
other: Union[Dict[str, pd.DataFrame], pd.DataFrame],
our_label: Optional[str] = "A",
their_label: Optional[str] = "B",
):
"""
Either merges self and other
(both of whichs hould be the result of
space.self_distance)
or a... |
Either merges self and other
(both of whichs hould be the result of
space.self_distance)
or a dictionary of dataframes and labels
not including the current dataframe.
| Either merges self and other
(both of whichs hould be the result of
space.self_distance)
or a dictionary of dataframes and labels
not including the current dataframe. | [
"Either",
"merges",
"self",
"and",
"other",
"(",
"both",
"of",
"whichs",
"hould",
"be",
"the",
"result",
"of",
"space",
".",
"self_distance",
")",
"or",
"a",
"dictionary",
"of",
"dataframes",
"and",
"labels",
"not",
"including",
"the",
"current",
"dataframe"... | def join_distance(
self,
other: Union[Dict[str, pd.DataFrame], pd.DataFrame],
our_label: Optional[str] = "A",
their_label: Optional[str] = "B",
):
if not isinstance(other, dict):
df_label_dict = {our_label: self._obj, their_label: other}
else:
... | [
"def",
"join_distance",
"(",
"self",
",",
"other",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"pd",
".",
"DataFrame",
"]",
",",
"pd",
".",
"DataFrame",
"]",
",",
"our_label",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"A\"",
",",
"their_label",
":",
... | Either merges self and other
(both of whichs hould be the result of
space.self_distance)
or a dictionary of dataframes and labels
not including the current dataframe. | [
"Either",
"merges",
"self",
"and",
"other",
"(",
"both",
"of",
"whichs",
"hould",
"be",
"the",
"result",
"of",
"space",
".",
"self_distance",
")",
"or",
"a",
"dictionary",
"of",
"dataframes",
"and",
"labels",
"not",
"including",
"the",
"current",
"dataframe"... | [
"\"\"\"\n Either merges self and other\n (both of whichs hould be the result of\n space.self_distance)\n or a dictionary of dataframes and labels\n not including the current dataframe.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "other",
"type": "Union[Dict[str, pd.DataFrame], pd.DataFrame]"
},
{
"param": "our_label",
"type": "Optional[str]"
},
{
"param": "their_label",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "other",
"type": "Union[Dict[str, pd.DataFrame], pd.DataFrame]",
"do... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | match_distance | <not_specific> | def match_distance(self):
"""
add a match percentage column where the tenth most distance is a 0% match
and 0 distance is an 100% match.
"""
df = self._obj
def standardise_distance(df):
df = df.copy()
# use tenth from last because the last point m... |
add a match percentage column where the tenth most distance is a 0% match
and 0 distance is an 100% match.
| add a match percentage column where the tenth most distance is a 0% match
and 0 distance is an 100% match. | [
"add",
"a",
"match",
"percentage",
"column",
"where",
"the",
"tenth",
"most",
"distance",
"is",
"a",
"0%",
"match",
"and",
"0",
"distance",
"is",
"an",
"100%",
"match",
"."
] | def match_distance(self):
df = self._obj
def standardise_distance(df):
df = df.copy()
tenth_from_last_score = df["distance"].sort_values().tail(10).iloc[0]
df["match"] = 1 - (df["distance"] / tenth_from_last_score)
df["match"] = df["match"].round(3) * 100
... | [
"def",
"match_distance",
"(",
"self",
")",
":",
"df",
"=",
"self",
".",
"_obj",
"def",
"standardise_distance",
"(",
"df",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"tenth_from_last_score",
"=",
"df",
"[",
"\"distance\"",
"]",
".",
"sort_values",
... | add a match percentage column where the tenth most distance is a 0% match
and 0 distance is an 100% match. | [
"add",
"a",
"match",
"percentage",
"column",
"where",
"the",
"tenth",
"most",
"distance",
"is",
"a",
"0%",
"match",
"and",
"0",
"distance",
"is",
"an",
"100%",
"match",
"."
] | [
"\"\"\"\n add a match percentage column where the tenth most distance is a 0% match\n and 0 distance is an 100% match.\n \"\"\"",
"# use tenth from last because the last point might be an extreme outlier (in this case london)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | local_rankings | <not_specific> | def local_rankings(self):
"""
add a position column that indicates the relative similarity based on distance
"""
df = self._obj
def get_position(df):
df["position"] = df["distance"].rank(method="first")
return df
return (
df.groupby(d... |
add a position column that indicates the relative similarity based on distance
| add a position column that indicates the relative similarity based on distance | [
"add",
"a",
"position",
"column",
"that",
"indicates",
"the",
"relative",
"similarity",
"based",
"on",
"distance"
] | def local_rankings(self):
df = self._obj
def get_position(df):
df["position"] = df["distance"].rank(method="first")
return df
return (
df.groupby(df.columns[0], as_index=False)
.apply(get_position)
.reset_index(drop=True)
) | [
"def",
"local_rankings",
"(",
"self",
")",
":",
"df",
"=",
"self",
".",
"_obj",
"def",
"get_position",
"(",
"df",
")",
":",
"df",
"[",
"\"position\"",
"]",
"=",
"df",
"[",
"\"distance\"",
"]",
".",
"rank",
"(",
"method",
"=",
"\"first\"",
")",
"retur... | add a position column that indicates the relative similarity based on distance | [
"add",
"a",
"position",
"column",
"that",
"indicates",
"the",
"relative",
"similarity",
"based",
"on",
"distance"
] | [
"\"\"\"\n add a position column that indicates the relative similarity based on distance\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | composite_distance | <not_specific> | def composite_distance(self, normalize: bool = False):
"""
Given all distances in joint space,
calculate a composite.
Set normalize to true to scale all distances between 0 and 1
Shouldn't be needed where a product of previous rounds of normalization
A scale factor of 2 f... |
Given all distances in joint space,
calculate a composite.
Set normalize to true to scale all distances between 0 and 1
Shouldn't be needed where a product of previous rounds of normalization
A scale factor of 2 for a column reduces distances by half
| Given all distances in joint space,
calculate a composite.
Set normalize to true to scale all distances between 0 and 1
Shouldn't be needed where a product of previous rounds of normalization
A scale factor of 2 for a column reduces distances by half | [
"Given",
"all",
"distances",
"in",
"joint",
"space",
"calculate",
"a",
"composite",
".",
"Set",
"normalize",
"to",
"true",
"to",
"scale",
"all",
"distances",
"between",
"0",
"and",
"1",
"Shouldn",
"'",
"t",
"be",
"needed",
"where",
"a",
"product",
"of",
... | def composite_distance(self, normalize: bool = False):
df = self._obj.copy()
def normalize_series(s: pd.Series):
return s / s.max()
cols = df.columns[2:]
cols = [df[x] for x in cols]
if normalize:
cols = [normalize_series(x) for x in cols]
squared_... | [
"def",
"composite_distance",
"(",
"self",
",",
"normalize",
":",
"bool",
"=",
"False",
")",
":",
"df",
"=",
"self",
".",
"_obj",
".",
"copy",
"(",
")",
"def",
"normalize_series",
"(",
"s",
":",
"pd",
".",
"Series",
")",
":",
"return",
"s",
"/",
"s"... | Given all distances in joint space,
calculate a composite. | [
"Given",
"all",
"distances",
"in",
"joint",
"space",
"calculate",
"a",
"composite",
"."
] | [
"\"\"\"\n Given all distances in joint space,\n calculate a composite.\n Set normalize to true to scale all distances between 0 and 1\n Shouldn't be needed where a product of previous rounds of normalization\n A scale factor of 2 for a column reduces distances by half\n \"\... | [
{
"param": "self",
"type": null
},
{
"param": "normalize",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "normalize",
"type": "bool",
"docstring": null,
"docstring_tok... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | same_nearest_k | <not_specific> | def same_nearest_k(self, k: int = 5):
"""
Expects the dataframe returned by `join_distance`.
Groups by column 1, Expects first two columns to be id columns.
Beyond that, will see if all columns (representing distances)
have the same items
in their lowest 'k' matches.
... |
Expects the dataframe returned by `join_distance`.
Groups by column 1, Expects first two columns to be id columns.
Beyond that, will see if all columns (representing distances)
have the same items
in their lowest 'k' matches.
Returns a column that can be averaged to get ... | Expects the dataframe returned by `join_distance`.
Groups by column 1, Expects first two columns to be id columns.
Beyond that, will see if all columns (representing distances)
have the same items
in their lowest 'k' matches.
Returns a column that can be averaged to get the overlap between
two metrics. | [
"Expects",
"the",
"dataframe",
"returned",
"by",
"`",
"join_distance",
"`",
".",
"Groups",
"by",
"column",
"1",
"Expects",
"first",
"two",
"columns",
"to",
"be",
"id",
"columns",
".",
"Beyond",
"that",
"will",
"see",
"if",
"all",
"columns",
"(",
"represent... | def same_nearest_k(self, k: int = 5):
df = self._obj
def top_k(df, k=5):
df = df.set_index(list(df.columns[:2])).rank()
df = df <= k
same_rank = df.sum(axis=1).reset_index(drop=True) == len(list(df.columns))
data = [[same_rank.sum() / k]]
d = p... | [
"def",
"same_nearest_k",
"(",
"self",
",",
"k",
":",
"int",
"=",
"5",
")",
":",
"df",
"=",
"self",
".",
"_obj",
"def",
"top_k",
"(",
"df",
",",
"k",
"=",
"5",
")",
":",
"df",
"=",
"df",
".",
"set_index",
"(",
"list",
"(",
"df",
".",
"columns"... | Expects the dataframe returned by `join_distance`. | [
"Expects",
"the",
"dataframe",
"returned",
"by",
"`",
"join_distance",
"`",
"."
] | [
"\"\"\"\n Expects the dataframe returned by `join_distance`.\n Groups by column 1, Expects first two columns to be id columns.\n Beyond that, will see if all columns (representing distances)\n have the same items\n in their lowest 'k' matches.\n Returns a column that can be... | [
{
"param": "self",
"type": null
},
{
"param": "k",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "k",
"type": "int",
"docstring": null,
"docstring_tokens": [],... |
60ab533bf1d25168bba4d4c38d95d4de155f1f67 | mysociety/notebook_helper | df_extensions/space.py | [
"MIT"
] | Python | agreement | <not_specific> | def agreement(self, ks: List[int] = [1, 2, 3, 5, 10, 25]):
"""
Given the result of 'join_distance' explore how similar
items fall in 'top_k' for a range of values of k.
"""
df = self._obj
def get_average(k):
return df.joint_space.same_nearest_k(k=k).mean().r... |
Given the result of 'join_distance' explore how similar
items fall in 'top_k' for a range of values of k.
| Given the result of 'join_distance' explore how similar
items fall in 'top_k' for a range of values of k. | [
"Given",
"the",
"result",
"of",
"'",
"join_distance",
"'",
"explore",
"how",
"similar",
"items",
"fall",
"in",
"'",
"top_k",
"'",
"for",
"a",
"range",
"of",
"values",
"of",
"k",
"."
] | def agreement(self, ks: List[int] = [1, 2, 3, 5, 10, 25]):
df = self._obj
def get_average(k):
return df.joint_space.same_nearest_k(k=k).mean().round(2)[0]
r = pd.DataFrame({"top_k": ks})
r["agreement"] = r["top_k"].apply(get_average)
return r | [
"def",
"agreement",
"(",
"self",
",",
"ks",
":",
"List",
"[",
"int",
"]",
"=",
"[",
"1",
",",
"2",
",",
"3",
",",
"5",
",",
"10",
",",
"25",
"]",
")",
":",
"df",
"=",
"self",
".",
"_obj",
"def",
"get_average",
"(",
"k",
")",
":",
"return",
... | Given the result of 'join_distance' explore how similar
items fall in 'top_k' for a range of values of k. | [
"Given",
"the",
"result",
"of",
"'",
"join_distance",
"'",
"explore",
"how",
"similar",
"items",
"fall",
"in",
"'",
"top_k",
"'",
"for",
"a",
"range",
"of",
"values",
"of",
"k",
"."
] | [
"\"\"\"\n Given the result of 'join_distance' explore how similar\n items fall in 'top_k' for a range of values of k.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ks",
"type": "List[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ks",
"type": "List[int]",
"docstring": null,
"docstring_token... |
ba647b0d5ba20c44679a8e0c539905267479e514 | mysociety/notebook_helper | management/upload.py | [
"MIT"
] | Python | upload_file | <not_specific> | def upload_file(file_name, file_path, g_folder_id, g_drive_id):
"""
upload file to Climate Emergency metrics folder
"""
api = DriveIntegration(settings["GOOGLE_CLIENT_JSON"])
print("uploading document to drive")
url = api.upload_file(file_name, file_path, g_folder_id, g_drive_id)
print(url)... |
upload file to Climate Emergency metrics folder
| upload file to Climate Emergency metrics folder | [
"upload",
"file",
"to",
"Climate",
"Emergency",
"metrics",
"folder"
] | def upload_file(file_name, file_path, g_folder_id, g_drive_id):
api = DriveIntegration(settings["GOOGLE_CLIENT_JSON"])
print("uploading document to drive")
url = api.upload_file(file_name, file_path, g_folder_id, g_drive_id)
print(url)
return url | [
"def",
"upload_file",
"(",
"file_name",
",",
"file_path",
",",
"g_folder_id",
",",
"g_drive_id",
")",
":",
"api",
"=",
"DriveIntegration",
"(",
"settings",
"[",
"\"GOOGLE_CLIENT_JSON\"",
"]",
")",
"print",
"(",
"\"uploading document to drive\"",
")",
"url",
"=",
... | upload file to Climate Emergency metrics folder | [
"upload",
"file",
"to",
"Climate",
"Emergency",
"metrics",
"folder"
] | [
"\"\"\"\n upload file to Climate Emergency metrics folder\n \"\"\""
] | [
{
"param": "file_name",
"type": null
},
{
"param": "file_path",
"type": null
},
{
"param": "g_folder_id",
"type": null
},
{
"param": "g_drive_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_path",
"type": null,
"docstring": null,
"docstring_... |
ba647b0d5ba20c44679a8e0c539905267479e514 | mysociety/notebook_helper | management/upload.py | [
"MIT"
] | Python | format_document | null | def format_document(url):
"""
Apply google sheets formatter to URL
"""
api = ScriptIntergration(settings["GOOGLE_CLIENT_JSON"])
script_id = (
"AKfycbwjKpOgzKaDHahyn-7If0LzMhaNfMTTsiHf6nvgL2gaaVsgI_VvuZjHJWAzRaehENLX"
)
func = api.get_function(script_id, "formatWordURL")
print("fo... |
Apply google sheets formatter to URL
| Apply google sheets formatter to URL | [
"Apply",
"google",
"sheets",
"formatter",
"to",
"URL"
] | def format_document(url):
api = ScriptIntergration(settings["GOOGLE_CLIENT_JSON"])
script_id = (
"AKfycbwjKpOgzKaDHahyn-7If0LzMhaNfMTTsiHf6nvgL2gaaVsgI_VvuZjHJWAzRaehENLX"
)
func = api.get_function(script_id, "formatWordURL")
print("formatting document, this may take a few minutes")
v = ... | [
"def",
"format_document",
"(",
"url",
")",
":",
"api",
"=",
"ScriptIntergration",
"(",
"settings",
"[",
"\"GOOGLE_CLIENT_JSON\"",
"]",
")",
"script_id",
"=",
"(",
"\"AKfycbwjKpOgzKaDHahyn-7If0LzMhaNfMTTsiHf6nvgL2gaaVsgI_VvuZjHJWAzRaehENLX\"",
")",
"func",
"=",
"api",
".... | Apply google sheets formatter to URL | [
"Apply",
"google",
"sheets",
"formatter",
"to",
"URL"
] | [
"\"\"\"\n Apply google sheets formatter to URL\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f77dc2db9a8e6e50f58b02a67ebfe940652d11cf | mysociety/notebook_helper | charting/download.py | [
"MIT"
] | Python | json_to_chart | alt.Chart | def json_to_chart(json_spec: str) -> alt.Chart:
"""
take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts
"""
di = json.loads(json_spec)
if "layer" in di:
layers = di["layer"]
del di["layer"]
del di["width"]
... |
take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts
| take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts | [
"take",
"a",
"json",
"spec",
"and",
"produce",
"a",
"chart",
"mostly",
"needed",
"for",
"the",
"weird",
"work",
"arounds",
"needed",
"for",
"importing",
"layer",
"charts"
] | def json_to_chart(json_spec: str) -> alt.Chart:
di = json.loads(json_spec)
if "layer" in di:
layers = di["layer"]
del di["layer"]
del di["width"]
chart = LayerChart.from_dict(
{"config": di["config"], "layer": [], "datasets": di["datasets"]}
)
for n, l... | [
"def",
"json_to_chart",
"(",
"json_spec",
":",
"str",
")",
"->",
"alt",
".",
"Chart",
":",
"di",
"=",
"json",
".",
"loads",
"(",
"json_spec",
")",
"if",
"\"layer\"",
"in",
"di",
":",
"layers",
"=",
"di",
"[",
"\"layer\"",
"]",
"del",
"di",
"[",
"\"... | take a json spec and produce a chart
mostly needed for the weird work arounds needed for importing layer charts | [
"take",
"a",
"json",
"spec",
"and",
"produce",
"a",
"chart",
"mostly",
"needed",
"for",
"the",
"weird",
"work",
"arounds",
"needed",
"for",
"importing",
"layer",
"charts"
] | [
"\"\"\"\n take a json spec and produce a chart\n mostly needed for the weird work arounds needed for importing layer charts\n \"\"\""
] | [
{
"param": "json_spec",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "json_spec",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1effc8fb8b139a1da26fb3f6817fb64ad7038ebc | mysociety/notebook_helper | progress.py | [
"MIT"
] | Python | track_progress | null | def track_progress(
iterable: Iterable,
name: Optional[str] = None,
total: Optional[int] = None,
update_label: bool = False,
label_func: Optional[Callable] = lambda x: x,
clear: Optional[bool] = True,
):
"""
simple tracking loop using rich progress
"""
if name is None:
na... |
simple tracking loop using rich progress
| simple tracking loop using rich progress | [
"simple",
"tracking",
"loop",
"using",
"rich",
"progress"
] | def track_progress(
iterable: Iterable,
name: Optional[str] = None,
total: Optional[int] = None,
update_label: bool = False,
label_func: Optional[Callable] = lambda x: x,
clear: Optional[bool] = True,
):
if name is None:
name = ""
if total is None:
total = len(iterable)
... | [
"def",
"track_progress",
"(",
"iterable",
":",
"Iterable",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"total",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"update_label",
":",
"bool",
"=",
"False",
",",
"label_func",
":",
... | simple tracking loop using rich progress | [
"simple",
"tracking",
"loop",
"using",
"rich",
"progress"
] | [
"\"\"\"\n simple tracking loop using rich progress\n \"\"\""
] | [
{
"param": "iterable",
"type": "Iterable"
},
{
"param": "name",
"type": "Optional[str]"
},
{
"param": "total",
"type": "Optional[int]"
},
{
"param": "update_label",
"type": "bool"
},
{
"param": "label_func",
"type": "Optional[Callable]"
},
{
"param": "... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iterable",
"type": "Iterable",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "Optional[str]",
"docstring": null,
... |
3ef44f15e744d19c77f2a1ed9ef78d756527e96f | mysociety/notebook_helper | df_extensions/viz.py | [
"MIT"
] | Python | raincloud | null | def raincloud(
self,
groups: Optional[pd.Series] = None,
ort: Optional[str] = "h",
pal: Optional[str] = "Set2",
sigma: Optional[float] = 0.2,
title: str = "",
all_data_label: str = "All data",
x_label: Optional[str] = None,
y_label: Optional[str] =... |
show a raincloud plot of the values of a series
Optional split by a second series (group)
with labels.
| show a raincloud plot of the values of a series
Optional split by a second series (group)
with labels. | [
"show",
"a",
"raincloud",
"plot",
"of",
"the",
"values",
"of",
"a",
"series",
"Optional",
"split",
"by",
"a",
"second",
"series",
"(",
"group",
")",
"with",
"labels",
"."
] | def raincloud(
self,
groups: Optional[pd.Series] = None,
ort: Optional[str] = "h",
pal: Optional[str] = "Set2",
sigma: Optional[float] = 0.2,
title: str = "",
all_data_label: str = "All data",
x_label: Optional[str] = None,
y_label: Optional[str] =... | [
"def",
"raincloud",
"(",
"self",
",",
"groups",
":",
"Optional",
"[",
"pd",
".",
"Series",
"]",
"=",
"None",
",",
"ort",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"h\"",
",",
"pal",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"Set2\"",
",",
"sigma",
... | show a raincloud plot of the values of a series
Optional split by a second series (group)
with labels. | [
"show",
"a",
"raincloud",
"plot",
"of",
"the",
"values",
"of",
"a",
"series",
"Optional",
"split",
"by",
"a",
"second",
"series",
"(",
"group",
")",
"with",
"labels",
"."
] | [
"\"\"\"\n show a raincloud plot of the values of a series\n Optional split by a second series (group)\n with labels.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "groups",
"type": "Optional[pd.Series]"
},
{
"param": "ort",
"type": "Optional[str]"
},
{
"param": "pal",
"type": "Optional[str]"
},
{
"param": "sigma",
"type": "Optional[float]"
},
{
"param": "title",
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "groups",
"type": "Optional[pd.Series]",
"docstring": null,
"d... |
3ef44f15e744d19c77f2a1ed9ef78d756527e96f | mysociety/notebook_helper | df_extensions/viz.py | [
"MIT"
] | Python | raincloud | null | def raincloud(
self,
values: str,
groups: Optional[str] = None,
one_value: Optional[str] = None,
limit: Optional[List[str]] = None,
ort: Optional[str] = "h",
pal: Optional[str] = "Set2",
sigma: Optional[float] = 0.2,
title: Optional[str] = "",
... |
helper function for visualising one column against
another with raincloud plots.
| helper function for visualising one column against
another with raincloud plots. | [
"helper",
"function",
"for",
"visualising",
"one",
"column",
"against",
"another",
"with",
"raincloud",
"plots",
"."
] | def raincloud(
self,
values: str,
groups: Optional[str] = None,
one_value: Optional[str] = None,
limit: Optional[List[str]] = None,
ort: Optional[str] = "h",
pal: Optional[str] = "Set2",
sigma: Optional[float] = 0.2,
title: Optional[str] = "",
... | [
"def",
"raincloud",
"(",
"self",
",",
"values",
":",
"str",
",",
"groups",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"one_value",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"limit",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
... | helper function for visualising one column against
another with raincloud plots. | [
"helper",
"function",
"for",
"visualising",
"one",
"column",
"against",
"another",
"with",
"raincloud",
"plots",
"."
] | [
"\"\"\"\n helper function for visualising one column against\n another with raincloud plots.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "values",
"type": "str"
},
{
"param": "groups",
"type": "Optional[str]"
},
{
"param": "one_value",
"type": "Optional[str]"
},
{
"param": "limit",
"type": "Optional[List[str]]"
},
{
"param": "ort",
"type... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "values",
"type": "str",
"docstring": null,
"docstring_tokens"... |
9054527c3bf123ca90f410bf6b43706aec978ea8 | mysociety/notebook_helper | charting/chart.py | [
"MIT"
] | Python | save_chart | null | def save_chart(chart, filename, scale_factor=1, **kwargs):
"""
dumbed down version of altair save function that just assumes
we're sending extra properties to the embed options
"""
if isinstance(filename, Path):
# altair doesn't process paths right
if filename.parent.exists() is Fals... |
dumbed down version of altair save function that just assumes
we're sending extra properties to the embed options
| dumbed down version of altair save function that just assumes
we're sending extra properties to the embed options | [
"dumbed",
"down",
"version",
"of",
"altair",
"save",
"function",
"that",
"just",
"assumes",
"we",
"'",
"re",
"sending",
"extra",
"properties",
"to",
"the",
"embed",
"options"
] | def save_chart(chart, filename, scale_factor=1, **kwargs):
if isinstance(filename, Path):
if filename.parent.exists() is False:
filename.parent.mkdir()
filename = str(filename)
altair_save_chart(
chart,
filename,
scale_factor=scale_factor,
embed_option... | [
"def",
"save_chart",
"(",
"chart",
",",
"filename",
",",
"scale_factor",
"=",
"1",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"Path",
")",
":",
"if",
"filename",
".",
"parent",
".",
"exists",
"(",
")",
"is",
"False",
":"... | dumbed down version of altair save function that just assumes
we're sending extra properties to the embed options | [
"dumbed",
"down",
"version",
"of",
"altair",
"save",
"function",
"that",
"just",
"assumes",
"we",
"'",
"re",
"sending",
"extra",
"properties",
"to",
"the",
"embed",
"options"
] | [
"\"\"\"\n dumbed down version of altair save function that just assumes\n we're sending extra properties to the embed options\n \"\"\"",
"# altair doesn't process paths right"
] | [
{
"param": "chart",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "scale_factor",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "chart",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_token... |
9054527c3bf123ca90f410bf6b43706aec978ea8 | mysociety/notebook_helper | charting/chart.py | [
"MIT"
] | Python | split_text_to_line | List[str] | def split_text_to_line(text: str, cut_off: int = 60) -> List[str]:
"""
Split a string to meet line limit
"""
bits = text.split(" ")
rows = []
current_item = []
for b in bits:
if len(" ".join(current_item + [b])) > cut_off:
rows.append(" ".join(current_item))
c... |
Split a string to meet line limit
| Split a string to meet line limit | [
"Split",
"a",
"string",
"to",
"meet",
"line",
"limit"
] | def split_text_to_line(text: str, cut_off: int = 60) -> List[str]:
bits = text.split(" ")
rows = []
current_item = []
for b in bits:
if len(" ".join(current_item + [b])) > cut_off:
rows.append(" ".join(current_item))
current_item = []
current_item.append(b)
ro... | [
"def",
"split_text_to_line",
"(",
"text",
":",
"str",
",",
"cut_off",
":",
"int",
"=",
"60",
")",
"->",
"List",
"[",
"str",
"]",
":",
"bits",
"=",
"text",
".",
"split",
"(",
"\" \"",
")",
"rows",
"=",
"[",
"]",
"current_item",
"=",
"[",
"]",
"for... | Split a string to meet line limit | [
"Split",
"a",
"string",
"to",
"meet",
"line",
"limit"
] | [
"\"\"\"\n Split a string to meet line limit\n \"\"\""
] | [
{
"param": "text",
"type": "str"
},
{
"param": "cut_off",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cut_off",
"type": "int",
"docstring": null,
"docstring_token... |
9054527c3bf123ca90f410bf6b43706aec978ea8 | mysociety/notebook_helper | charting/chart.py | [
"MIT"
] | Python | display_options | <not_specific> | def display_options(self, **kwargs):
"""
arguments passed will be sent to display process
"""
self._display_options.update(kwargs)
return self |
arguments passed will be sent to display process
| arguments passed will be sent to display process | [
"arguments",
"passed",
"will",
"be",
"sent",
"to",
"display",
"process"
] | def display_options(self, **kwargs):
self._display_options.update(kwargs)
return self | [
"def",
"display_options",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_display_options",
".",
"update",
"(",
"kwargs",
")",
"return",
"self"
] | arguments passed will be sent to display process | [
"arguments",
"passed",
"will",
"be",
"sent",
"to",
"display",
"process"
] | [
"\"\"\"\n arguments passed will be sent to display process\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9054527c3bf123ca90f410bf6b43706aec978ea8 | mysociety/notebook_helper | charting/chart.py | [
"MIT"
] | Python | update_df | <not_specific> | def update_df(self, df: pd.DataFrame):
"""
take a new df and update the chart
"""
self.datasets[self.data["name"]] = df.to_dict("records")
return self |
take a new df and update the chart
| take a new df and update the chart | [
"take",
"a",
"new",
"df",
"and",
"update",
"the",
"chart"
] | def update_df(self, df: pd.DataFrame):
self.datasets[self.data["name"]] = df.to_dict("records")
return self | [
"def",
"update_df",
"(",
"self",
",",
"df",
":",
"pd",
".",
"DataFrame",
")",
":",
"self",
".",
"datasets",
"[",
"self",
".",
"data",
"[",
"\"name\"",
"]",
"]",
"=",
"df",
".",
"to_dict",
"(",
"\"records\"",
")",
"return",
"self"
] | take a new df and update the chart | [
"take",
"a",
"new",
"df",
"and",
"update",
"the",
"chart"
] | [
"\"\"\"\n take a new df and update the chart\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "df",
"type": "pd.DataFrame"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": null,
"docstring_to... |
9054527c3bf123ca90f410bf6b43706aec978ea8 | mysociety/notebook_helper | charting/chart.py | [
"MIT"
] | Python | df | <not_specific> | def df(self):
"""
get the dataset from the chart as a df
"""
return self._get_df() |
get the dataset from the chart as a df
| get the dataset from the chart as a df | [
"get",
"the",
"dataset",
"from",
"the",
"chart",
"as",
"a",
"df"
] | def df(self):
return self._get_df() | [
"def",
"df",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_df",
"(",
")"
] | get the dataset from the chart as a df | [
"get",
"the",
"dataset",
"from",
"the",
"chart",
"as",
"a",
"df"
] | [
"\"\"\"\n get the dataset from the chart as a df\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4e4ed766c8bce52818d5c846b77f1a1821aa9ce2 | mysociety/notebook_helper | management/exporters.py | [
"MIT"
] | Python | preprocess_cell | <not_specific> | def preprocess_cell(self, cell, resources, cell_index):
"""
Apply a transformation on each cell. See base.py for details.
"""
if cell["source"]:
if "#HIDE" == cell["source"][:5]:
cell.transient = {"remove_source": True}
return cell, resources |
Apply a transformation on each cell. See base.py for details.
| Apply a transformation on each cell. | [
"Apply",
"a",
"transformation",
"on",
"each",
"cell",
"."
] | def preprocess_cell(self, cell, resources, cell_index):
if cell["source"]:
if "#HIDE" == cell["source"][:5]:
cell.transient = {"remove_source": True}
return cell, resources | [
"def",
"preprocess_cell",
"(",
"self",
",",
"cell",
",",
"resources",
",",
"cell_index",
")",
":",
"if",
"cell",
"[",
"\"source\"",
"]",
":",
"if",
"\"#HIDE\"",
"==",
"cell",
"[",
"\"source\"",
"]",
"[",
":",
"5",
"]",
":",
"cell",
".",
"transient",
... | Apply a transformation on each cell. | [
"Apply",
"a",
"transformation",
"on",
"each",
"cell",
"."
] | [
"\"\"\"\n Apply a transformation on each cell. See base.py for details.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "cell",
"type": null
},
{
"param": "resources",
"type": null
},
{
"param": "cell_index",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cell",
"type": null,
"docstring": null,
"docstring_tokens": [... |
4e4ed766c8bce52818d5c846b77f1a1821aa9ce2 | mysociety/notebook_helper | management/exporters.py | [
"MIT"
] | Python | indent | <not_specific> | def indent(instr, nspaces=4, ntabs=0, flatten=False):
"""
do not indent markdown tables when exporting through this filter
"""
if instr.strip() and instr.strip()[0] == "|":
return instr
if "WARN Dropping" in instr:
return ""
return normal_indent(instr, nspaces, ntabs, flatten) |
do not indent markdown tables when exporting through this filter
| do not indent markdown tables when exporting through this filter | [
"do",
"not",
"indent",
"markdown",
"tables",
"when",
"exporting",
"through",
"this",
"filter"
] | def indent(instr, nspaces=4, ntabs=0, flatten=False):
if instr.strip() and instr.strip()[0] == "|":
return instr
if "WARN Dropping" in instr:
return ""
return normal_indent(instr, nspaces, ntabs, flatten) | [
"def",
"indent",
"(",
"instr",
",",
"nspaces",
"=",
"4",
",",
"ntabs",
"=",
"0",
",",
"flatten",
"=",
"False",
")",
":",
"if",
"instr",
".",
"strip",
"(",
")",
"and",
"instr",
".",
"strip",
"(",
")",
"[",
"0",
"]",
"==",
"\"|\"",
":",
"return",... | do not indent markdown tables when exporting through this filter | [
"do",
"not",
"indent",
"markdown",
"tables",
"when",
"exporting",
"through",
"this",
"filter"
] | [
"\"\"\"\n do not indent markdown tables when exporting through this filter\n \"\"\""
] | [
{
"param": "instr",
"type": null
},
{
"param": "nspaces",
"type": null
},
{
"param": "ntabs",
"type": null
},
{
"param": "flatten",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "instr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nspaces",
"type": null,
"docstring": null,
"docstring_tokens... |
88a71539e449a9e2e095dc1a433024c9dea92776 | gpmidi/MCEdit-Unified | resource_packs.py | [
"0BSD"
] | Python | step | <not_specific> | def step(slot):
'''
Utility method for multiplying the slot by 16
:param slot: Texture slot
:type slot: int
'''
texSlot = slot*16
return texSlot |
Utility method for multiplying the slot by 16
:param slot: Texture slot
:type slot: int
| Utility method for multiplying the slot by 16 | [
"Utility",
"method",
"for",
"multiplying",
"the",
"slot",
"by",
"16"
] | def step(slot):
texSlot = slot*16
return texSlot | [
"def",
"step",
"(",
"slot",
")",
":",
"texSlot",
"=",
"slot",
"*",
"16",
"return",
"texSlot"
] | Utility method for multiplying the slot by 16 | [
"Utility",
"method",
"for",
"multiplying",
"the",
"slot",
"by",
"16"
] | [
"'''\n Utility method for multiplying the slot by 16\n \n :param slot: Texture slot\n :type slot: int\n '''"
] | [
{
"param": "slot",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "slot",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
88a71539e449a9e2e095dc1a433024c9dea92776 | gpmidi/MCEdit-Unified | resource_packs.py | [
"0BSD"
] | Python | parse_terrain_png | null | def parse_terrain_png(self):
'''
Parses each block texture into a usable PNG file like terrain.png
'''
new_terrain = Image.new("RGBA", (512, 512), None)
for tex in self.block_image.keys():
if not self.__stop and tex in textureSlots.keys():
try:
... |
Parses each block texture into a usable PNG file like terrain.png
| Parses each block texture into a usable PNG file like terrain.png | [
"Parses",
"each",
"block",
"texture",
"into",
"a",
"usable",
"PNG",
"file",
"like",
"terrain",
".",
"png"
] | def parse_terrain_png(self):
new_terrain = Image.new("RGBA", (512, 512), None)
for tex in self.block_image.keys():
if not self.__stop and tex in textureSlots.keys():
try:
image = self.block_image[tex]
if image.mode != "RGBA":
... | [
"def",
"parse_terrain_png",
"(",
"self",
")",
":",
"new_terrain",
"=",
"Image",
".",
"new",
"(",
"\"RGBA\"",
",",
"(",
"512",
",",
"512",
")",
",",
"None",
")",
"for",
"tex",
"in",
"self",
".",
"block_image",
".",
"keys",
"(",
")",
":",
"if",
"not"... | Parses each block texture into a usable PNG file like terrain.png | [
"Parses",
"each",
"block",
"texture",
"into",
"a",
"usable",
"PNG",
"file",
"like",
"terrain",
".",
"png"
] | [
"'''\n Parses each block texture into a usable PNG file like terrain.png\n '''",
"# Print the resource pack 'raw' name.",
"# I for a reason it fails, print the 'representation' of it.",
"#print u\"{} did not replace any textures\".format(self._pack_name)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
88a71539e449a9e2e095dc1a433024c9dea92776 | gpmidi/MCEdit-Unified | resource_packs.py | [
"0BSD"
] | Python | open_pack | null | def open_pack(self):
'''
Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
'''
zfile = zipfile.ZipFile(self.zipfile)
for name in zfile.infolist():
if name.filename.endswith(".png")... |
Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
| Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance | [
"Opens",
"the",
"zip",
"file",
"and",
"puts",
"texture",
"data",
"into",
"a",
"dictionary",
"where",
"the",
"key",
"is",
"the",
"texture",
"file",
"name",
"and",
"the",
"value",
"is",
"a",
"PIL",
".",
"Image",
"instance"
] | def open_pack(self):
zfile = zipfile.ZipFile(self.zipfile)
for name in zfile.infolist():
if name.filename.endswith(".png") and not name.filename.split(os.path.sep)[-1].startswith("._"):
filename = "assets/minecraft/textures/blocks"
if name.filename.startswith(... | [
"def",
"open_pack",
"(",
"self",
")",
":",
"zfile",
"=",
"zipfile",
".",
"ZipFile",
"(",
"self",
".",
"zipfile",
")",
"for",
"name",
"in",
"zfile",
".",
"infolist",
"(",
")",
":",
"if",
"name",
".",
"filename",
".",
"endswith",
"(",
"\".png\"",
")",
... | Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance | [
"Opens",
"the",
"zip",
"file",
"and",
"puts",
"texture",
"data",
"into",
"a",
"dictionary",
"where",
"the",
"key",
"is",
"the",
"texture",
"file",
"name",
"and",
"the",
"value",
"is",
"a",
"PIL",
".",
"Image",
"instance"
] | [
"'''\n Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance\n '''",
"#zfile.extract(name.filename, self.texture_path)",
"#possible_texture = Image.open(os.path.join(self.texture_path, os.path.normpath(name.filenam... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
88a71539e449a9e2e095dc1a433024c9dea92776 | gpmidi/MCEdit-Unified | resource_packs.py | [
"0BSD"
] | Python | add_textures | null | def add_textures(self):
'''
Scraps the block textures folder and puts texture data into a dictionary with exactly identical structure as ZipResourcePack
'''
base_path = os.path.join(self._full_path, "assets", "minecraft", "textures", "blocks")
if os.path.exists(base_path):
... |
Scraps the block textures folder and puts texture data into a dictionary with exactly identical structure as ZipResourcePack
| Scraps the block textures folder and puts texture data into a dictionary with exactly identical structure as ZipResourcePack | [
"Scraps",
"the",
"block",
"textures",
"folder",
"and",
"puts",
"texture",
"data",
"into",
"a",
"dictionary",
"with",
"exactly",
"identical",
"structure",
"as",
"ZipResourcePack"
] | def add_textures(self):
base_path = os.path.join(self._full_path, "assets", "minecraft", "textures", "blocks")
if os.path.exists(base_path):
files = os.listdir(base_path)
for tex_file in files:
if tex_file.endswith(".png") and not tex_file.startswith("._") and tex... | [
"def",
"add_textures",
"(",
"self",
")",
":",
"base_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_full_path",
",",
"\"assets\"",
",",
"\"minecraft\"",
",",
"\"textures\"",
",",
"\"blocks\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
... | Scraps the block textures folder and puts texture data into a dictionary with exactly identical structure as ZipResourcePack | [
"Scraps",
"the",
"block",
"textures",
"folder",
"and",
"puts",
"texture",
"data",
"into",
"a",
"dictionary",
"with",
"exactly",
"identical",
"structure",
"as",
"ZipResourcePack"
] | [
"'''\n Scraps the block textures folder and puts texture data into a dictionary with exactly identical structure as ZipResourcePack\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5f42a73f02ea2d49e4799dded03dd7aa2d5cafad | gpmidi/MCEdit-Unified | albow/extended_widgets.py | [
"0BSD"
] | Python | showProgress | <not_specific> | def showProgress(progressText, progressIterator, cancel=False):
"""Show the progress for a long-running synchronous operation.
progressIterator should be a generator-like object that can return
either None, for an indeterminate indicator,
A float value between 0.0 and 1.0 for a determinate indicator,
... | Show the progress for a long-running synchronous operation.
progressIterator should be a generator-like object that can return
either None, for an indeterminate indicator,
A float value between 0.0 and 1.0 for a determinate indicator,
A string, to update the progress info label
or a tuple of (float ... | Show the progress for a long-running synchronous operation.
progressIterator should be a generator-like object that can return
either None, for an indeterminate indicator,
A float value between 0.0 and 1.0 for a determinate indicator,
A string, to update the progress info label
or a tuple of (float value, string) to se... | [
"Show",
"the",
"progress",
"for",
"a",
"long",
"-",
"running",
"synchronous",
"operation",
".",
"progressIterator",
"should",
"be",
"a",
"generator",
"-",
"like",
"object",
"that",
"can",
"return",
"either",
"None",
"for",
"an",
"indeterminate",
"indicator",
"... | def showProgress(progressText, progressIterator, cancel=False):
class ProgressWidget(Dialog):
progressFraction = 0.0
firstDraw = False
root = None
def draw(self, surface):
if self.root is None:
self.root = self.get_root()
Widget.draw(self, surf... | [
"def",
"showProgress",
"(",
"progressText",
",",
"progressIterator",
",",
"cancel",
"=",
"False",
")",
":",
"class",
"ProgressWidget",
"(",
"Dialog",
")",
":",
"progressFraction",
"=",
"0.0",
"firstDraw",
"=",
"False",
"root",
"=",
"None",
"def",
"draw",
"("... | Show the progress for a long-running synchronous operation. | [
"Show",
"the",
"progress",
"for",
"a",
"long",
"-",
"running",
"synchronous",
"operation",
"."
] | [
"\"\"\"Show the progress for a long-running synchronous operation.\n progressIterator should be a generator-like object that can return\n either None, for an indeterminate indicator,\n A float value between 0.0 and 1.0 for a determinate indicator,\n A string, to update the progress info label\n or a ... | [
{
"param": "progressText",
"type": null
},
{
"param": "progressIterator",
"type": null
},
{
"param": "cancel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "progressText",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "progressIterator",
"type": null,
"docstring": null,
"... |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | fixAllOfPodshotsBugs | null | def fixAllOfPodshotsBugs(self):
'''
Convenient function that fixes any bugs/typos (in the usercache.json file) that Podshot may have created
'''
for player in self._playerCacheList:
if "Timstamp" in player:
player["Timestamp"] = player["Timstamp"]
... |
Convenient function that fixes any bugs/typos (in the usercache.json file) that Podshot may have created
| Convenient function that fixes any bugs/typos (in the usercache.json file) that Podshot may have created | [
"Convenient",
"function",
"that",
"fixes",
"any",
"bugs",
"/",
"typos",
"(",
"in",
"the",
"usercache",
".",
"json",
"file",
")",
"that",
"Podshot",
"may",
"have",
"created"
] | def fixAllOfPodshotsBugs(self):
for player in self._playerCacheList:
if "Timstamp" in player:
player["Timestamp"] = player["Timstamp"]
del player["Timstamp"]
self._save() | [
"def",
"fixAllOfPodshotsBugs",
"(",
"self",
")",
":",
"for",
"player",
"in",
"self",
".",
"_playerCacheList",
":",
"if",
"\"Timstamp\"",
"in",
"player",
":",
"player",
"[",
"\"Timestamp\"",
"]",
"=",
"player",
"[",
"\"Timstamp\"",
"]",
"del",
"player",
"[",
... | Convenient function that fixes any bugs/typos (in the usercache.json file) that Podshot may have created | [
"Convenient",
"function",
"that",
"fixes",
"any",
"bugs",
"/",
"typos",
"(",
"in",
"the",
"usercache",
".",
"json",
"file",
")",
"that",
"Podshot",
"may",
"have",
"created"
] | [
"'''\n Convenient function that fixes any bugs/typos (in the usercache.json file) that Podshot may have created\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | load | null | def load(self):
'''
Loads from the usercache.json file if it exists, if not an empty one will be generated
'''
if not os.path.exists(userCachePath):
out = open(userCachePath, 'w')
json.dump(self._playerCacheList, out)
out.close()
f = open(user... |
Loads from the usercache.json file if it exists, if not an empty one will be generated
| Loads from the usercache.json file if it exists, if not an empty one will be generated | [
"Loads",
"from",
"the",
"usercache",
".",
"json",
"file",
"if",
"it",
"exists",
"if",
"not",
"an",
"empty",
"one",
"will",
"be",
"generated"
] | def load(self):
if not os.path.exists(userCachePath):
out = open(userCachePath, 'w')
json.dump(self._playerCacheList, out)
out.close()
f = open(userCachePath, 'r')
line = f.readline()
if line.startswith("{"):
f.close()
self.__c... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"userCachePath",
")",
":",
"out",
"=",
"open",
"(",
"userCachePath",
",",
"'w'",
")",
"json",
".",
"dump",
"(",
"self",
".",
"_playerCacheList",
",",
"out",
"... | Loads from the usercache.json file if it exists, if not an empty one will be generated | [
"Loads",
"from",
"the",
"usercache",
".",
"json",
"file",
"if",
"it",
"exists",
"if",
"not",
"an",
"empty",
"one",
"will",
"be",
"generated"
] | [
"'''\n Loads from the usercache.json file if it exists, if not an empty one will be generated\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | nameInCache | <not_specific> | def nameInCache(self, name):
'''
Checks to see if the name is already in the cache
:param name: The name of the player
:type name: str
:rtype: bool
'''
isInCache = False
for p in self._playerCacheList:
if p["Playername"] == name:
... |
Checks to see if the name is already in the cache
:param name: The name of the player
:type name: str
:rtype: bool
| Checks to see if the name is already in the cache | [
"Checks",
"to",
"see",
"if",
"the",
"name",
"is",
"already",
"in",
"the",
"cache"
] | def nameInCache(self, name):
isInCache = False
for p in self._playerCacheList:
if p["Playername"] == name:
isInCache = True
return isInCache | [
"def",
"nameInCache",
"(",
"self",
",",
"name",
")",
":",
"isInCache",
"=",
"False",
"for",
"p",
"in",
"self",
".",
"_playerCacheList",
":",
"if",
"p",
"[",
"\"Playername\"",
"]",
"==",
"name",
":",
"isInCache",
"=",
"True",
"return",
"isInCache"
] | Checks to see if the name is already in the cache | [
"Checks",
"to",
"see",
"if",
"the",
"name",
"is",
"already",
"in",
"the",
"cache"
] | [
"'''\n Checks to see if the name is already in the cache\n \n :param name: The name of the player\n :type name: str\n :rtype: bool\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | uuidInCache | <not_specific> | def uuidInCache(self, uuid, seperator=True):
'''
Checks to see if the UUID is already in the cache
:param uuid: The UUID of the player
:type uuid: str
:param seperator: True if the UUID has separators ('-')
:type seperator: bool
:rtype: bool
'''
... |
Checks to see if the UUID is already in the cache
:param uuid: The UUID of the player
:type uuid: str
:param seperator: True if the UUID has separators ('-')
:type seperator: bool
:rtype: bool
| Checks to see if the UUID is already in the cache | [
"Checks",
"to",
"see",
"if",
"the",
"UUID",
"is",
"already",
"in",
"the",
"cache"
] | def uuidInCache(self, uuid, seperator=True):
isInCache = False
for p in self._playerCacheList:
if seperator:
if p["UUID (Separator)"] == uuid:
isInCache = True
else:
if p["UUID (No Separator)"] == uuid:
isInC... | [
"def",
"uuidInCache",
"(",
"self",
",",
"uuid",
",",
"seperator",
"=",
"True",
")",
":",
"isInCache",
"=",
"False",
"for",
"p",
"in",
"self",
".",
"_playerCacheList",
":",
"if",
"seperator",
":",
"if",
"p",
"[",
"\"UUID (Separator)\"",
"]",
"==",
"uuid",... | Checks to see if the UUID is already in the cache | [
"Checks",
"to",
"see",
"if",
"the",
"UUID",
"is",
"already",
"in",
"the",
"cache"
] | [
"'''\n Checks to see if the UUID is already in the cache\n \n :param uuid: The UUID of the player\n :type uuid: str\n :param seperator: True if the UUID has separators ('-')\n :type seperator: bool\n :rtype: bool\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "uuid",
"type": null
},
{
"param": "seperator",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | force_refresh | null | def force_refresh(self):
'''
Refreshes all players in the cache, regardless of how long ago the name was synced
'''
players = self._playerCacheList
for player in players:
self.getPlayerInfo(player["UUID (Separator)"], force=True) |
Refreshes all players in the cache, regardless of how long ago the name was synced
| Refreshes all players in the cache, regardless of how long ago the name was synced | [
"Refreshes",
"all",
"players",
"in",
"the",
"cache",
"regardless",
"of",
"how",
"long",
"ago",
"the",
"name",
"was",
"synced"
] | def force_refresh(self):
players = self._playerCacheList
for player in players:
self.getPlayerInfo(player["UUID (Separator)"], force=True) | [
"def",
"force_refresh",
"(",
"self",
")",
":",
"players",
"=",
"self",
".",
"_playerCacheList",
"for",
"player",
"in",
"players",
":",
"self",
".",
"getPlayerInfo",
"(",
"player",
"[",
"\"UUID (Separator)\"",
"]",
",",
"force",
"=",
"True",
")"
] | Refreshes all players in the cache, regardless of how long ago the name was synced | [
"Refreshes",
"all",
"players",
"in",
"the",
"cache",
"regardless",
"of",
"how",
"long",
"ago",
"the",
"name",
"was",
"synced"
] | [
"'''\n Refreshes all players in the cache, regardless of how long ago the name was synced\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
23380e9e98f6fef2a7508d279c41df29238df7ed | gpmidi/MCEdit-Unified | version_utils.py | [
"0BSD"
] | Python | cleanup | null | def cleanup(self):
'''
Removes all failed UUID/Player name lookups from the cache
'''
remove = []
for player in self._playerCacheList:
if not player["WasSuccessful"]:
remove.append(player)
for toRemove in remove:
self._playerCacheLi... |
Removes all failed UUID/Player name lookups from the cache
| Removes all failed UUID/Player name lookups from the cache | [
"Removes",
"all",
"failed",
"UUID",
"/",
"Player",
"name",
"lookups",
"from",
"the",
"cache"
] | def cleanup(self):
remove = []
for player in self._playerCacheList:
if not player["WasSuccessful"]:
remove.append(player)
for toRemove in remove:
self._playerCacheList.remove(toRemove)
self._save() | [
"def",
"cleanup",
"(",
"self",
")",
":",
"remove",
"=",
"[",
"]",
"for",
"player",
"in",
"self",
".",
"_playerCacheList",
":",
"if",
"not",
"player",
"[",
"\"WasSuccessful\"",
"]",
":",
"remove",
".",
"append",
"(",
"player",
")",
"for",
"toRemove",
"i... | Removes all failed UUID/Player name lookups from the cache | [
"Removes",
"all",
"failed",
"UUID",
"/",
"Player",
"name",
"lookups",
"from",
"the",
"cache"
] | [
"'''\n Removes all failed UUID/Player name lookups from the cache\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
798ce0be184897ab03f07afea03d2ddfbab5b1c1 | gpmidi/MCEdit-Unified | mcplatform.py | [
"0BSD"
] | Python | OSXVersionChecker | <not_specific> | def OSXVersionChecker(name,compare):
"""Rediculously complicated function to compare current System version to inputted version."""
if compare != 'gt' and compare != 'lt' and compare != 'eq' and compare != 'gteq' and compare != 'lteq':
print "Invalid version check {}".format(compare)
return Fals... | Rediculously complicated function to compare current System version to inputted version. | Rediculously complicated function to compare current System version to inputted version. | [
"Rediculously",
"complicated",
"function",
"to",
"compare",
"current",
"System",
"version",
"to",
"inputted",
"version",
"."
] | def OSXVersionChecker(name,compare):
if compare != 'gt' and compare != 'lt' and compare != 'eq' and compare != 'gteq' and compare != 'lteq':
print "Invalid version check {}".format(compare)
return False
if sys.platform == 'darwin':
try:
systemVersion = platform.mac_ver()[0].s... | [
"def",
"OSXVersionChecker",
"(",
"name",
",",
"compare",
")",
":",
"if",
"compare",
"!=",
"'gt'",
"and",
"compare",
"!=",
"'lt'",
"and",
"compare",
"!=",
"'eq'",
"and",
"compare",
"!=",
"'gteq'",
"and",
"compare",
"!=",
"'lteq'",
":",
"print",
"\"Invalid v... | Rediculously complicated function to compare current System version to inputted version. | [
"Rediculously",
"complicated",
"function",
"to",
"compare",
"current",
"System",
"version",
"to",
"inputted",
"version",
"."
] | [
"\"\"\"Rediculously complicated function to compare current System version to inputted version.\"\"\""
] | [
{
"param": "name",
"type": null
},
{
"param": "compare",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compare",
"type": null,
"docstring": null,
"docstring_tokens"... |
03442fe72dd90b186b30281f864256e87aa93a5e | justinpettit/differential-datalog | test/souffle/convert.py | [
"MIT"
] | Python | convert_conjunction | <not_specific> | def convert_conjunction(conj):
"""Convert a conjunction of expressions into a string"""
expr = getOptField(conj, "Expression")
if expr != None:
return convert_expression(expr)
children = getArray(conj, "ConjunctionsOrDisjunctions")
operator = getOptField(conj, "OR")
assert operator == No... | Convert a conjunction of expressions into a string | Convert a conjunction of expressions into a string | [
"Convert",
"a",
"conjunction",
"of",
"expressions",
"into",
"a",
"string"
] | def convert_conjunction(conj):
expr = getOptField(conj, "Expression")
if expr != None:
return convert_expression(expr)
children = getArray(conj, "ConjunctionsOrDisjunctions")
operator = getOptField(conj, "OR")
assert operator == None
rec = map(convert_conjunction, children)
return ",... | [
"def",
"convert_conjunction",
"(",
"conj",
")",
":",
"expr",
"=",
"getOptField",
"(",
"conj",
",",
"\"Expression\"",
")",
"if",
"expr",
"!=",
"None",
":",
"return",
"convert_expression",
"(",
"expr",
")",
"children",
"=",
"getArray",
"(",
"conj",
",",
"\"C... | Convert a conjunction of expressions into a string | [
"Convert",
"a",
"conjunction",
"of",
"expressions",
"into",
"a",
"string"
] | [
"\"\"\"Convert a conjunction of expressions into a string\"\"\""
] | [
{
"param": "conj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "conj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
03442fe72dd90b186b30281f864256e87aa93a5e | justinpettit/differential-datalog | test/souffle/convert.py | [
"MIT"
] | Python | normalize_tail | <not_specific> | def normalize_tail(tail):
"""Converts a tail into a disjunction of conjunctions.
Returns a list with all disjunctions"""
# TODO
return [getField(tail, "ConjunctionsOrDisjunctions")] | Converts a tail into a disjunction of conjunctions.
Returns a list with all disjunctions | Converts a tail into a disjunction of conjunctions.
Returns a list with all disjunctions | [
"Converts",
"a",
"tail",
"into",
"a",
"disjunction",
"of",
"conjunctions",
".",
"Returns",
"a",
"list",
"with",
"all",
"disjunctions"
] | def normalize_tail(tail):
return [getField(tail, "ConjunctionsOrDisjunctions")] | [
"def",
"normalize_tail",
"(",
"tail",
")",
":",
"return",
"[",
"getField",
"(",
"tail",
",",
"\"ConjunctionsOrDisjunctions\"",
")",
"]"
] | Converts a tail into a disjunction of conjunctions. | [
"Converts",
"a",
"tail",
"into",
"a",
"disjunction",
"of",
"conjunctions",
"."
] | [
"\"\"\"Converts a tail into a disjunction of conjunctions.\n Returns a list with all disjunctions\"\"\"",
"# TODO"
] | [
{
"param": "tail",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tail",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
03442fe72dd90b186b30281f864256e87aa93a5e | justinpettit/differential-datalog | test/souffle/convert.py | [
"MIT"
] | Python | has_relations | <not_specific> | def has_relations(conj):
"""True if a conjunction contains any relations"""
expr = getOptField(conj, "Expression")
if expr != None:
return expression_has_relations(expr)
children = getArray(conj, "ConjunctionsOrDisjunctions")
rec = map(has_relations, children)
return reduce(lambda a,b: a... | True if a conjunction contains any relations | True if a conjunction contains any relations | [
"True",
"if",
"a",
"conjunction",
"contains",
"any",
"relations"
] | def has_relations(conj):
expr = getOptField(conj, "Expression")
if expr != None:
return expression_has_relations(expr)
children = getArray(conj, "ConjunctionsOrDisjunctions")
rec = map(has_relations, children)
return reduce(lambda a,b: a or b, rec, False) | [
"def",
"has_relations",
"(",
"conj",
")",
":",
"expr",
"=",
"getOptField",
"(",
"conj",
",",
"\"Expression\"",
")",
"if",
"expr",
"!=",
"None",
":",
"return",
"expression_has_relations",
"(",
"expr",
")",
"children",
"=",
"getArray",
"(",
"conj",
",",
"\"C... | True if a conjunction contains any relations | [
"True",
"if",
"a",
"conjunction",
"contains",
"any",
"relations"
] | [
"\"\"\"True if a conjunction contains any relations\"\"\""
] | [
{
"param": "conj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "conj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
03442fe72dd90b186b30281f864256e87aa93a5e | justinpettit/differential-datalog | test/souffle/convert.py | [
"MIT"
] | Python | process_rule | null | def process_rule(rule, files, preprocess):
"""Convert a rule and emit the output"""
head = getField(rule, "Head")
tail = getField(rule, "Tail")
headClauses = getListField(head, "Clause", "ClauseList")
tails = normalize_tail(tail)
if not has_relations(tail) and preprocess:
# If there are... | Convert a rule and emit the output | Convert a rule and emit the output | [
"Convert",
"a",
"rule",
"and",
"emit",
"the",
"output"
] | def process_rule(rule, files, preprocess):
head = getField(rule, "Head")
tail = getField(rule, "Tail")
headClauses = getListField(head, "Clause", "ClauseList")
tails = normalize_tail(tail)
if not has_relations(tail) and preprocess:
for clause in headClauses:
name = getField(claus... | [
"def",
"process_rule",
"(",
"rule",
",",
"files",
",",
"preprocess",
")",
":",
"head",
"=",
"getField",
"(",
"rule",
",",
"\"Head\"",
")",
"tail",
"=",
"getField",
"(",
"rule",
",",
"\"Tail\"",
")",
"headClauses",
"=",
"getListField",
"(",
"head",
",",
... | Convert a rule and emit the output | [
"Convert",
"a",
"rule",
"and",
"emit",
"the",
"output"
] | [
"\"\"\"Convert a rule and emit the output\"\"\"",
"# If there are no clauses in the tail we",
"# mark all input relations as input relations",
"# TODO: we should also emit the facts as data..."
] | [
{
"param": "rule",
"type": null
},
{
"param": "files",
"type": null
},
{
"param": "preprocess",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rule",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "files",
"type": null,
"docstring": null,
"docstring_tokens": ... |
03442fe72dd90b186b30281f864256e87aa93a5e | justinpettit/differential-datalog | test/souffle/convert.py | [
"MIT"
] | Python | process_relation_decl | <not_specific> | def process_relation_decl(relationdecl, files, preprocess):
"""Process a relation declaration and emit output to files"""
id = getField(relationdecl, "Identifier")
params = getListField(relationdecl, "Parameter", "ParameterList")
if preprocess:
relname = register_relation(id.value)
retur... | Process a relation declaration and emit output to files | Process a relation declaration and emit output to files | [
"Process",
"a",
"relation",
"declaration",
"and",
"emit",
"output",
"to",
"files"
] | def process_relation_decl(relationdecl, files, preprocess):
id = getField(relationdecl, "Identifier")
params = getListField(relationdecl, "Parameter", "ParameterList")
if preprocess:
relname = register_relation(id.value)
return
relname = relation_name(id.value)
paramdecls = map(conve... | [
"def",
"process_relation_decl",
"(",
"relationdecl",
",",
"files",
",",
"preprocess",
")",
":",
"id",
"=",
"getField",
"(",
"relationdecl",
",",
"\"Identifier\"",
")",
"params",
"=",
"getListField",
"(",
"relationdecl",
",",
"\"Parameter\"",
",",
"\"ParameterList\... | Process a relation declaration and emit output to files | [
"Process",
"a",
"relation",
"declaration",
"and",
"emit",
"output",
"to",
"files"
] | [
"\"\"\"Process a relation declaration and emit output to files\"\"\""
] | [
{
"param": "relationdecl",
"type": null
},
{
"param": "files",
"type": null
},
{
"param": "preprocess",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "relationdecl",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "files",
"type": null,
"docstring": null,
"docstring_t... |
86895528a875cd1c15feaa4c512266dd407b3f41 | quatrope/uttrs | uttr.py | [
"BSD-3-Clause"
] | Python | is_dimensionless | <not_specific> | def is_dimensionless(self, v):
"""Return true if v is dimensionless."""
return (
not isinstance(v, u.Quantity) or v.unit == u.dimensionless_unscaled
) | Return true if v is dimensionless. | Return true if v is dimensionless. | [
"Return",
"true",
"if",
"v",
"is",
"dimensionless",
"."
] | def is_dimensionless(self, v):
return (
not isinstance(v, u.Quantity) or v.unit == u.dimensionless_unscaled
) | [
"def",
"is_dimensionless",
"(",
"self",
",",
"v",
")",
":",
"return",
"(",
"not",
"isinstance",
"(",
"v",
",",
"u",
".",
"Quantity",
")",
"or",
"v",
".",
"unit",
"==",
"u",
".",
"dimensionless_unscaled",
")"
] | Return true if v is dimensionless. | [
"Return",
"true",
"if",
"v",
"is",
"dimensionless",
"."
] | [
"\"\"\"Return true if v is dimensionless.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "v",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
86895528a875cd1c15feaa4c512266dd407b3f41 | quatrope/uttrs | uttr.py | [
"BSD-3-Clause"
] | Python | convert_if_dimensionless | <not_specific> | def convert_if_dimensionless(self, value):
"""Assign a unit to a dimensionless object.
If the object already has a dimension it returns it without change
Examples
--------
>>> uc = UnitConverter(u.km)
>>> uc.convert_if_dimensionless(1) # dimensionless then convert
... | Assign a unit to a dimensionless object.
If the object already has a dimension it returns it without change
Examples
--------
>>> uc = UnitConverter(u.km)
>>> uc.convert_if_dimensionless(1) # dimensionless then convert
'<Quantity 1. km>'
>>> # the same object... | Assign a unit to a dimensionless object.
If the object already has a dimension it returns it without change
Examples
| [
"Assign",
"a",
"unit",
"to",
"a",
"dimensionless",
"object",
".",
"If",
"the",
"object",
"already",
"has",
"a",
"dimension",
"it",
"returns",
"it",
"without",
"change",
"Examples"
] | def convert_if_dimensionless(self, value):
if self.is_dimensionless(value) and value is not None:
return value * self.unit
return value | [
"def",
"convert_if_dimensionless",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"is_dimensionless",
"(",
"value",
")",
"and",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"*",
"self",
".",
"unit",
"return",
"value"
] | Assign a unit to a dimensionless object. | [
"Assign",
"a",
"unit",
"to",
"a",
"dimensionless",
"object",
"."
] | [
"\"\"\"Assign a unit to a dimensionless object.\n\n If the object already has a dimension it returns it without change\n\n Examples\n --------\n >>> uc = UnitConverter(u.km)\n\n >>> uc.convert_if_dimensionless(1) # dimensionless then convert\n '<Quantity 1. km>'\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | run | null | def run(args):
"""
Executes the correct action according the user input.
Parameters:
args - arguments collected by argparser
"""
# Declares an instance of SetupSimulator()
setup = SetupSimulator()
if args.install:
# Cleanup the screen
setup.clear()
# Get the ... |
Executes the correct action according the user input.
Parameters:
args - arguments collected by argparser
| Executes the correct action according the user input.
Parameters:
args - arguments collected by argparser | [
"Executes",
"the",
"correct",
"action",
"according",
"the",
"user",
"input",
".",
"Parameters",
":",
"args",
"-",
"arguments",
"collected",
"by",
"argparser"
] | def run(args):
setup = SetupSimulator()
if args.install:
setup.clear()
start_time = time.time()
if not setup.is_connected_internet():
print "Ensure you have internet connection"
sys.exit(1)
setup.pretty_print("Installing")
setup.verify_dependencies... | [
"def",
"run",
"(",
"args",
")",
":",
"setup",
"=",
"SetupSimulator",
"(",
")",
"if",
"args",
".",
"install",
":",
"setup",
".",
"clear",
"(",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"setup",
".",
"is_connected_internet",
"... | Executes the correct action according the user input. | [
"Executes",
"the",
"correct",
"action",
"according",
"the",
"user",
"input",
"."
] | [
"\"\"\"\n Executes the correct action according the user input.\n\n Parameters:\n args - arguments collected by argparser\n \"\"\"",
"# Declares an instance of SetupSimulator()",
"# Cleanup the screen",
"# Get the moment when the installation started",
"# Check internet connection",
"# Pre... | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | create_directory | null | def create_directory(target_directory, setup_simulator):
'''
Create a directory where all packages will be stored.
'''
if setup_simulator.directory_exists(target_directory):
setup_simulator.remove_directory(target_directory)
else:
setup_simulator.create_directory(target_directory) |
Create a directory where all packages will be stored.
| Create a directory where all packages will be stored. | [
"Create",
"a",
"directory",
"where",
"all",
"packages",
"will",
"be",
"stored",
"."
] | def create_directory(target_directory, setup_simulator):
if setup_simulator.directory_exists(target_directory):
setup_simulator.remove_directory(target_directory)
else:
setup_simulator.create_directory(target_directory) | [
"def",
"create_directory",
"(",
"target_directory",
",",
"setup_simulator",
")",
":",
"if",
"setup_simulator",
".",
"directory_exists",
"(",
"target_directory",
")",
":",
"setup_simulator",
".",
"remove_directory",
"(",
"target_directory",
")",
"else",
":",
"setup_sim... | Create a directory where all packages will be stored. | [
"Create",
"a",
"directory",
"where",
"all",
"packages",
"will",
"be",
"stored",
"."
] | [
"'''\n Create a directory where all packages will be stored.\n '''"
] | [
{
"param": "target_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "target_directory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "setup_simulator",
"type": null,
"docstring": null,
... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | download_common_pckg | null | def download_common_pckg(common_files, download_directory, setup_simulator):
'''
Download the necessary packages. They are stored into the files
license and simulator. The first line contains the base URI and
the rest of the file contains the packages.
'''
setup_simulator.print_line()
for do... |
Download the necessary packages. They are stored into the files
license and simulator. The first line contains the base URI and
the rest of the file contains the packages.
| Download the necessary packages. They are stored into the files
license and simulator. The first line contains the base URI and
the rest of the file contains the packages. | [
"Download",
"the",
"necessary",
"packages",
".",
"They",
"are",
"stored",
"into",
"the",
"files",
"license",
"and",
"simulator",
".",
"The",
"first",
"line",
"contains",
"the",
"base",
"URI",
"and",
"the",
"rest",
"of",
"the",
"file",
"contains",
"the",
"p... | def download_common_pckg(common_files, download_directory, setup_simulator):
setup_simulator.print_line()
for download in common_files:
with open(download) as fdownload:
ftpurl = fdownload.readline().strip('\n')
packages = fdownload.readlines()
size = len(packages)
... | [
"def",
"download_common_pckg",
"(",
"common_files",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"setup_simulator",
".",
"print_line",
"(",
")",
"for",
"download",
"in",
"common_files",
":",
"with",
"open",
"(",
"download",
")",
"as",
"fdownload",
... | Download the necessary packages. | [
"Download",
"the",
"necessary",
"packages",
"."
] | [
"'''\n Download the necessary packages. They are stored into the files\n license and simulator. The first line contains the base URI and\n the rest of the file contains the packages.\n '''"
] | [
{
"param": "common_files",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "common_files",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "download_directory",
"type": null,
"docstring": null,
... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | download_by_distro | null | def download_by_distro(distro, dir_path, download_directory, setup_simulator):
'''
Download the necessary packages by distro.
'''
if var.UBUNTU in distro:
dfile = dir_path + "/resources/distros/ubuntu.config"
elif var.FEDORA in distro:
dfile = dir_path + "/resources/distros/fedora.co... |
Download the necessary packages by distro.
| Download the necessary packages by distro. | [
"Download",
"the",
"necessary",
"packages",
"by",
"distro",
"."
] | def download_by_distro(distro, dir_path, download_directory, setup_simulator):
if var.UBUNTU in distro:
dfile = dir_path + "/resources/distros/ubuntu.config"
elif var.FEDORA in distro:
dfile = dir_path + "/resources/distros/fedora.config"
else:
dfile = dir_path + "/resources/distros/... | [
"def",
"download_by_distro",
"(",
"distro",
",",
"dir_path",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"if",
"var",
".",
"UBUNTU",
"in",
"distro",
":",
"dfile",
"=",
"dir_path",
"+",
"\"/resources/distros/ubuntu.config\"",
"elif",
"var",
".",
... | Download the necessary packages by distro. | [
"Download",
"the",
"necessary",
"packages",
"by",
"distro",
"."
] | [
"'''\n Download the necessary packages by distro.\n '''"
] | [
{
"param": "distro",
"type": null
},
{
"param": "dir_path",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "distro",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dir_path",
"type": null,
"docstring": null,
"docstring_toke... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | install_packages | null | def install_packages(simulator_versions, download_directory, setup_simulator):
'''
Install the simulator packages for p8 and p9 according
the host distro
'''
for simulator_version in simulator_versions:
if not setup_simulator.directory_exists(simulator_version):
setup_simulator.p... |
Install the simulator packages for p8 and p9 according
the host distro
| Install the simulator packages for p8 and p9 according
the host distro | [
"Install",
"the",
"simulator",
"packages",
"for",
"p8",
"and",
"p9",
"according",
"the",
"host",
"distro"
] | def install_packages(simulator_versions, download_directory, setup_simulator):
for simulator_version in simulator_versions:
if not setup_simulator.directory_exists(simulator_version):
setup_simulator.print_line()
print "Installing the simulator packages..."
if var.UBUNTU ... | [
"def",
"install_packages",
"(",
"simulator_versions",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"for",
"simulator_version",
"in",
"simulator_versions",
":",
"if",
"not",
"setup_simulator",
".",
"directory_exists",
"(",
"simulator_version",
")",
":",
... | Install the simulator packages for p8 and p9 according
the host distro | [
"Install",
"the",
"simulator",
"packages",
"for",
"p8",
"and",
"p9",
"according",
"the",
"host",
"distro"
] | [
"'''\n Install the simulator packages for p8 and p9 according\n the host distro\n '''"
] | [
{
"param": "simulator_versions",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "simulator_versions",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "download_directory",
"type": null,
"docstring": null,... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | extract_img | null | def extract_img(disk_img, download_directory, setup_simulator):
'''
Extract the bzip2 file which contains the Debian sysroot
'''
full_img_path = download_directory + disk_img
try:
if not setup_simulator.file_exists(full_img_path):
if setup_simulator.file_exists(full_img_path + ".... |
Extract the bzip2 file which contains the Debian sysroot
| Extract the bzip2 file which contains the Debian sysroot | [
"Extract",
"the",
"bzip2",
"file",
"which",
"contains",
"the",
"Debian",
"sysroot"
] | def extract_img(disk_img, download_directory, setup_simulator):
full_img_path = download_directory + disk_img
try:
if not setup_simulator.file_exists(full_img_path):
if setup_simulator.file_exists(full_img_path + ".bz2"):
setup_simulator.print_line()
print "Ex... | [
"def",
"extract_img",
"(",
"disk_img",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"full_img_path",
"=",
"download_directory",
"+",
"disk_img",
"try",
":",
"if",
"not",
"setup_simulator",
".",
"file_exists",
"(",
"full_img_path",
")",
":",
"if",
... | Extract the bzip2 file which contains the Debian sysroot | [
"Extract",
"the",
"bzip2",
"file",
"which",
"contains",
"the",
"Debian",
"sysroot"
] | [
"'''\n Extract the bzip2 file which contains the Debian sysroot\n '''"
] | [
{
"param": "disk_img",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "disk_img",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "download_directory",
"type": null,
"docstring": null,
"do... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | customize_img | null | def customize_img(disk_img, lock, mount, download_directory, setup_simulator):
'''
Customize the disk img by copying the script which installs the SDK
and its dependencies inside it
'''
full_img_path = download_directory + disk_img
if not setup_simulator.file_exists(lock):
setup_simulato... |
Customize the disk img by copying the script which installs the SDK
and its dependencies inside it
| Customize the disk img by copying the script which installs the SDK
and its dependencies inside it | [
"Customize",
"the",
"disk",
"img",
"by",
"copying",
"the",
"script",
"which",
"installs",
"the",
"SDK",
"and",
"its",
"dependencies",
"inside",
"it"
] | def customize_img(disk_img, lock, mount, download_directory, setup_simulator):
full_img_path = download_directory + disk_img
if not setup_simulator.file_exists(lock):
setup_simulator.print_line()
print "Customizing the image..."
setup_simulator.configure_image(full_img_path, lock, mount)... | [
"def",
"customize_img",
"(",
"disk_img",
",",
"lock",
",",
"mount",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"full_img_path",
"=",
"download_directory",
"+",
"disk_img",
"if",
"not",
"setup_simulator",
".",
"file_exists",
"(",
"lock",
")",
":... | Customize the disk img by copying the script which installs the SDK
and its dependencies inside it | [
"Customize",
"the",
"disk",
"img",
"by",
"copying",
"the",
"script",
"which",
"installs",
"the",
"SDK",
"and",
"its",
"dependencies",
"inside",
"it"
] | [
"'''\n Customize the disk img by copying the script which installs the SDK\n and its dependencies inside it\n '''"
] | [
{
"param": "disk_img",
"type": null
},
{
"param": "lock",
"type": null
},
{
"param": "mount",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "disk_img",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lock",
"type": null,
"docstring": null,
"docstring_tokens... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | create_symlink | null | def create_symlink(sym_link, disk, download_directory, setup_simulator):
'''
Configure a symlink to be used by the tcl script
'''
if not setup_simulator.file_exists(download_directory + sym_link):
cmd = download_directory + disk + " " + download_directory + sym_link
setup_simulator.execu... |
Configure a symlink to be used by the tcl script
| Configure a symlink to be used by the tcl script | [
"Configure",
"a",
"symlink",
"to",
"be",
"used",
"by",
"the",
"tcl",
"script"
] | def create_symlink(sym_link, disk, download_directory, setup_simulator):
if not setup_simulator.file_exists(download_directory + sym_link):
cmd = download_directory + disk + " " + download_directory + sym_link
setup_simulator.execute_cmd("ln -s " + cmd) | [
"def",
"create_symlink",
"(",
"sym_link",
",",
"disk",
",",
"download_directory",
",",
"setup_simulator",
")",
":",
"if",
"not",
"setup_simulator",
".",
"file_exists",
"(",
"download_directory",
"+",
"sym_link",
")",
":",
"cmd",
"=",
"download_directory",
"+",
"... | Configure a symlink to be used by the tcl script | [
"Configure",
"a",
"symlink",
"to",
"be",
"used",
"by",
"the",
"tcl",
"script"
] | [
"'''\n Configure a symlink to be used by the tcl script\n '''"
] | [
{
"param": "sym_link",
"type": null
},
{
"param": "disk",
"type": null
},
{
"param": "download_directory",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sym_link",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "disk",
"type": null,
"docstring": null,
"docstring_tokens... |
2f6ed2b72f7b8d7929a963ec2f53efccdc2dcf8c | open-power-sdk/power-simulator | mambo/controller.py | [
"Apache-2.0"
] | Python | start_simulator | null | def start_simulator(version, setup_simulator):
'''
starts the simulator according the version selected by the user
'''
if setup_simulator.show_connection_info(version):
os.chdir(var.DOWNLOAD_DIR)
set_network(setup_simulator)
if 'power8' in version:
p8_prefix = '/opt/i... |
starts the simulator according the version selected by the user
| starts the simulator according the version selected by the user | [
"starts",
"the",
"simulator",
"according",
"the",
"version",
"selected",
"by",
"the",
"user"
] | def start_simulator(version, setup_simulator):
if setup_simulator.show_connection_info(version):
os.chdir(var.DOWNLOAD_DIR)
set_network(setup_simulator)
if 'power8' in version:
p8_prefix = '/opt/ibm/systemsim-p8/run/pegasus/'
p8_sim = p8_prefix + 'power8 -W -f'
... | [
"def",
"start_simulator",
"(",
"version",
",",
"setup_simulator",
")",
":",
"if",
"setup_simulator",
".",
"show_connection_info",
"(",
"version",
")",
":",
"os",
".",
"chdir",
"(",
"var",
".",
"DOWNLOAD_DIR",
")",
"set_network",
"(",
"setup_simulator",
")",
"i... | starts the simulator according the version selected by the user | [
"starts",
"the",
"simulator",
"according",
"the",
"version",
"selected",
"by",
"the",
"user"
] | [
"'''\n starts the simulator according the version selected by the user\n '''"
] | [
{
"param": "version",
"type": null
},
{
"param": "setup_simulator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "version",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "setup_simulator",
"type": null,
"docstring": null,
"docstr... |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | install_deb_apt | null | def install_deb_apt(self, package):
'''install DEB file via apt-get'''
try:
self.execute_cmd('sudo apt-get -y install ' + package)
except (KeyboardInterrupt, SystemExit, RuntimeError):
raise | install DEB file via apt-get | install DEB file via apt-get | [
"install",
"DEB",
"file",
"via",
"apt",
"-",
"get"
] | def install_deb_apt(self, package):
try:
self.execute_cmd('sudo apt-get -y install ' + package)
except (KeyboardInterrupt, SystemExit, RuntimeError):
raise | [
"def",
"install_deb_apt",
"(",
"self",
",",
"package",
")",
":",
"try",
":",
"self",
".",
"execute_cmd",
"(",
"'sudo apt-get -y install '",
"+",
"package",
")",
"except",
"(",
"KeyboardInterrupt",
",",
"SystemExit",
",",
"RuntimeError",
")",
":",
"raise"
] | install DEB file via apt-get | [
"install",
"DEB",
"file",
"via",
"apt",
"-",
"get"
] | [
"'''install DEB file via apt-get'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "package",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "package",
"type": null,
"docstring": null,
"docstring_tokens"... |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | configure_image | null | def configure_image(self, disk_img, lock, mount_point):
'''configure the image, copying the configurerepos.sh into it.'''
try:
# create mount point
self.execute_cmd('sudo mkdir ' + mount_point)
# mount images
self.execute_cmd('sudo mount -o loop ' + disk_i... | configure the image, copying the configurerepos.sh into it. | configure the image, copying the configurerepos.sh into it. | [
"configure",
"the",
"image",
"copying",
"the",
"configurerepos",
".",
"sh",
"into",
"it",
"."
] | def configure_image(self, disk_img, lock, mount_point):
try:
self.execute_cmd('sudo mkdir ' + mount_point)
self.execute_cmd('sudo mount -o loop ' + disk_img + ' ' + mount_point)
mtp = mount_point + "/home"
cmd = var.DOWNLOAD_DIR + 'configurerepos.sh' + ' ' + mtp
... | [
"def",
"configure_image",
"(",
"self",
",",
"disk_img",
",",
"lock",
",",
"mount_point",
")",
":",
"try",
":",
"self",
".",
"execute_cmd",
"(",
"'sudo mkdir '",
"+",
"mount_point",
")",
"self",
".",
"execute_cmd",
"(",
"'sudo mount -o loop '",
"+",
"disk_img",... | configure the image, copying the configurerepos.sh into it. | [
"configure",
"the",
"image",
"copying",
"the",
"configurerepos",
".",
"sh",
"into",
"it",
"."
] | [
"'''configure the image, copying the configurerepos.sh into it.'''",
"# create mount point",
"# mount images",
"# copy file inside the images",
"# umount",
"# remove mount point",
"# create lock file that block continuing customization"
] | [
{
"param": "self",
"type": null
},
{
"param": "disk_img",
"type": null
},
{
"param": "lock",
"type": null
},
{
"param": "mount_point",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "disk_img",
"type": null,
"docstring": null,
"docstring_tokens... |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | verify_dependencies | null | def verify_dependencies(self):
'''verify if the required dependencies are installed'''
self.print_line()
print " * Checking dependencies..."
try:
for dep in var.DEPENDENCIES:
if not self.cmd_exists(dep):
self.install_dependencies(dep)
... | verify if the required dependencies are installed | verify if the required dependencies are installed | [
"verify",
"if",
"the",
"required",
"dependencies",
"are",
"installed"
] | def verify_dependencies(self):
self.print_line()
print " * Checking dependencies..."
try:
for dep in var.DEPENDENCIES:
if not self.cmd_exists(dep):
self.install_dependencies(dep)
except (KeyboardInterrupt, SystemExit, RuntimeError):
... | [
"def",
"verify_dependencies",
"(",
"self",
")",
":",
"self",
".",
"print_line",
"(",
")",
"print",
"\" * Checking dependencies...\"",
"try",
":",
"for",
"dep",
"in",
"var",
".",
"DEPENDENCIES",
":",
"if",
"not",
"self",
".",
"cmd_exists",
"(",
"dep",
")",
... | verify if the required dependencies are installed | [
"verify",
"if",
"the",
"required",
"dependencies",
"are",
"installed"
] | [
"'''verify if the required dependencies are installed'''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | size_of | <not_specific> | def size_of(value):
'''return the size of file formated'''
for unit in ['', 'Ki', 'Mi']:
if abs(value) < 1024.0:
return "%3.1f %s%s" % (value, unit, 'B')
value = value / 1024.0
return "%.1f%s%s" % (value, 'Yi', 'B') | return the size of file formated | return the size of file formated | [
"return",
"the",
"size",
"of",
"file",
"formated"
] | def size_of(value):
for unit in ['', 'Ki', 'Mi']:
if abs(value) < 1024.0:
return "%3.1f %s%s" % (value, unit, 'B')
value = value / 1024.0
return "%.1f%s%s" % (value, 'Yi', 'B') | [
"def",
"size_of",
"(",
"value",
")",
":",
"for",
"unit",
"in",
"[",
"''",
",",
"'Ki'",
",",
"'Mi'",
"]",
":",
"if",
"abs",
"(",
"value",
")",
"<",
"1024.0",
":",
"return",
"\"%3.1f %s%s\"",
"%",
"(",
"value",
",",
"unit",
",",
"'B'",
")",
"value"... | return the size of file formated | [
"return",
"the",
"size",
"of",
"file",
"formated"
] | [
"'''return the size of file formated'''"
] | [
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | configure_license | null | def configure_license():
'''extract and convert the license from dos to unix'''
try:
licensezip = zipfile.ZipFile(var.LICENSE_FILE_ZIP, 'r')
licensezip.extractall(var.DOWNLOAD_DIR)
licensezip.close()
licensetext = open(var.LICENSE, 'rb').read().replace('\r... | extract and convert the license from dos to unix | extract and convert the license from dos to unix | [
"extract",
"and",
"convert",
"the",
"license",
"from",
"dos",
"to",
"unix"
] | def configure_license():
try:
licensezip = zipfile.ZipFile(var.LICENSE_FILE_ZIP, 'r')
licensezip.extractall(var.DOWNLOAD_DIR)
licensezip.close()
licensetext = open(var.LICENSE, 'rb').read().replace('\r\n', '\n')
open(var.LICENSE, 'wb').write(licensetex... | [
"def",
"configure_license",
"(",
")",
":",
"try",
":",
"licensezip",
"=",
"zipfile",
".",
"ZipFile",
"(",
"var",
".",
"LICENSE_FILE_ZIP",
",",
"'r'",
")",
"licensezip",
".",
"extractall",
"(",
"var",
".",
"DOWNLOAD_DIR",
")",
"licensezip",
".",
"close",
"(... | extract and convert the license from dos to unix | [
"extract",
"and",
"convert",
"the",
"license",
"from",
"dos",
"to",
"unix"
] | [
"'''extract and convert the license from dos to unix'''"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
47aeb7b3c564ae5e402a70ebbb920f412d227c64 | open-power-sdk/power-simulator | mambo/core.py | [
"Apache-2.0"
] | Python | show_connection_info | <not_specific> | def show_connection_info(self, version):
'''Show to the user how to connect to the simulator'''
try:
self.print_line()
sversion = 'IBM POWER' + version[-1:] + ' Functional Simulator'
print '\nYou are starting the ' + sversion
print 'When the boot process i... | Show to the user how to connect to the simulator | Show to the user how to connect to the simulator | [
"Show",
"to",
"the",
"user",
"how",
"to",
"connect",
"to",
"the",
"simulator"
] | def show_connection_info(self, version):
try:
self.print_line()
sversion = 'IBM POWER' + version[-1:] + ' Functional Simulator'
print '\nYou are starting the ' + sversion
print 'When the boot process is complete, use the following'
print 'credentials t... | [
"def",
"show_connection_info",
"(",
"self",
",",
"version",
")",
":",
"try",
":",
"self",
".",
"print_line",
"(",
")",
"sversion",
"=",
"'IBM POWER'",
"+",
"version",
"[",
"-",
"1",
":",
"]",
"+",
"' Functional Simulator'",
"print",
"'\\nYou are starting the '... | Show to the user how to connect to the simulator | [
"Show",
"to",
"the",
"user",
"how",
"to",
"connect",
"to",
"the",
"simulator"
] | [
"'''Show to the user how to connect to the simulator'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version",
"type": null,
"docstring": null,
"docstring_tokens"... |
54db95a137d4663453df6f582099d114064b92ca | ID56/HEAR-2021-Audio-MAE | hearaudiomlp/kwmlp/common_api.py | [
"MIT"
] | Python | load_model | nn.Module | def load_model(model_file_path: str) -> nn.Module:
"""Loads model weights from provided path.
Args:
model_file_path (str): Provided checkpoint path.
Returns:
nn.Module: Model instance.
"""
embed_dim = 64
scene_dim = 1024
encoder_type = "kwmlp"
model = AudioMLP_Wrapper... | Loads model weights from provided path.
Args:
model_file_path (str): Provided checkpoint path.
Returns:
nn.Module: Model instance.
| Loads model weights from provided path. | [
"Loads",
"model",
"weights",
"from",
"provided",
"path",
"."
] | def load_model(model_file_path: str) -> nn.Module:
embed_dim = 64
scene_dim = 1024
encoder_type = "kwmlp"
model = AudioMLP_Wrapper(
sample_rate=16000,
timestamp_embedding_size=embed_dim,
scene_embedding_size=scene_dim,
encoder_type=encoder_type,
encoder_ckpt=model... | [
"def",
"load_model",
"(",
"model_file_path",
":",
"str",
")",
"->",
"nn",
".",
"Module",
":",
"embed_dim",
"=",
"64",
"scene_dim",
"=",
"1024",
"encoder_type",
"=",
"\"kwmlp\"",
"model",
"=",
"AudioMLP_Wrapper",
"(",
"sample_rate",
"=",
"16000",
",",
"timest... | Loads model weights from provided path. | [
"Loads",
"model",
"weights",
"from",
"provided",
"path",
"."
] | [
"\"\"\"Loads model weights from provided path.\n\n Args:\n model_file_path (str): Provided checkpoint path.\n\n Returns:\n nn.Module: Model instance.\n \"\"\""
] | [
{
"param": "model_file_path",
"type": "str"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "nn.Module"
}
],
"raises": [],
"params": [
{
"identifier": "model_file_path",
"type": "str",
"docstring": "Provided checkpoint path.",
"docstring_tokens": [
"Pr... |
a791cf621d81cb80f4c959265dcca3b585116712 | ID56/HEAR-2021-Audio-MAE | hearaudiomlp/kwmlp/utils.py | [
"MIT"
] | Python | initial_padding | Tensor | def initial_padding(audio: Tensor, sr=16000, hop_ms=10, window_ms=30) -> Tensor:
"""Do some initial padding in order to get embeddings at the start/end of audio.
Args:
audio (Tensor): n_sounds x n_samples of mono audio.
sr (int, optional): Sample rate. Defaults to 16000.
hop_ms (int, op... | Do some initial padding in order to get embeddings at the start/end of audio.
Args:
audio (Tensor): n_sounds x n_samples of mono audio.
sr (int, optional): Sample rate. Defaults to 16000.
hop_ms (int, optional): Hop length in ms. Defaults to 10.
window_ms (int, optional): Window len... | Do some initial padding in order to get embeddings at the start/end of audio. | [
"Do",
"some",
"initial",
"padding",
"in",
"order",
"to",
"get",
"embeddings",
"at",
"the",
"start",
"/",
"end",
"of",
"audio",
"."
] | def initial_padding(audio: Tensor, sr=16000, hop_ms=10, window_ms=30) -> Tensor:
init_pad = int((window_ms // 2 - hop_ms) / 1000 * sr) if window_ms // 2 > hop_ms else 0
end_pad = int((window_ms // 2 ) / 1000 * sr)
return F.pad(audio, (init_pad, end_pad), "constant", 0) | [
"def",
"initial_padding",
"(",
"audio",
":",
"Tensor",
",",
"sr",
"=",
"16000",
",",
"hop_ms",
"=",
"10",
",",
"window_ms",
"=",
"30",
")",
"->",
"Tensor",
":",
"init_pad",
"=",
"int",
"(",
"(",
"window_ms",
"//",
"2",
"-",
"hop_ms",
")",
"/",
"100... | Do some initial padding in order to get embeddings at the start/end of audio. | [
"Do",
"some",
"initial",
"padding",
"in",
"order",
"to",
"get",
"embeddings",
"at",
"the",
"start",
"/",
"end",
"of",
"audio",
"."
] | [
"\"\"\"Do some initial padding in order to get embeddings at the start/end of audio.\n\n Args:\n audio (Tensor): n_sounds x n_samples of mono audio.\n sr (int, optional): Sample rate. Defaults to 16000.\n hop_ms (int, optional): Hop length in ms. Defaults to 10.\n window_ms (int, opti... | [
{
"param": "audio",
"type": "Tensor"
},
{
"param": "sr",
"type": null
},
{
"param": "hop_ms",
"type": null
},
{
"param": "window_ms",
"type": null
}
] | {
"returns": [
{
"docstring": "n_sounds x n_samples_padded.",
"docstring_tokens": [
"n_sounds",
"x",
"n_samples_padded",
"."
],
"type": "Tensor"
}
],
"raises": [],
"params": [
{
"identifier": "audio",
"type": "Tensor",
"docstr... |
f775a7691edd2132f7b3462ca4377a935b3efcde | ATMOcanes/tropycal | src/tropycal/recon/dataset.py | [
"MIT"
] | Python | findMission | <not_specific> | def findMission(self,time):
r"""
Returns the name of a mission or list of missions given a specified time.
Parameters
----------
time : datetime.datetime or list
Datetime object or list of datetime objects representing the time of the requested missi... | r"""
Returns the name of a mission or list of missions given a specified time.
Parameters
----------
time : datetime.datetime or list
Datetime object or list of datetime objects representing the time of the requested mission.
Returns
-------
... | r"""
Returns the name of a mission or list of missions given a specified time.
Parameters
time : datetime.datetime or list
Datetime object or list of datetime objects representing the time of the requested mission.
Returns
list
The names of any/all missions that had in-storm observations during the specified time. | [
"r",
"\"",
"\"",
"\"",
"Returns",
"the",
"name",
"of",
"a",
"mission",
"or",
"list",
"of",
"missions",
"given",
"a",
"specified",
"time",
".",
"Parameters",
"time",
":",
"datetime",
".",
"datetime",
"or",
"list",
"Datetime",
"object",
"or",
"list",
"of",... | def findMission(self,time):
if isinstance(time,list):
t1=min(time)
t2=max(time)
else:
t1 = t2 = time
selected=[]
for name in self.missiondata:
t_start = min(self.missiondata[name]['time'])
t_end = max(self.missiondata[name]['tim... | [
"def",
"findMission",
"(",
"self",
",",
"time",
")",
":",
"if",
"isinstance",
"(",
"time",
",",
"list",
")",
":",
"t1",
"=",
"min",
"(",
"time",
")",
"t2",
"=",
"max",
"(",
"time",
")",
"else",
":",
"t1",
"=",
"t2",
"=",
"time",
"selected",
"="... | r"""
Returns the name of a mission or list of missions given a specified time. | [
"r",
"\"",
"\"",
"\"",
"Returns",
"the",
"name",
"of",
"a",
"mission",
"or",
"list",
"of",
"missions",
"given",
"a",
"specified",
"time",
"."
] | [
"r\"\"\"\n Returns the name of a mission or list of missions given a specified time.\n \n Parameters\n ----------\n time : datetime.datetime or list\n Datetime object or list of datetime objects representing the time of the requested mission.\n \n Returns\... | [
{
"param": "self",
"type": null
},
{
"param": "time",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "time",
"type": null,
"docstring": null,
"docstring_tokens": [... |
f775a7691edd2132f7b3462ca4377a935b3efcde | ATMOcanes/tropycal | src/tropycal/recon/dataset.py | [
"MIT"
] | Python | plot_hovmoller | <not_specific> | def plot_hovmoller(self,recon_select=None,varname='wspd',radlim=None,track_dict=None,plane_p_range=None,\
window=6,align='center',ax=None,return_ax=False,**kwargs):
r"""
Creates a hovmoller plot of azimuthally-averaged recon data.
Parameters
-----... | r"""
Creates a hovmoller plot of azimuthally-averaged recon data.
Parameters
----------
recon_select : Requested recon data
pandas.DataFrame or dict,
or datetime or list of start/end datetimes.
varname : Variable to average and plot (e.g. 'wspd').... | r"""
Creates a hovmoller plot of azimuthally-averaged recon data.
Parameters
recon_select : Requested recon data
pandas.DataFrame or dict,
or datetime or list of start/end datetimes.
varname : Variable to average and plot .
String
ax : axes
Instance of axes to plot on. If none, one will be generated. Default is none.... | [
"r",
"\"",
"\"",
"\"",
"Creates",
"a",
"hovmoller",
"plot",
"of",
"azimuthally",
"-",
"averaged",
"recon",
"data",
".",
"Parameters",
"recon_select",
":",
"Requested",
"recon",
"data",
"pandas",
".",
"DataFrame",
"or",
"dict",
"or",
"datetime",
"or",
"list",... | def plot_hovmoller(self,recon_select=None,varname='wspd',radlim=None,track_dict=None,plane_p_range=None,\
window=6,align='center',ax=None,return_ax=False,**kwargs):
prop = kwargs.pop('prop',{})
default_prop = {'cmap':'category','levels':None,'smooth_contourf':False}
for ke... | [
"def",
"plot_hovmoller",
"(",
"self",
",",
"recon_select",
"=",
"None",
",",
"varname",
"=",
"'wspd'",
",",
"radlim",
"=",
"None",
",",
"track_dict",
"=",
"None",
",",
"plane_p_range",
"=",
"None",
",",
"window",
"=",
"6",
",",
"align",
"=",
"'center'",
... | r"""
Creates a hovmoller plot of azimuthally-averaged recon data. | [
"r",
"\"",
"\"",
"\"",
"Creates",
"a",
"hovmoller",
"plot",
"of",
"azimuthally",
"-",
"averaged",
"recon",
"data",
"."
] | [
"r\"\"\"\n Creates a hovmoller plot of azimuthally-averaged recon data.\n \n Parameters\n ----------\n recon_select : Requested recon data\n pandas.DataFrame or dict,\n or datetime or list of start/end datetimes.\n varname : Variable to average and plo... | [
{
"param": "self",
"type": null
},
{
"param": "recon_select",
"type": null
},
{
"param": "varname",
"type": null
},
{
"param": "radlim",
"type": null
},
{
"param": "track_dict",
"type": null
},
{
"param": "plane_p_range",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "recon_select",
"type": null,
"docstring": null,
"docstring_to... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | interp | <not_specific> | def interp(self,timeres=1,dt_window=24,dt_align='middle'):
r"""
Interpolate a storm temporally to a specified time resolution.
Parameters
----------
timeres : int
Temporal resolution in hours to interpolate storm data to. Default is 1 hour.
d... | r"""
Interpolate a storm temporally to a specified time resolution.
Parameters
----------
timeres : int
Temporal resolution in hours to interpolate storm data to. Default is 1 hour.
dt_window : int
Time window in hours over which to calculate temp... | r"""
Interpolate a storm temporally to a specified time resolution.
Parameters
timeres : int
Temporal resolution in hours to interpolate storm data to. Default is 1 hour.
dt_window : int
Time window in hours over which to calculate temporal change data. Default is 24 hours.
Returns
tropycal.tracks.Storm
New Storm o... | [
"r",
"\"",
"\"",
"\"",
"Interpolate",
"a",
"storm",
"temporally",
"to",
"a",
"specified",
"time",
"resolution",
".",
"Parameters",
"timeres",
":",
"int",
"Temporal",
"resolution",
"in",
"hours",
"to",
"interpolate",
"storm",
"data",
"to",
".",
"Default",
"is... | def interp(self,timeres=1,dt_window=24,dt_align='middle'):
NEW_STORM = copy.copy(self)
newdict = interp_storm(self.dict,timeres,dt_window,dt_align)
for key in newdict.keys():
NEW_STORM.dict[key] = newdict[key]
for key in NEW_STORM.dict.keys():
if key == 'realtime... | [
"def",
"interp",
"(",
"self",
",",
"timeres",
"=",
"1",
",",
"dt_window",
"=",
"24",
",",
"dt_align",
"=",
"'middle'",
")",
":",
"NEW_STORM",
"=",
"copy",
".",
"copy",
"(",
"self",
")",
"newdict",
"=",
"interp_storm",
"(",
"self",
".",
"dict",
",",
... | r"""
Interpolate a storm temporally to a specified time resolution. | [
"r",
"\"",
"\"",
"\"",
"Interpolate",
"a",
"storm",
"temporally",
"to",
"a",
"specified",
"time",
"resolution",
"."
] | [
"r\"\"\"\n Interpolate a storm temporally to a specified time resolution.\n \n Parameters\n ----------\n timeres : int\n Temporal resolution in hours to interpolate storm data to. Default is 1 hour.\n dt_window : int\n Time window in hours over which t... | [
{
"param": "self",
"type": null
},
{
"param": "timeres",
"type": null
},
{
"param": "dt_window",
"type": null
},
{
"param": "dt_align",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "timeres",
"type": null,
"docstring": null,
"docstring_tokens"... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | to_xarray | <not_specific> | def to_xarray(self):
r"""
Converts the storm dict into an xarray Dataset object.
Returns
-------
xarray.Dataset
An xarray Dataset object containing information about the storm.
"""
#Try importing xarray
try:
... | r"""
Converts the storm dict into an xarray Dataset object.
Returns
-------
xarray.Dataset
An xarray Dataset object containing information about the storm.
| r"""
Converts the storm dict into an xarray Dataset object.
Returns
xarray.Dataset
An xarray Dataset object containing information about the storm. | [
"r",
"\"",
"\"",
"\"",
"Converts",
"the",
"storm",
"dict",
"into",
"an",
"xarray",
"Dataset",
"object",
".",
"Returns",
"xarray",
".",
"Dataset",
"An",
"xarray",
"Dataset",
"object",
"containing",
"information",
"about",
"the",
"storm",
"."
] | def to_xarray(self):
try:
import xarray as xr
except ImportError as e:
raise RuntimeError("Error: xarray is not available. Install xarray in order to use this function.") from e
time = self.dict['date']
ds = {}
attrs = {}
keys = [k for k in self.di... | [
"def",
"to_xarray",
"(",
"self",
")",
":",
"try",
":",
"import",
"xarray",
"as",
"xr",
"except",
"ImportError",
"as",
"e",
":",
"raise",
"RuntimeError",
"(",
"\"Error: xarray is not available. Install xarray in order to use this function.\"",
")",
"from",
"e",
"time",... | r"""
Converts the storm dict into an xarray Dataset object. | [
"r",
"\"",
"\"",
"\"",
"Converts",
"the",
"storm",
"dict",
"into",
"an",
"xarray",
"Dataset",
"object",
"."
] | [
"r\"\"\"\n Converts the storm dict into an xarray Dataset object.\n \n Returns\n -------\n xarray.Dataset\n An xarray Dataset object containing information about the storm.\n \"\"\"",
"#Try importing xarray",
"#Set up empty dict for dataset",
"#Add every ke... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | to_dataframe | <not_specific> | def to_dataframe(self, attrs_as_columns=False):
r"""
Converts the storm dict into a pandas DataFrame object.
Parameters
----------
attrs_as_columns : bool
If True, adds Storm object attributes as columns in the DataFrame returned. Default is False.
... | r"""
Converts the storm dict into a pandas DataFrame object.
Parameters
----------
attrs_as_columns : bool
If True, adds Storm object attributes as columns in the DataFrame returned. Default is False.
Returns
-------
pandas.DataFrame
... | r"""
Converts the storm dict into a pandas DataFrame object.
Parameters
attrs_as_columns : bool
If True, adds Storm object attributes as columns in the DataFrame returned. Default is False.
Returns
pandas.DataFrame
A pandas DataFrame object containing information about the storm. | [
"r",
"\"",
"\"",
"\"",
"Converts",
"the",
"storm",
"dict",
"into",
"a",
"pandas",
"DataFrame",
"object",
".",
"Parameters",
"attrs_as_columns",
":",
"bool",
"If",
"True",
"adds",
"Storm",
"object",
"attributes",
"as",
"columns",
"in",
"the",
"DataFrame",
"re... | def to_dataframe(self, attrs_as_columns=False):
try:
import pandas as pd
except ImportError as e:
raise RuntimeError("Error: pandas is not available. Install pandas in order to use this function.") from e
time = self.dict['date']
ds = {}
keys = [k for k in... | [
"def",
"to_dataframe",
"(",
"self",
",",
"attrs_as_columns",
"=",
"False",
")",
":",
"try",
":",
"import",
"pandas",
"as",
"pd",
"except",
"ImportError",
"as",
"e",
":",
"raise",
"RuntimeError",
"(",
"\"Error: pandas is not available. Install pandas in order to use th... | r"""
Converts the storm dict into a pandas DataFrame object. | [
"r",
"\"",
"\"",
"\"",
"Converts",
"the",
"storm",
"dict",
"into",
"a",
"pandas",
"DataFrame",
"object",
"."
] | [
"r\"\"\"\n Converts the storm dict into a pandas DataFrame object.\n \n Parameters\n ----------\n attrs_as_columns : bool\n If True, adds Storm object attributes as columns in the DataFrame returned. Default is False.\n \n Returns\n -------\n ... | [
{
"param": "self",
"type": null
},
{
"param": "attrs_as_columns",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attrs_as_columns",
"type": null,
"docstring": null,
"docstrin... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | query_nhc_discussions | <not_specific> | def query_nhc_discussions(self,query):
r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm.
Parameters
----------
query : str or list
String or list representing a word(s) or phrase(s) to search for within t... | r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm.
Parameters
----------
query : str or list
String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions (e.g., "rapid intensificatio... | r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm.
Parameters
query : str or list
String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions . Query is case insensitive.
Returns
list
List of dictionaries containing all relevant f... | [
"r",
"\"",
"\"",
"\"",
"Searches",
"for",
"the",
"given",
"word",
"or",
"phrase",
"through",
"all",
"NHC",
"forecast",
"discussions",
"for",
"this",
"storm",
".",
"Parameters",
"query",
":",
"str",
"or",
"list",
"String",
"or",
"list",
"representing",
"a",... | def query_nhc_discussions(self,query):
if self.source != "hurdat":
msg = "Error: NHC data can only be accessed when HURDAT is used as the data source."
raise RuntimeError(msg)
if self.invest:
raise RuntimeError("Error: NHC does not issue advisories for invests that ha... | [
"def",
"query_nhc_discussions",
"(",
"self",
",",
"query",
")",
":",
"if",
"self",
".",
"source",
"!=",
"\"hurdat\"",
":",
"msg",
"=",
"\"Error: NHC data can only be accessed when HURDAT is used as the data source.\"",
"raise",
"RuntimeError",
"(",
"msg",
")",
"if",
"... | r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm. | [
"r",
"\"",
"\"",
"\"",
"Searches",
"for",
"the",
"given",
"word",
"or",
"phrase",
"through",
"all",
"NHC",
"forecast",
"discussions",
"for",
"this",
"storm",
"."
] | [
"r\"\"\"\n Searches for the given word or phrase through all NHC forecast discussions for this storm.\n \n Parameters\n ----------\n query : str or list\n String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions (e.g., \"rapid... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | download_tcr | null | def download_tcr(self,save_path=""):
r"""
Downloads the NHC offical Tropical Cyclone Report (TCR) for the requested storm to the requested directory. Available only for storms with advisories issued by the National Hurricane Center.
Parameters
----------
save_pa... | r"""
Downloads the NHC offical Tropical Cyclone Report (TCR) for the requested storm to the requested directory. Available only for storms with advisories issued by the National Hurricane Center.
Parameters
----------
save_path : str
Path of directory to download the... | r"""
Downloads the NHC offical Tropical Cyclone Report (TCR) for the requested storm to the requested directory. Available only for storms with advisories issued by the National Hurricane Center.
Parameters
save_path : str
Path of directory to download the TCR into. Default is current working directory. | [
"r",
"\"",
"\"",
"\"",
"Downloads",
"the",
"NHC",
"offical",
"Tropical",
"Cyclone",
"Report",
"(",
"TCR",
")",
"for",
"the",
"requested",
"storm",
"to",
"the",
"requested",
"directory",
".",
"Available",
"only",
"for",
"storms",
"with",
"advisories",
"issued... | def download_tcr(self,save_path=""):
if self.invest:
raise RuntimeError("Error: NHC does not issue advisories for invests that have not been designated as Potential Tropical Cyclones.")
if self.source != "hurdat":
msg = "NHC data can only be accessed when HURDAT is used as the da... | [
"def",
"download_tcr",
"(",
"self",
",",
"save_path",
"=",
"\"\"",
")",
":",
"if",
"self",
".",
"invest",
":",
"raise",
"RuntimeError",
"(",
"\"Error: NHC does not issue advisories for invests that have not been designated as Potential Tropical Cyclones.\"",
")",
"if",
"sel... | r"""
Downloads the NHC offical Tropical Cyclone Report (TCR) for the requested storm to the requested directory. | [
"r",
"\"",
"\"",
"\"",
"Downloads",
"the",
"NHC",
"offical",
"Tropical",
"Cyclone",
"Report",
"(",
"TCR",
")",
"for",
"the",
"requested",
"storm",
"to",
"the",
"requested",
"directory",
"."
] | [
"r\"\"\"\n Downloads the NHC offical Tropical Cyclone Report (TCR) for the requested storm to the requested directory. Available only for storms with advisories issued by the National Hurricane Center.\n \n Parameters\n ----------\n save_path : str\n Path of directory t... | [
{
"param": "self",
"type": null
},
{
"param": "save_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "save_path",
"type": null,
"docstring": null,
"docstring_token... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | plot_tors | <not_specific> | def plot_tors(self,dist_thresh=1000,Tors=None,domain="dynamic",plotPPH=False,plot_all=False,\
ax=None,cartopy_proj=None,save_path=None,prop={},map_prop={}):
r"""
Creates a plot of the storm and associated tornado tracks.
Parameters
----------
... | r"""
Creates a plot of the storm and associated tornado tracks.
Parameters
----------
dist_thresh : int
Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km.
Tors : pandas.DataFrame... | r"""
Creates a plot of the storm and associated tornado tracks.
Parameters
dist_thresh : int
Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km.
Tors : pandas.DataFrame
DataFrame containing tornado data associated with the storm. If None,... | [
"r",
"\"",
"\"",
"\"",
"Creates",
"a",
"plot",
"of",
"the",
"storm",
"and",
"associated",
"tornado",
"tracks",
".",
"Parameters",
"dist_thresh",
":",
"int",
"Distance",
"threshold",
"(",
"in",
"kilometers",
")",
"from",
"the",
"tropical",
"cyclone",
"track",... | def plot_tors(self,dist_thresh=1000,Tors=None,domain="dynamic",plotPPH=False,plot_all=False,\
ax=None,cartopy_proj=None,save_path=None,prop={},map_prop={}):
try:
prop['PPHcolors']
except:
prop['PPHcolors']='Wistia'
if Tors is None:
try:
... | [
"def",
"plot_tors",
"(",
"self",
",",
"dist_thresh",
"=",
"1000",
",",
"Tors",
"=",
"None",
",",
"domain",
"=",
"\"dynamic\"",
",",
"plotPPH",
"=",
"False",
",",
"plot_all",
"=",
"False",
",",
"ax",
"=",
"None",
",",
"cartopy_proj",
"=",
"None",
",",
... | r"""
Creates a plot of the storm and associated tornado tracks. | [
"r",
"\"",
"\"",
"\"",
"Creates",
"a",
"plot",
"of",
"the",
"storm",
"and",
"associated",
"tornado",
"tracks",
"."
] | [
"r\"\"\"\n Creates a plot of the storm and associated tornado tracks.\n \n Parameters\n ----------\n dist_thresh : int\n Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km.\n Tors : p... | [
{
"param": "self",
"type": null
},
{
"param": "dist_thresh",
"type": null
},
{
"param": "Tors",
"type": null
},
{
"param": "domain",
"type": null
},
{
"param": "plotPPH",
"type": null
},
{
"param": "plot_all",
"type": null
},
{
"param": "ax... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dist_thresh",
"type": null,
"docstring": null,
"docstring_tok... |
2bbe438971fbf193a52431cf9131dccb31308bd8 | ATMOcanes/tropycal | src/tropycal/tracks/storm.py | [
"MIT"
] | Python | plot_TCtors_rotated | <not_specific> | def plot_TCtors_rotated(self,dist_thresh=1000,save_path=None):
r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
Parameters
----------
dist_thresh : int
Distance threshold (in kilometers) from the tropical cyc... | r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
Parameters
----------
dist_thresh : int
Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Igno... | r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
Parameters
dist_thresh : int
Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Ignored if tornado data was passed into Storm from TrackDataset.
s... | [
"r",
"\"",
"\"",
"\"",
"Plot",
"tracks",
"of",
"tornadoes",
"relative",
"to",
"the",
"storm",
"motion",
"vector",
"of",
"the",
"tropical",
"cyclone",
".",
"Parameters",
"dist_thresh",
":",
"int",
"Distance",
"threshold",
"(",
"in",
"kilometers",
")",
"from",... | def plot_TCtors_rotated(self,dist_thresh=1000,save_path=None):
try:
self.stormTors
dist_thresh = self.tornado_dist_thresh
except:
warn_message = "Reading in tornado data for this storm. If you seek to analyze tornado data for multiple storms, run \"TrackDataset.assign... | [
"def",
"plot_TCtors_rotated",
"(",
"self",
",",
"dist_thresh",
"=",
"1000",
",",
"save_path",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"stormTors",
"dist_thresh",
"=",
"self",
".",
"tornado_dist_thresh",
"except",
":",
"warn_message",
"=",
"\"Reading in... | r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone. | [
"r",
"\"",
"\"",
"\"",
"Plot",
"tracks",
"of",
"tornadoes",
"relative",
"to",
"the",
"storm",
"motion",
"vector",
"of",
"the",
"tropical",
"cyclone",
"."
] | [
"r\"\"\"\n Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.\n \n Parameters\n ----------\n dist_thresh : int\n Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is... | [
{
"param": "self",
"type": null
},
{
"param": "dist_thresh",
"type": null
},
{
"param": "save_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dist_thresh",
"type": null,
"docstring": null,
"docstring_tok... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.