repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
aarongarrett/inspyred | inspyred/ec/observers.py | file_observer | def file_observer(population, num_generations, num_evaluations, args):
"""Print the output of the evolutionary computation to a file.
This function saves the results of the evolutionary computation
to two files. The first file, which by default is named
'inspyred-statistics-file-<timestamp>.csv', ... | python | def file_observer(population, num_generations, num_evaluations, args):
"""Print the output of the evolutionary computation to a file.
This function saves the results of the evolutionary computation
to two files. The first file, which by default is named
'inspyred-statistics-file-<timestamp>.csv', ... | [
"def",
"file_observer",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"try",
":",
"statistics_file",
"=",
"args",
"[",
"'statistics_file'",
"]",
"except",
"KeyError",
":",
"statistics_file",
"=",
"open",
"(",
"'inspyre... | Print the output of the evolutionary computation to a file.
This function saves the results of the evolutionary computation
to two files. The first file, which by default is named
'inspyred-statistics-file-<timestamp>.csv', contains the basic
generational statistics of the population throughout th... | [
"Print",
"the",
"output",
"of",
"the",
"evolutionary",
"computation",
"to",
"a",
"file",
".",
"This",
"function",
"saves",
"the",
"results",
"of",
"the",
"evolutionary",
"computation",
"to",
"two",
"files",
".",
"The",
"first",
"file",
"which",
"by",
"defaul... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L135-L195 |
aarongarrett/inspyred | inspyred/ec/observers.py | archive_observer | def archive_observer(population, num_generations, num_evaluations, args):
"""Print the current archive to the screen.
This function displays the current archive of the evolutionary
computation to the screen.
.. Arguments:
population -- the population of Individuals
num_generati... | python | def archive_observer(population, num_generations, num_evaluations, args):
"""Print the current archive to the screen.
This function displays the current archive of the evolutionary
computation to the screen.
.. Arguments:
population -- the population of Individuals
num_generati... | [
"def",
"archive_observer",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"archive",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"archive",
"print",
"(",
"'----------------------------------------------------------------------------'",
... | Print the current archive to the screen.
This function displays the current archive of the evolutionary
computation to the screen.
.. Arguments:
population -- the population of Individuals
num_generations -- the number of elapsed generations
num_evaluations -- the number of ... | [
"Print",
"the",
"current",
"archive",
"to",
"the",
"screen",
".",
"This",
"function",
"displays",
"the",
"current",
"archive",
"of",
"the",
"evolutionary",
"computation",
"to",
"the",
"screen",
".",
"..",
"Arguments",
":",
"population",
"--",
"the",
"populatio... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L198-L217 |
aarongarrett/inspyred | inspyred/ec/observers.py | plot_observer | def plot_observer(population, num_generations, num_evaluations, args):
"""Plot the output of the evolutionary computation as a graph.
This function plots the performance of the EC as a line graph
using matplotlib and numpy. The graph consists of a blue line
representing the best fitness, a gr... | python | def plot_observer(population, num_generations, num_evaluations, args):
"""Plot the output of the evolutionary computation as a graph.
This function plots the performance of the EC as a line graph
using matplotlib and numpy. The graph consists of a blue line
representing the best fitness, a gr... | [
"def",
"plot_observer",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"numpy",
"stats",
"=",
"inspyred",
".",
"ec",
".",
"analysis",
".",
"fitness_statist... | Plot the output of the evolutionary computation as a graph.
This function plots the performance of the EC as a line graph
using matplotlib and numpy. The graph consists of a blue line
representing the best fitness, a green line representing the
average fitness, and a red line representing the me... | [
"Plot",
"the",
"output",
"of",
"the",
"evolutionary",
"computation",
"as",
"a",
"graph",
".",
"This",
"function",
"plots",
"the",
"performance",
"of",
"the",
"EC",
"as",
"a",
"line",
"graph",
"using",
"matplotlib",
"and",
"numpy",
".",
"The",
"graph",
"con... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L337-L407 |
aarongarrett/inspyred | inspyred/ec/terminators.py | diversity_termination | def diversity_termination(population, num_generations, num_evaluations, args):
"""Return True if population diversity is less than a minimum diversity.
This function calculates the Euclidean distance between every pair of
individuals in the population. It then compares the maximum of those
distance... | python | def diversity_termination(population, num_generations, num_evaluations, args):
"""Return True if population diversity is less than a minimum diversity.
This function calculates the Euclidean distance between every pair of
individuals in the population. It then compares the maximum of those
distance... | [
"def",
"diversity_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"min_diversity",
"=",
"args",
".",
"setdefault",
"(",
"'min_diversity'",
",",
"0.001",
")",
"cart_prod",
"=",
"itertools",
".",
"product",
"... | Return True if population diversity is less than a minimum diversity.
This function calculates the Euclidean distance between every pair of
individuals in the population. It then compares the maximum of those
distances with a specified minimum required diversity. This terminator
is really only wel... | [
"Return",
"True",
"if",
"population",
"diversity",
"is",
"less",
"than",
"a",
"minimum",
"diversity",
".",
"This",
"function",
"calculates",
"the",
"Euclidean",
"distance",
"between",
"every",
"pair",
"of",
"individuals",
"in",
"the",
"population",
".",
"It",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L69-L97 |
aarongarrett/inspyred | inspyred/ec/terminators.py | average_fitness_termination | def average_fitness_termination(population, num_generations, num_evaluations, args):
"""Return True if the population's average fitness is near its best fitness.
This function calculates the average fitness of the population, as well
as the best fitness. If the difference between those values is less
... | python | def average_fitness_termination(population, num_generations, num_evaluations, args):
"""Return True if the population's average fitness is near its best fitness.
This function calculates the average fitness of the population, as well
as the best fitness. If the difference between those values is less
... | [
"def",
"average_fitness_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"tolerance",
"=",
"args",
".",
"setdefault",
"(",
"'tolerance'",
",",
"0.001",
")",
"avg_fit",
"=",
"sum",
"(",
"[",
"x",
".",
"fi... | Return True if the population's average fitness is near its best fitness.
This function calculates the average fitness of the population, as well
as the best fitness. If the difference between those values is less
than a specified tolerance, the function returns True.
.. Arguments:
po... | [
"Return",
"True",
"if",
"the",
"population",
"s",
"average",
"fitness",
"is",
"near",
"its",
"best",
"fitness",
".",
"This",
"function",
"calculates",
"the",
"average",
"fitness",
"of",
"the",
"population",
"as",
"well",
"as",
"the",
"best",
"fitness",
".",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L100-L122 |
aarongarrett/inspyred | inspyred/ec/terminators.py | evaluation_termination | def evaluation_termination(population, num_generations, num_evaluations, args):
"""Return True if the number of function evaluations meets or exceeds a maximum.
This function compares the number of function evaluations that have been
generated with a specified maximum. It returns True if the maximum i... | python | def evaluation_termination(population, num_generations, num_evaluations, args):
"""Return True if the number of function evaluations meets or exceeds a maximum.
This function compares the number of function evaluations that have been
generated with a specified maximum. It returns True if the maximum i... | [
"def",
"evaluation_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"max_evaluations",
"=",
"args",
".",
"setdefault",
"(",
"'max_evaluations'",
",",
"len",
"(",
"population",
")",
")",
"return",
"num_evaluati... | Return True if the number of function evaluations meets or exceeds a maximum.
This function compares the number of function evaluations that have been
generated with a specified maximum. It returns True if the maximum is met
or exceeded.
.. Arguments:
population -- the population of In... | [
"Return",
"True",
"if",
"the",
"number",
"of",
"function",
"evaluations",
"meets",
"or",
"exceeds",
"a",
"maximum",
".",
"This",
"function",
"compares",
"the",
"number",
"of",
"function",
"evaluations",
"that",
"have",
"been",
"generated",
"with",
"a",
"specif... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L125-L145 |
aarongarrett/inspyred | inspyred/ec/terminators.py | generation_termination | def generation_termination(population, num_generations, num_evaluations, args):
"""Return True if the number of generations meets or exceeds a maximum.
This function compares the number of generations with a specified
maximum. It returns True if the maximum is met or exceeded.
.. Arguments:
... | python | def generation_termination(population, num_generations, num_evaluations, args):
"""Return True if the number of generations meets or exceeds a maximum.
This function compares the number of generations with a specified
maximum. It returns True if the maximum is met or exceeded.
.. Arguments:
... | [
"def",
"generation_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"max_generations",
"=",
"args",
".",
"setdefault",
"(",
"'max_generations'",
",",
"1",
")",
"return",
"num_generations",
">=",
"max_generations... | Return True if the number of generations meets or exceeds a maximum.
This function compares the number of generations with a specified
maximum. It returns True if the maximum is met or exceeded.
.. Arguments:
population -- the population of Individuals
num_generations -- the number ... | [
"Return",
"True",
"if",
"the",
"number",
"of",
"generations",
"meets",
"or",
"exceeds",
"a",
"maximum",
".",
"This",
"function",
"compares",
"the",
"number",
"of",
"generations",
"with",
"a",
"specified",
"maximum",
".",
"It",
"returns",
"True",
"if",
"the",... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L148-L166 |
aarongarrett/inspyred | inspyred/ec/terminators.py | time_termination | def time_termination(population, num_generations, num_evaluations, args):
"""Return True if the elapsed time meets or exceeds a duration of time.
This function compares the elapsed time with a specified maximum.
It returns True if the maximum is met or exceeded. If the `start_time`
keyword argumen... | python | def time_termination(population, num_generations, num_evaluations, args):
"""Return True if the elapsed time meets or exceeds a duration of time.
This function compares the elapsed time with a specified maximum.
It returns True if the maximum is met or exceeded. If the `start_time`
keyword argumen... | [
"def",
"time_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"start_time",
"=",
"args",
".",
"setdefault",
"(",
"'start_time'",
",",
"None",
")",
"max_time",
"=",
"args",
".",
"setdefault",
"(",
"'max_tim... | Return True if the elapsed time meets or exceeds a duration of time.
This function compares the elapsed time with a specified maximum.
It returns True if the maximum is met or exceeded. If the `start_time`
keyword argument is omitted, it defaults to `None` and will be set to
the current system tim... | [
"Return",
"True",
"if",
"the",
"elapsed",
"time",
"meets",
"or",
"exceeds",
"a",
"duration",
"of",
"time",
".",
"This",
"function",
"compares",
"the",
"elapsed",
"time",
"with",
"a",
"specified",
"maximum",
".",
"It",
"returns",
"True",
"if",
"the",
"maxim... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L169-L214 |
aarongarrett/inspyred | inspyred/ec/terminators.py | user_termination | def user_termination(population, num_generations, num_evaluations, args):
"""Return True if user presses the ESC key when prompted.
This function prompts the user to press the ESC key to terminate the
evolution. The prompt persists for a specified number of seconds before
evolution continues. Addi... | python | def user_termination(population, num_generations, num_evaluations, args):
"""Return True if user presses the ESC key when prompted.
This function prompts the user to press the ESC key to terminate the
evolution. The prompt persists for a specified number of seconds before
evolution continues. Addi... | [
"def",
"user_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"def",
"getch",
"(",
")",
":",
"unix",
"=",
"(",
"'darwin'",
",",
"'linux2'",
")",
"if",
"sys",
".",
"platform",
"not",
"in",
"unix",
":"... | Return True if user presses the ESC key when prompted.
This function prompts the user to press the ESC key to terminate the
evolution. The prompt persists for a specified number of seconds before
evolution continues. Additionally, the function can be customized to
allow any press of the ESC key t... | [
"Return",
"True",
"if",
"user",
"presses",
"the",
"ESC",
"key",
"when",
"prompted",
".",
"This",
"function",
"prompts",
"the",
"user",
"to",
"press",
"the",
"ESC",
"key",
"to",
"terminate",
"the",
"evolution",
".",
"The",
"prompt",
"persists",
"for",
"a",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L217-L282 |
aarongarrett/inspyred | inspyred/ec/terminators.py | no_improvement_termination | def no_improvement_termination(population, num_generations, num_evaluations, args):
"""Return True if the best fitness does not change for a number of generations.
This function keeps track of the current best fitness and compares it to
the best fitness in previous generations. Whenever those values ar... | python | def no_improvement_termination(population, num_generations, num_evaluations, args):
"""Return True if the best fitness does not change for a number of generations.
This function keeps track of the current best fitness and compares it to
the best fitness in previous generations. Whenever those values ar... | [
"def",
"no_improvement_termination",
"(",
"population",
",",
"num_generations",
",",
"num_evaluations",
",",
"args",
")",
":",
"max_generations",
"=",
"args",
".",
"setdefault",
"(",
"'max_generations'",
",",
"10",
")",
"previous_best",
"=",
"args",
".",
"setdefau... | Return True if the best fitness does not change for a number of generations.
This function keeps track of the current best fitness and compares it to
the best fitness in previous generations. Whenever those values are the
same, it begins a generation count. If that count exceeds a specified
numbe... | [
"Return",
"True",
"if",
"the",
"best",
"fitness",
"does",
"not",
"change",
"for",
"a",
"number",
"of",
"generations",
".",
"This",
"function",
"keeps",
"track",
"of",
"the",
"current",
"best",
"fitness",
"and",
"compares",
"it",
"to",
"the",
"best",
"fitne... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/terminators.py#L285-L316 |
aarongarrett/inspyred | inspyred/benchmarks.py | DTLZ2.global_optimum | def global_optimum(self):
"""Return a globally optimal solution to this problem.
This function returns a globally optimal solution (i.e., a
solution that lives on the Pareto front). Since there are many
solutions that are Pareto-optimal, this function randomly
chooses ... | python | def global_optimum(self):
"""Return a globally optimal solution to this problem.
This function returns a globally optimal solution (i.e., a
solution that lives on the Pareto front). Since there are many
solutions that are Pareto-optimal, this function randomly
chooses ... | [
"def",
"global_optimum",
"(",
"self",
")",
":",
"x",
"=",
"[",
"random",
".",
"uniform",
"(",
"0",
",",
"1",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"objectives",
"-",
"1",
")",
"]",
"x",
".",
"extend",
"(",
"[",
"0.5",
"for",
"_",
... | Return a globally optimal solution to this problem.
This function returns a globally optimal solution (i.e., a
solution that lives on the Pareto front). Since there are many
solutions that are Pareto-optimal, this function randomly
chooses one to return. | [
"Return",
"a",
"globally",
"optimal",
"solution",
"to",
"this",
"problem",
".",
"This",
"function",
"returns",
"a",
"globally",
"optimal",
"solution",
"(",
"i",
".",
"e",
".",
"a",
"solution",
"that",
"lives",
"on",
"the",
"Pareto",
"front",
")",
".",
"S... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L552-L563 |
aarongarrett/inspyred | inspyred/benchmarks.py | TSP.generator | def generator(self, random, args):
"""Return a candidate solution for an evolutionary computation."""
locations = [i for i in range(len(self.weights))]
random.shuffle(locations)
return locations | python | def generator(self, random, args):
"""Return a candidate solution for an evolutionary computation."""
locations = [i for i in range(len(self.weights))]
random.shuffle(locations)
return locations | [
"def",
"generator",
"(",
"self",
",",
"random",
",",
"args",
")",
":",
"locations",
"=",
"[",
"i",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"weights",
")",
")",
"]",
"random",
".",
"shuffle",
"(",
"locations",
")",
"return",
"locati... | Return a candidate solution for an evolutionary computation. | [
"Return",
"a",
"candidate",
"solution",
"for",
"an",
"evolutionary",
"computation",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L980-L984 |
aarongarrett/inspyred | inspyred/benchmarks.py | TSP.constructor | def constructor(self, random, args):
"""Return a candidate solution for an ant colony optimization."""
self._use_ants = True
candidate = []
while len(candidate) < len(self.weights) - 1:
# Find feasible components
feasible_components = []
if len(candida... | python | def constructor(self, random, args):
"""Return a candidate solution for an ant colony optimization."""
self._use_ants = True
candidate = []
while len(candidate) < len(self.weights) - 1:
# Find feasible components
feasible_components = []
if len(candida... | [
"def",
"constructor",
"(",
"self",
",",
"random",
",",
"args",
")",
":",
"self",
".",
"_use_ants",
"=",
"True",
"candidate",
"=",
"[",
"]",
"while",
"len",
"(",
"candidate",
")",
"<",
"len",
"(",
"self",
".",
"weights",
")",
"-",
"1",
":",
"# Find ... | Return a candidate solution for an ant colony optimization. | [
"Return",
"a",
"candidate",
"solution",
"for",
"an",
"ant",
"colony",
"optimization",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L986-L1014 |
aarongarrett/inspyred | inspyred/benchmarks.py | TSP.evaluator | def evaluator(self, candidates, args):
"""Return the fitness values for the given candidates."""
fitness = []
if self._use_ants:
for candidate in candidates:
total = 0
for c in candidate:
total += self.weights[c.element[0]][c.elemen... | python | def evaluator(self, candidates, args):
"""Return the fitness values for the given candidates."""
fitness = []
if self._use_ants:
for candidate in candidates:
total = 0
for c in candidate:
total += self.weights[c.element[0]][c.elemen... | [
"def",
"evaluator",
"(",
"self",
",",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"if",
"self",
".",
"_use_ants",
":",
"for",
"candidate",
"in",
"candidates",
":",
"total",
"=",
"0",
"for",
"c",
"in",
"candidate",
":",
"total",
"+=... | Return the fitness values for the given candidates. | [
"Return",
"the",
"fitness",
"values",
"for",
"the",
"given",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L1016-L1033 |
aarongarrett/inspyred | inspyred/benchmarks.py | Knapsack.generator | def generator(self, random, args):
"""Return a candidate solution for an evolutionary computation."""
if self.duplicates:
max_count = [self.capacity // item[0] for item in self.items]
return [random.randint(0, m) for m in max_count]
else:
return [random.choice... | python | def generator(self, random, args):
"""Return a candidate solution for an evolutionary computation."""
if self.duplicates:
max_count = [self.capacity // item[0] for item in self.items]
return [random.randint(0, m) for m in max_count]
else:
return [random.choice... | [
"def",
"generator",
"(",
"self",
",",
"random",
",",
"args",
")",
":",
"if",
"self",
".",
"duplicates",
":",
"max_count",
"=",
"[",
"self",
".",
"capacity",
"//",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"self",
".",
"items",
"]",
"return",
"[",... | Return a candidate solution for an evolutionary computation. | [
"Return",
"a",
"candidate",
"solution",
"for",
"an",
"evolutionary",
"computation",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L1085-L1091 |
aarongarrett/inspyred | inspyred/benchmarks.py | Knapsack.constructor | def constructor(self, random, args):
"""Return a candidate solution for an ant colony optimization."""
self._use_ants = True
candidate = []
while len(candidate) < len(self.components):
# Find feasible components
feasible_components = []
if len(candidat... | python | def constructor(self, random, args):
"""Return a candidate solution for an ant colony optimization."""
self._use_ants = True
candidate = []
while len(candidate) < len(self.components):
# Find feasible components
feasible_components = []
if len(candidat... | [
"def",
"constructor",
"(",
"self",
",",
"random",
",",
"args",
")",
":",
"self",
".",
"_use_ants",
"=",
"True",
"candidate",
"=",
"[",
"]",
"while",
"len",
"(",
"candidate",
")",
"<",
"len",
"(",
"self",
".",
"components",
")",
":",
"# Find feasible co... | Return a candidate solution for an ant colony optimization. | [
"Return",
"a",
"candidate",
"solution",
"for",
"an",
"ant",
"colony",
"optimization",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L1093-L1117 |
aarongarrett/inspyred | inspyred/benchmarks.py | Knapsack.evaluator | def evaluator(self, candidates, args):
"""Return the fitness values for the given candidates."""
fitness = []
if self._use_ants:
for candidate in candidates:
total = 0
for c in candidate:
total += c.value
fitness.app... | python | def evaluator(self, candidates, args):
"""Return the fitness values for the given candidates."""
fitness = []
if self._use_ants:
for candidate in candidates:
total = 0
for c in candidate:
total += c.value
fitness.app... | [
"def",
"evaluator",
"(",
"self",
",",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"if",
"self",
".",
"_use_ants",
":",
"for",
"candidate",
"in",
"candidates",
":",
"total",
"=",
"0",
"for",
"c",
"in",
"candidate",
":",
"total",
"+=... | Return the fitness values for the given candidates. | [
"Return",
"the",
"fitness",
"values",
"for",
"the",
"given",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/benchmarks.py#L1119-L1139 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | crossover | def crossover(cross):
"""Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and co... | python | def crossover(cross):
"""Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and co... | [
"def",
"crossover",
"(",
"cross",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"cross",
")",
"def",
"inspyred_crossover",
"(",
"random",
",",
"candidates",
",",
"args",
")",
":",
"if",
"len",
"(",
"candidates",
")",
"%",
"2",
"==",
"1",
":",
"candi... | Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and collecting of all offspring.
... | [
"Return",
"an",
"inspyred",
"crossover",
"function",
"based",
"on",
"the",
"given",
"function",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L38-L83 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | n_point_crossover | def n_point_crossover(random, mom, dad, args):
"""Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
rando... | python | def n_point_crossover(random, mom, dad, args):
"""Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
rando... | [
"def",
"n_point_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"num_crossover_points",
"=",
"args",
".",
"setdefault",
"(",
"'num_crossover_p... | Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
random -- the random number generator object
mom -- ... | [
"Return",
"the",
"offspring",
"of",
"n",
"-",
"point",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L87-L129 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | uniform_crossover | def uniform_crossover(random, mom, dad, args):
"""Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
... | python | def uniform_crossover(random, mom, dad, args):
"""Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
... | [
"def",
"uniform_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"ux_bias",
"=",
"args",
".",
"setdefault",
"(",
"'ux_bias'",
",",
"0.5",
")",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
... | Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
optional keyword argument in args, ``ux_bias``, deter... | [
"Return",
"the",
"offspring",
"of",
"uniform",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L133-L170 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | partially_matched_crossover | def partially_matched_crossover(random, mom, dad, args):
"""Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given se... | python | def partially_matched_crossover(random, mom, dad, args):
"""Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given se... | [
"def",
"partially_matched_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
... | Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given set (typically integers). It produces offspring
that are thems... | [
"Return",
"the",
"offspring",
"of",
"partially",
"matched",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L174-L212 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | arithmetic_crossover | def arithmetic_crossover(random, mom, dad, args):
"""Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha*... | python | def arithmetic_crossover(random, mom, dad, args):
"""Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha*... | [
"def",
"arithmetic_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"ax_alpha",
"=",
"args",
".",
"setdefault",
"(",
"'ax_alpha'",
",",
"0.5",
")",
"ax_points",
"=",
"args",
".",
"setdefault",
"(",
"'ax_points'",
",",
"None",
")"... | Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha* keyword argument, and
the allele of the complement p... | [
"Return",
"the",
"offspring",
"of",
"arithmetic",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L216-L265 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | blend_crossover | def blend_crossover(random, mom, dad, args):
"""Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
... | python | def blend_crossover(random, mom, dad, args):
"""Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
... | [
"def",
"blend_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"blx_alpha",
"=",
"args",
".",
"setdefault",
"(",
"'blx_alpha'",
",",
"0.1",
")",
"blx_points",
"=",
"args",
".",
"setdefault",
"(",
"'blx_points'",
",",
"None",
")",... | Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
parent alleles but that is also extended by some a... | [
"Return",
"the",
"offspring",
"of",
"blend",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L269-L320 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | heuristic_crossover | def heuristic_crossover(random, candidates, args):
"""Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the ... | python | def heuristic_crossover(random, candidates, args):
"""Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the ... | [
"def",
"heuristic_crossover",
"(",
"random",
",",
"candidates",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"bounder",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"bounder",
"if",
"len",
"(",
... | Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the EC's
``evolve`` method.
.. note::
Th... | [
"Return",
"the",
"offspring",
"of",
"heuristic",
"crossover",
"on",
"the",
"candidates",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L323-L379 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | simulated_binary_crossover | def simulated_binary_crossover(random, mom, dad, args):
"""Return the offspring of simulated binary crossover on the candidates.
This function performs simulated binary crossover (SBX), following the
implementation in NSGA-II
`(Deb et al., ICANNGA 1999) <http://vision.ucsd.edu/~sagarwal/icannga.p... | python | def simulated_binary_crossover(random, mom, dad, args):
"""Return the offspring of simulated binary crossover on the candidates.
This function performs simulated binary crossover (SBX), following the
implementation in NSGA-II
`(Deb et al., ICANNGA 1999) <http://vision.ucsd.edu/~sagarwal/icannga.p... | [
"def",
"simulated_binary_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
"... | Return the offspring of simulated binary crossover on the candidates.
This function performs simulated binary crossover (SBX), following the
implementation in NSGA-II
`(Deb et al., ICANNGA 1999) <http://vision.ucsd.edu/~sagarwal/icannga.pdf>`_.
.. Arguments:
random -- the random number g... | [
"Return",
"the",
"offspring",
"of",
"simulated",
"binary",
"crossover",
"on",
"the",
"candidates",
".",
"This",
"function",
"performs",
"simulated",
"binary",
"crossover",
"(",
"SBX",
")",
"following",
"the",
"implementation",
"in",
"NSGA",
"-",
"II",
"(",
"De... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L383-L440 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | laplace_crossover | def laplace_crossover(random, mom, dad, args):
"""Return the offspring of Laplace crossover on the candidates.
This function performs Laplace crosssover (LX), following the
implementation specified in (Deep and Thakur, "A new crossover
operator for real coded genetic algorithms," Applied Mathemat... | python | def laplace_crossover(random, mom, dad, args):
"""Return the offspring of Laplace crossover on the candidates.
This function performs Laplace crosssover (LX), following the
implementation specified in (Deep and Thakur, "A new crossover
operator for real coded genetic algorithms," Applied Mathemat... | [
"def",
"laplace_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
":",
"bo... | Return the offspring of Laplace crossover on the candidates.
This function performs Laplace crosssover (LX), following the
implementation specified in (Deep and Thakur, "A new crossover
operator for real coded genetic algorithms," Applied Mathematics
and Computation, Volume 188, Issue 1, May 200... | [
"Return",
"the",
"offspring",
"of",
"Laplace",
"crossover",
"on",
"the",
"candidates",
".",
"This",
"function",
"performs",
"Laplace",
"crosssover",
"(",
"LX",
")",
"following",
"the",
"implementation",
"specified",
"in",
"(",
"Deep",
"and",
"Thakur",
"A",
"ne... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L444-L493 |
aarongarrett/inspyred | inspyred/ec/analysis.py | fitness_statistics | def fitness_statistics(population):
"""Return the basic statistics of the population's fitness values.
This function returns a dictionary containing the "best", "worst",
"mean", "median", and "std" fitness values in the population.
("std" is the standard deviation.) A typical usage would be similar... | python | def fitness_statistics(population):
"""Return the basic statistics of the population's fitness values.
This function returns a dictionary containing the "best", "worst",
"mean", "median", and "std" fitness values in the population.
("std" is the standard deviation.) A typical usage would be similar... | [
"def",
"fitness_statistics",
"(",
"population",
")",
":",
"population",
".",
"sort",
"(",
"reverse",
"=",
"True",
")",
"worst_fit",
"=",
"population",
"[",
"-",
"1",
"]",
".",
"fitness",
"best_fit",
"=",
"population",
"[",
"0",
"]",
".",
"fitness",
"try"... | Return the basic statistics of the population's fitness values.
This function returns a dictionary containing the "best", "worst",
"mean", "median", and "std" fitness values in the population.
("std" is the standard deviation.) A typical usage would be similar
to the following::
stats =... | [
"Return",
"the",
"basic",
"statistics",
"of",
"the",
"population",
"s",
"fitness",
"values",
".",
"This",
"function",
"returns",
"a",
"dictionary",
"containing",
"the",
"best",
"worst",
"mean",
"median",
"and",
"std",
"fitness",
"values",
"in",
"the",
"populat... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/analysis.py#L34-L88 |
aarongarrett/inspyred | inspyred/ec/analysis.py | generation_plot | def generation_plot(file, errorbars=True):
"""Plot the results of the algorithm using generation statistics.
This function creates a plot of the generation fitness statistics
(best, worst, median, and average). This function requires the
matplotlib library.
.. note::
This fun... | python | def generation_plot(file, errorbars=True):
"""Plot the results of the algorithm using generation statistics.
This function creates a plot of the generation fitness statistics
(best, worst, median, and average). This function requires the
matplotlib library.
.. note::
This fun... | [
"def",
"generation_plot",
"(",
"file",
",",
"errorbars",
"=",
"True",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"matplotlib",
".",
"font_manager",
"generation",
"=",
"[",
"]",
"psize",
"=",
"[",
"]",
"worst",
"=",
"[",
"]",
... | Plot the results of the algorithm using generation statistics.
This function creates a plot of the generation fitness statistics
(best, worst, median, and average). This function requires the
matplotlib library.
.. note::
This function only works for single-objective problems.
... | [
"Plot",
"the",
"results",
"of",
"the",
"algorithm",
"using",
"generation",
"statistics",
".",
"This",
"function",
"creates",
"a",
"plot",
"of",
"the",
"generation",
"fitness",
"statistics",
"(",
"best",
"worst",
"median",
"and",
"average",
")",
".",
"This",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/analysis.py#L91-L157 |
aarongarrett/inspyred | inspyred/ec/analysis.py | allele_plot | def allele_plot(file, normalize=False, alleles=None, generations=None):
"""Plot the alleles from each generation from the individuals file.
This function creates a plot of the individual allele values as they
change through the generations. It creates three subplots, one for each
of the best, media... | python | def allele_plot(file, normalize=False, alleles=None, generations=None):
"""Plot the alleles from each generation from the individuals file.
This function creates a plot of the individual allele values as they
change through the generations. It creates three subplots, one for each
of the best, media... | [
"def",
"allele_plot",
"(",
"file",
",",
"normalize",
"=",
"False",
",",
"alleles",
"=",
"None",
",",
"generations",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"generation_data",
"=",
"[",
"]",
"reader",
"=",
"csv",
".",
... | Plot the alleles from each generation from the individuals file.
This function creates a plot of the individual allele values as they
change through the generations. It creates three subplots, one for each
of the best, median, and average individual. The best and median
individuals are chosen usin... | [
"Plot",
"the",
"alleles",
"from",
"each",
"generation",
"from",
"the",
"individuals",
"file",
".",
"This",
"function",
"creates",
"a",
"plot",
"of",
"the",
"individual",
"allele",
"values",
"as",
"they",
"change",
"through",
"the",
"generations",
".",
"It",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/analysis.py#L160-L269 |
aarongarrett/inspyred | inspyred/ec/analysis.py | hypervolume | def hypervolume(pareto_set, reference_point=None):
"""Calculates the hypervolume by slicing objectives (HSO).
This function calculates the hypervolume (or S-measure) of a nondominated
set using the Hypervolume by Slicing Objectives (HSO) procedure of `While, et al.
(IEEE CEC 2005) <http://www.lani... | python | def hypervolume(pareto_set, reference_point=None):
"""Calculates the hypervolume by slicing objectives (HSO).
This function calculates the hypervolume (or S-measure) of a nondominated
set using the Hypervolume by Slicing Objectives (HSO) procedure of `While, et al.
(IEEE CEC 2005) <http://www.lani... | [
"def",
"hypervolume",
"(",
"pareto_set",
",",
"reference_point",
"=",
"None",
")",
":",
"def",
"dominates",
"(",
"p",
",",
"q",
",",
"k",
"=",
"None",
")",
":",
"if",
"k",
"is",
"None",
":",
"k",
"=",
"len",
"(",
"p",
")",
"d",
"=",
"True",
"wh... | Calculates the hypervolume by slicing objectives (HSO).
This function calculates the hypervolume (or S-measure) of a nondominated
set using the Hypervolume by Slicing Objectives (HSO) procedure of `While, et al.
(IEEE CEC 2005) <http://www.lania.mx/~ccoello/EMOO/while05a.pdf.gz>`_.
The *pareto_set... | [
"Calculates",
"the",
"hypervolume",
"by",
"slicing",
"objectives",
"(",
"HSO",
")",
".",
"This",
"function",
"calculates",
"the",
"hypervolume",
"(",
"or",
"S",
"-",
"measure",
")",
"of",
"a",
"nondominated",
"set",
"using",
"the",
"Hypervolume",
"by",
"Slic... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/analysis.py#L272-L343 |
aarongarrett/inspyred | docs/moonshot.py | gravitational_force | def gravitational_force(position_a, mass_a, position_b, mass_b):
"""Returns the gravitational force between the two bodies a and b."""
distance = distance_between(position_a, position_b)
# Calculate the direction and magnitude of the force.
angle = math.atan2(position_a[1] - position_b[1], position_a[0... | python | def gravitational_force(position_a, mass_a, position_b, mass_b):
"""Returns the gravitational force between the two bodies a and b."""
distance = distance_between(position_a, position_b)
# Calculate the direction and magnitude of the force.
angle = math.atan2(position_a[1] - position_b[1], position_a[0... | [
"def",
"gravitational_force",
"(",
"position_a",
",",
"mass_a",
",",
"position_b",
",",
"mass_b",
")",
":",
"distance",
"=",
"distance_between",
"(",
"position_a",
",",
"position_b",
")",
"# Calculate the direction and magnitude of the force.",
"angle",
"=",
"math",
"... | Returns the gravitational force between the two bodies a and b. | [
"Returns",
"the",
"gravitational",
"force",
"between",
"the",
"two",
"bodies",
"a",
"and",
"b",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L37-L50 |
aarongarrett/inspyred | docs/moonshot.py | force_on_satellite | def force_on_satellite(position, mass):
"""Returns the total gravitational force acting on the body from the Earth and Moon."""
earth_grav_force = gravitational_force(position, mass, earth_position, earth_mass)
moon_grav_force = gravitational_force(position, mass, moon_position, moon_mass)
F_x = earth_g... | python | def force_on_satellite(position, mass):
"""Returns the total gravitational force acting on the body from the Earth and Moon."""
earth_grav_force = gravitational_force(position, mass, earth_position, earth_mass)
moon_grav_force = gravitational_force(position, mass, moon_position, moon_mass)
F_x = earth_g... | [
"def",
"force_on_satellite",
"(",
"position",
",",
"mass",
")",
":",
"earth_grav_force",
"=",
"gravitational_force",
"(",
"position",
",",
"mass",
",",
"earth_position",
",",
"earth_mass",
")",
"moon_grav_force",
"=",
"gravitational_force",
"(",
"position",
",",
"... | Returns the total gravitational force acting on the body from the Earth and Moon. | [
"Returns",
"the",
"total",
"gravitational",
"force",
"acting",
"on",
"the",
"body",
"from",
"the",
"Earth",
"and",
"Moon",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L52-L58 |
aarongarrett/inspyred | docs/moonshot.py | acceleration_of_satellite | def acceleration_of_satellite(position, mass):
"""Returns the acceleration based on all forces acting upon the body."""
F_x, F_y = force_on_satellite(position, mass)
return F_x / mass, F_y / mass | python | def acceleration_of_satellite(position, mass):
"""Returns the acceleration based on all forces acting upon the body."""
F_x, F_y = force_on_satellite(position, mass)
return F_x / mass, F_y / mass | [
"def",
"acceleration_of_satellite",
"(",
"position",
",",
"mass",
")",
":",
"F_x",
",",
"F_y",
"=",
"force_on_satellite",
"(",
"position",
",",
"mass",
")",
"return",
"F_x",
"/",
"mass",
",",
"F_y",
"/",
"mass"
] | Returns the acceleration based on all forces acting upon the body. | [
"Returns",
"the",
"acceleration",
"based",
"on",
"all",
"forces",
"acting",
"upon",
"the",
"body",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L60-L63 |
aarongarrett/inspyred | inspyred/ec/replacers.py | truncation_replacement | def truncation_replacement(random, population, parents, offspring, args):
"""Replaces population with the best of the population and offspring.
This function performs truncation replacement, which means that
the entire existing population is replaced by the best from among
the current population an... | python | def truncation_replacement(random, population, parents, offspring, args):
"""Replaces population with the best of the population and offspring.
This function performs truncation replacement, which means that
the entire existing population is replaced by the best from among
the current population an... | [
"def",
"truncation_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"psize",
"=",
"len",
"(",
"population",
")",
"population",
".",
"extend",
"(",
"list",
"(",
"offspring",
")",
")",
"population",
"."... | Replaces population with the best of the population and offspring.
This function performs truncation replacement, which means that
the entire existing population is replaced by the best from among
the current population and offspring, keeping the existing population
size fixed. This is similar to s... | [
"Replaces",
"population",
"with",
"the",
"best",
"of",
"the",
"population",
"and",
"offspring",
".",
"This",
"function",
"performs",
"truncation",
"replacement",
"which",
"means",
"that",
"the",
"entire",
"existing",
"population",
"is",
"replaced",
"by",
"the",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L58-L82 |
aarongarrett/inspyred | inspyred/ec/replacers.py | steady_state_replacement | def steady_state_replacement(random, population, parents, offspring, args):
"""Performs steady-state replacement for the offspring.
This function performs steady-state replacement, which means that
the offspring replace the least fit individuals in the existing
population, even if those offspring a... | python | def steady_state_replacement(random, population, parents, offspring, args):
"""Performs steady-state replacement for the offspring.
This function performs steady-state replacement, which means that
the offspring replace the least fit individuals in the existing
population, even if those offspring a... | [
"def",
"steady_state_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"population",
".",
"sort",
"(",
")",
"num_to_replace",
"=",
"min",
"(",
"len",
"(",
"offspring",
")",
",",
"len",
"(",
"population... | Performs steady-state replacement for the offspring.
This function performs steady-state replacement, which means that
the offspring replace the least fit individuals in the existing
population, even if those offspring are less fit than the individuals
that they replace.
.. Arguments:
... | [
"Performs",
"steady",
"-",
"state",
"replacement",
"for",
"the",
"offspring",
".",
"This",
"function",
"performs",
"steady",
"-",
"state",
"replacement",
"which",
"means",
"that",
"the",
"offspring",
"replace",
"the",
"least",
"fit",
"individuals",
"in",
"the",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L85-L104 |
aarongarrett/inspyred | inspyred/ec/replacers.py | generational_replacement | def generational_replacement(random, population, parents, offspring, args):
"""Performs generational replacement with optional weak elitism.
This function performs generational replacement, which means that
the entire existing population is replaced by the offspring,
truncating to the population si... | python | def generational_replacement(random, population, parents, offspring, args):
"""Performs generational replacement with optional weak elitism.
This function performs generational replacement, which means that
the entire existing population is replaced by the offspring,
truncating to the population si... | [
"def",
"generational_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"num_elites",
"=",
"args",
".",
"setdefault",
"(",
"'num_elites'",
",",
"0",
")",
"population",
".",
"sort",
"(",
"reverse",
"=",
... | Performs generational replacement with optional weak elitism.
This function performs generational replacement, which means that
the entire existing population is replaced by the offspring,
truncating to the population size if the number of offspring is
larger. Weak elitism may also be specified th... | [
"Performs",
"generational",
"replacement",
"with",
"optional",
"weak",
"elitism",
".",
"This",
"function",
"performs",
"generational",
"replacement",
"which",
"means",
"that",
"the",
"entire",
"existing",
"population",
"is",
"replaced",
"by",
"the",
"offspring",
"tr... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L107-L135 |
aarongarrett/inspyred | inspyred/ec/replacers.py | random_replacement | def random_replacement(random, population, parents, offspring, args):
"""Performs random replacement with optional weak elitism.
This function performs random replacement, which means that
the offspring replace random members of the population, keeping
the population size constant. Weak elitism may... | python | def random_replacement(random, population, parents, offspring, args):
"""Performs random replacement with optional weak elitism.
This function performs random replacement, which means that
the offspring replace random members of the population, keeping
the population size constant. Weak elitism may... | [
"def",
"random_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"num_elites",
"=",
"args",
".",
"setdefault",
"(",
"'num_elites'",
",",
"0",
")",
"population",
".",
"sort",
"(",
"reverse",
"=",
"True"... | Performs random replacement with optional weak elitism.
This function performs random replacement, which means that
the offspring replace random members of the population, keeping
the population size constant. Weak elitism may also be specified
through the `num_elites` keyword argument in args. If... | [
"Performs",
"random",
"replacement",
"with",
"optional",
"weak",
"elitism",
".",
"This",
"function",
"performs",
"random",
"replacement",
"which",
"means",
"that",
"the",
"offspring",
"replace",
"random",
"members",
"of",
"the",
"population",
"keeping",
"the",
"po... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L138-L168 |
aarongarrett/inspyred | inspyred/ec/replacers.py | plus_replacement | def plus_replacement(random, population, parents, offspring, args):
"""Performs "plus" replacement.
This function performs "plus" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the combined set of parents and
offspring.
... | python | def plus_replacement(random, population, parents, offspring, args):
"""Performs "plus" replacement.
This function performs "plus" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the combined set of parents and
offspring.
... | [
"def",
"plus_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"pool",
"=",
"list",
"(",
"offspring",
")",
"pool",
".",
"extend",
"(",
"parents",
")",
"pool",
".",
"sort",
"(",
"reverse",
"=",
"Tru... | Performs "plus" replacement.
This function performs "plus" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the combined set of parents and
offspring.
.. Arguments:
random -- the random number generator object
... | [
"Performs",
"plus",
"replacement",
".",
"This",
"function",
"performs",
"plus",
"replacement",
"which",
"means",
"that",
"the",
"entire",
"existing",
"population",
"is",
"replaced",
"by",
"the",
"best",
"population",
"-",
"many",
"elements",
"from",
"the",
"comb... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L171-L191 |
aarongarrett/inspyred | inspyred/ec/replacers.py | comma_replacement | def comma_replacement(random, population, parents, offspring, args):
"""Performs "comma" replacement.
This function performs "comma" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the offspring. This function
makes the assumpti... | python | def comma_replacement(random, population, parents, offspring, args):
"""Performs "comma" replacement.
This function performs "comma" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the offspring. This function
makes the assumpti... | [
"def",
"comma_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"offspring",
".",
"sort",
"(",
"reverse",
"=",
"True",
")",
"survivors",
"=",
"offspring",
"[",
":",
"len",
"(",
"population",
")",
"]"... | Performs "comma" replacement.
This function performs "comma" replacement, which means that
the entire existing population is replaced by the best
population-many elements from the offspring. This function
makes the assumption that the size of the offspring is at
least as large as the original ... | [
"Performs",
"comma",
"replacement",
".",
"This",
"function",
"performs",
"comma",
"replacement",
"which",
"means",
"that",
"the",
"entire",
"existing",
"population",
"is",
"replaced",
"by",
"the",
"best",
"population",
"-",
"many",
"elements",
"from",
"the",
"of... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L194-L214 |
aarongarrett/inspyred | inspyred/ec/replacers.py | crowding_replacement | def crowding_replacement(random, population, parents, offspring, args):
"""Performs crowding replacement as a form of niching.
This function performs crowding replacement, which means that
the members of the population are replaced one-at-a-time with
each of the offspring. A random sample of `crowd... | python | def crowding_replacement(random, population, parents, offspring, args):
"""Performs crowding replacement as a form of niching.
This function performs crowding replacement, which means that
the members of the population are replaced one-at-a-time with
each of the offspring. A random sample of `crowd... | [
"def",
"crowding_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"def",
"distance",
"(",
"x",
",",
"y",
")",
":",
"return",
"math",
".",
"sqrt",
"(",
"sum",
"(",
"[",
"(",
"a",
"-",
"b",
")",... | Performs crowding replacement as a form of niching.
This function performs crowding replacement, which means that
the members of the population are replaced one-at-a-time with
each of the offspring. A random sample of `crowding_distance`
individuals is pulled from the current population, and the
... | [
"Performs",
"crowding",
"replacement",
"as",
"a",
"form",
"of",
"niching",
".",
"This",
"function",
"performs",
"crowding",
"replacement",
"which",
"means",
"that",
"the",
"members",
"of",
"the",
"population",
"are",
"replaced",
"one",
"-",
"at",
"-",
"a",
"... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L217-L262 |
aarongarrett/inspyred | inspyred/ec/replacers.py | simulated_annealing_replacement | def simulated_annealing_replacement(random, population, parents, offspring, args):
"""Replaces population using the simulated annealing schedule.
This function performs simulated annealing replacement based
on a temperature and a cooling rate. These can be specified
by the keyword arguments `temper... | python | def simulated_annealing_replacement(random, population, parents, offspring, args):
"""Replaces population using the simulated annealing schedule.
This function performs simulated annealing replacement based
on a temperature and a cooling rate. These can be specified
by the keyword arguments `temper... | [
"def",
"simulated_annealing_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"try",
":",
"temp",
"=",
"args",
"[",
"'temperature'",
"]",
"cooling_rate",
"=",
"args",
"[",
"'cooling_rate'",
"]",
"temp",
... | Replaces population using the simulated annealing schedule.
This function performs simulated annealing replacement based
on a temperature and a cooling rate. These can be specified
by the keyword arguments `temperature`, which should be the
initial temperature, and `cooling_rate`, which should be t... | [
"Replaces",
"population",
"using",
"the",
"simulated",
"annealing",
"schedule",
".",
"This",
"function",
"performs",
"simulated",
"annealing",
"replacement",
"based",
"on",
"a",
"temperature",
"and",
"a",
"cooling",
"rate",
".",
"These",
"can",
"be",
"specified",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L271-L324 |
aarongarrett/inspyred | inspyred/ec/replacers.py | nsga_replacement | def nsga_replacement(random, population, parents, offspring, args):
"""Replaces population using the non-dominated sorting technique from NSGA-II.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent indivi... | python | def nsga_replacement(random, population, parents, offspring, args):
"""Replaces population using the non-dominated sorting technique from NSGA-II.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent indivi... | [
"def",
"nsga_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"survivors",
"=",
"[",
"]",
"combined",
"=",
"list",
"(",
"population",
")",
"combined",
".",
"extend",
"(",
"offspring",
")",
"# Perform ... | Replaces population using the non-dominated sorting technique from NSGA-II.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent individuals
offspring -- the list of offspring individuals
args -- ... | [
"Replaces",
"population",
"using",
"the",
"non",
"-",
"dominated",
"sorting",
"technique",
"from",
"NSGA",
"-",
"II",
".",
"..",
"Arguments",
":",
"random",
"--",
"the",
"random",
"number",
"generator",
"object",
"population",
"--",
"the",
"population",
"of",
... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L327-L398 |
aarongarrett/inspyred | inspyred/ec/replacers.py | paes_replacement | def paes_replacement(random, population, parents, offspring, args):
"""Replaces population using the Pareto Archived Evolution Strategy method.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent individua... | python | def paes_replacement(random, population, parents, offspring, args):
"""Replaces population using the Pareto Archived Evolution Strategy method.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent individua... | [
"def",
"paes_replacement",
"(",
"random",
",",
"population",
",",
"parents",
",",
"offspring",
",",
"args",
")",
":",
"archive",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"archive",
"archiver",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"archiver",
"survivors",
"="... | Replaces population using the Pareto Archived Evolution Strategy method.
.. Arguments:
random -- the random number generator object
population -- the population of individuals
parents -- the list of parent individuals
offspring -- the list of offspring individuals
args -- a d... | [
"Replaces",
"population",
"using",
"the",
"Pareto",
"Archived",
"Evolution",
"Strategy",
"method",
".",
"..",
"Arguments",
":",
"random",
"--",
"the",
"random",
"number",
"generator",
"object",
"population",
"--",
"the",
"population",
"of",
"individuals",
"parents... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/replacers.py#L401-L438 |
aarongarrett/inspyred | inspyred/ec/evaluators.py | evaluator | def evaluator(evaluate):
"""Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the fol... | python | def evaluator(evaluate):
"""Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the fol... | [
"def",
"evaluator",
"(",
"evaluate",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"evaluate",
")",
"def",
"inspyred_evaluator",
"(",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"for",
"candidate",
"in",
"candidates",
":",
"fitness",
... | Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the following signature::
... | [
"Return",
"an",
"inspyred",
"evaluator",
"function",
"based",
"on",
"the",
"given",
"function",
".",
"This",
"function",
"generator",
"takes",
"a",
"function",
"that",
"evaluates",
"only",
"one",
"candidate",
".",
"The",
"generator",
"handles",
"the",
"iteration... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L45-L77 |
aarongarrett/inspyred | inspyred/ec/evaluators.py | parallel_evaluation_pp | def parallel_evaluation_pp(candidates, args):
"""Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must ... | python | def parallel_evaluation_pp(candidates, args):
"""Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must ... | [
"def",
"parallel_evaluation_pp",
"(",
"candidates",
",",
"args",
")",
":",
"import",
"pp",
"logger",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"logger",
"try",
":",
"evaluator",
"=",
"args",
"[",
"'pp_evaluator'",
"]",
"except",
"KeyError",
":",
"logger",
".",
... | Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must already
be installed in order to use this functi... | [
"Evaluate",
"the",
"candidates",
"in",
"parallel",
"using",
"Parallel",
"Python",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L80-L162 |
aarongarrett/inspyred | inspyred/ec/evaluators.py | parallel_evaluation_mp | def parallel_evaluation_mp(candidates, args):
"""Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
... | python | def parallel_evaluation_mp(candidates, args):
"""Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
... | [
"def",
"parallel_evaluation_mp",
"(",
"candidates",
",",
"args",
")",
":",
"import",
"time",
"import",
"multiprocessing",
"logger",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"logger",
"try",
":",
"evaluator",
"=",
"args",
"[",
"'mp_evaluator'",
"]",
"except",
"Ke... | Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
candidate to its own job, all of which are then di... | [
"Evaluate",
"the",
"candidates",
"in",
"parallel",
"using",
"multiprocessing",
"."
] | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L165-L230 |
aarongarrett/inspyred | inspyred/ec/generators.py | strategize | def strategize(generator):
"""Add strategy parameters to candidates created by a generator.
This function decorator is used to provide a means of adding strategy
parameters to candidates created by a generator. The generator function
is modifed to extend the candidate with ``len(candidate)`` stra... | python | def strategize(generator):
"""Add strategy parameters to candidates created by a generator.
This function decorator is used to provide a means of adding strategy
parameters to candidates created by a generator. The generator function
is modifed to extend the candidate with ``len(candidate)`` stra... | [
"def",
"strategize",
"(",
"generator",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"generator",
")",
"def",
"strategy_generator",
"(",
"random",
",",
"args",
")",
":",
"candidate",
"=",
"generator",
"(",
"random",
",",
"args",
")",
"n",
"=",
"len",
... | Add strategy parameters to candidates created by a generator.
This function decorator is used to provide a means of adding strategy
parameters to candidates created by a generator. The generator function
is modifed to extend the candidate with ``len(candidate)`` strategy
parameters (one per cand... | [
"Add",
"strategy",
"parameters",
"to",
"candidates",
"created",
"by",
"a",
"generator",
".",
"This",
"function",
"decorator",
"is",
"used",
"to",
"provide",
"a",
"means",
"of",
"adding",
"strategy",
"parameters",
"to",
"candidates",
"created",
"by",
"a",
"gene... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/generators.py#L40-L62 |
aarongarrett/inspyred | inspyred/ec/utilities.py | memoize | def memoize(func=None, maxlen=None):
"""Cache a function's return value each time it is called.
This function serves as a function decorator to provide a caching of
evaluated fitness values. If called later with the same arguments,
the cached value is returned instead of being re-evaluated.
... | python | def memoize(func=None, maxlen=None):
"""Cache a function's return value each time it is called.
This function serves as a function decorator to provide a caching of
evaluated fitness values. If called later with the same arguments,
the cached value is returned instead of being re-evaluated.
... | [
"def",
"memoize",
"(",
"func",
"=",
"None",
",",
"maxlen",
"=",
"None",
")",
":",
"if",
"func",
"is",
"not",
"None",
":",
"cache",
"=",
"BoundedOrderedDict",
"(",
"maxlen",
"=",
"maxlen",
")",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
... | Cache a function's return value each time it is called.
This function serves as a function decorator to provide a caching of
evaluated fitness values. If called later with the same arguments,
the cached value is returned instead of being re-evaluated.
This decorator assumes that candidates ar... | [
"Cache",
"a",
"function",
"s",
"return",
"value",
"each",
"time",
"it",
"is",
"called",
".",
"This",
"function",
"serves",
"as",
"a",
"function",
"decorator",
"to",
"provide",
"a",
"caching",
"of",
"evaluated",
"fitness",
"values",
".",
"If",
"called",
"la... | train | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/utilities.py#L252-L301 |
djsutho/django-debug-toolbar-request-history | ddt_request_history/panels/request_history.py | allow_ajax | def allow_ajax(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
return False
if toolbar_version < LooseVersion('1.8') \
and request.get_full_path().startswith(DEBUG_... | python | def allow_ajax(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
return False
if toolbar_version < LooseVersion('1.8') \
and request.get_full_path().startswith(DEBUG_... | [
"def",
"allow_ajax",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'REMOTE_ADDR'",
",",
"None",
")",
"not",
"in",
"settings",
".",
"INTERNAL_IPS",
":",
"return",
"False",
"if",
"toolbar_version",
"<",
"LooseVersion",
"(",
"'1.8'... | Default function to determine whether to show the toolbar on a given page. | [
"Default",
"function",
"to",
"determine",
"whether",
"to",
"show",
"the",
"toolbar",
"on",
"a",
"given",
"page",
"."
] | train | https://github.com/djsutho/django-debug-toolbar-request-history/blob/b3da3e12762d68c23a307ffb279e6047f80ba695/ddt_request_history/panels/request_history.py#L104-L114 |
djsutho/django-debug-toolbar-request-history | ddt_request_history/panels/request_history.py | RequestHistoryPanel.content | def content(self):
""" Content of the panel when it's displayed in full screen. """
toolbars = OrderedDict()
for id, toolbar in DebugToolbar._store.items():
content = {}
for panel in toolbar.panels:
panel_id = None
nav_title = ''
... | python | def content(self):
""" Content of the panel when it's displayed in full screen. """
toolbars = OrderedDict()
for id, toolbar in DebugToolbar._store.items():
content = {}
for panel in toolbar.panels:
panel_id = None
nav_title = ''
... | [
"def",
"content",
"(",
"self",
")",
":",
"toolbars",
"=",
"OrderedDict",
"(",
")",
"for",
"id",
",",
"toolbar",
"in",
"DebugToolbar",
".",
"_store",
".",
"items",
"(",
")",
":",
"content",
"=",
"{",
"}",
"for",
"panel",
"in",
"toolbar",
".",
"panels"... | Content of the panel when it's displayed in full screen. | [
"Content",
"of",
"the",
"panel",
"when",
"it",
"s",
"displayed",
"in",
"full",
"screen",
"."
] | train | https://github.com/djsutho/django-debug-toolbar-request-history/blob/b3da3e12762d68c23a307ffb279e6047f80ba695/ddt_request_history/panels/request_history.py#L184-L215 |
AlexMathew/scrapple | scrapple/commands/web.py | WebCommand.execute_command | def execute_command(self):
"""
The web command runs the Scrapple web interface through a simple \
`Flask <http://flask.pocoo.org>`_ app.
When the execute_command() method is called from the \
:ref:`runCLI() <implementation-cli>` function, it starts of two simultaneous \
... | python | def execute_command(self):
"""
The web command runs the Scrapple web interface through a simple \
`Flask <http://flask.pocoo.org>`_ app.
When the execute_command() method is called from the \
:ref:`runCLI() <implementation-cli>` function, it starts of two simultaneous \
... | [
"def",
"execute_command",
"(",
"self",
")",
":",
"print",
"(",
"Back",
".",
"GREEN",
"+",
"Fore",
".",
"BLACK",
"+",
"\"Scrapple Web Interface\"",
")",
"print",
"(",
"Back",
".",
"RESET",
"+",
"Fore",
".",
"RESET",
")",
"p1",
"=",
"Process",
"(",
"targ... | The web command runs the Scrapple web interface through a simple \
`Flask <http://flask.pocoo.org>`_ app.
When the execute_command() method is called from the \
:ref:`runCLI() <implementation-cli>` function, it starts of two simultaneous \
processes :
- Calls the run_flask() ... | [
"The",
"web",
"command",
"runs",
"the",
"Scrapple",
"web",
"interface",
"through",
"a",
"simple",
"\\",
"Flask",
"<http",
":",
"//",
"flask",
".",
"pocoo",
".",
"org",
">",
"_",
"app",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/commands/web.py#L39-L67 |
AlexMathew/scrapple | scrapple/commands/generate.py | GenerateCommand.execute_command | def execute_command(self):
"""
The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
to create Python scripts, according to the specification in the configuration \
file. The predefined templates use the extract_content() method of the \
:ref:`selector classes... | python | def execute_command(self):
"""
The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
to create Python scripts, according to the specification in the configuration \
file. The predefined templates use the extract_content() method of the \
:ref:`selector classes... | [
"def",
"execute_command",
"(",
"self",
")",
":",
"print",
"(",
"Back",
".",
"GREEN",
"+",
"Fore",
".",
"BLACK",
"+",
"\"Scrapple Generate\"",
")",
"print",
"(",
"Back",
".",
"RESET",
"+",
"Fore",
".",
"RESET",
")",
"directory",
"=",
"os",
".",
"path",
... | The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
to create Python scripts, according to the specification in the configuration \
file. The predefined templates use the extract_content() method of the \
:ref:`selector classes <implementation-selectors>` to implement linea... | [
"The",
"generate",
"command",
"uses",
"Jinja2",
"<http",
":",
"//",
"jinja",
".",
"pocoo",
".",
"org",
"/",
">",
"_",
"templates",
"\\",
"to",
"create",
"Python",
"scripts",
"according",
"to",
"the",
"specification",
"in",
"the",
"configuration",
"\\",
"fi... | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/commands/generate.py#L28-L67 |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_content | def extract_content(self, selector='', attr='', default='', connector='', *args, **kwargs):
"""
Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. ... | python | def extract_content(self, selector='', attr='', default='', connector='', *args, **kwargs):
"""
Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. ... | [
"def",
"extract_content",
"(",
"self",
",",
"selector",
"=",
"''",
",",
"attr",
"=",
"''",
",",
"default",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"selector",
".",
"lower",
"(... | Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. The particular \
attribute to be extracted ("text", "href", etc.) is specified in the method \
a... | [
"Method",
"for",
"performing",
"the",
"content",
"extraction",
"for",
"the",
"particular",
"selector",
"type",
".",
"\\"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L81-L119 |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_links | def extract_links(self, selector='', *args, **kwargs):
"""
Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The ... | python | def extract_links(self, selector='', *args, **kwargs):
"""
Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The ... | [
"def",
"extract_links",
"(",
"self",
",",
"selector",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"links",
"=",
"self",
".",
"get_tree_tag",
"(",
"selector",
"=",
"selector",
")",
"for",
"link",
"in",
"links",
":",
"... | Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The relative paths are converted into absolute paths and \
a ``Xp... | [
"Method",
"for",
"performing",
"the",
"link",
"extraction",
"for",
"the",
"crawler",
".",
"\\"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L122-L147 |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_tabular | def extract_tabular(self, header='', prefix='', suffix='', table_type='', *args, **kwargs):
"""
Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted.... | python | def extract_tabular(self, header='', prefix='', suffix='', table_type='', *args, **kwargs):
"""
Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted.... | [
"def",
"extract_tabular",
"(",
"self",
",",
"header",
"=",
"''",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
",",
"table_type",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"type",
"(",
"header",
")",
"in",
"[",
... | Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted. \
A row extraction is when there is a single row to be extracted and mapped to a set of headers. ... | [
"Method",
"for",
"performing",
"the",
"tabular",
"data",
"extraction",
".",
"\\"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L150-L187 |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_rows | def extract_rows(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Row data extraction for extract_tabular
"""
result_list = []
try:
values = self.get_tree_tag(selector)
if len(table_headers) >= len(values):
from itertools import i... | python | def extract_rows(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Row data extraction for extract_tabular
"""
result_list = []
try:
values = self.get_tree_tag(selector)
if len(table_headers) >= len(values):
from itertools import i... | [
"def",
"extract_rows",
"(",
"self",
",",
"result",
"=",
"{",
"}",
",",
"selector",
"=",
"''",
",",
"table_headers",
"=",
"[",
"]",
",",
"attr",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"default",
"=",
"''",
",",
"verbosity",
"=",
"0",
",",
"*... | Row data extraction for extract_tabular | [
"Row",
"data",
"extraction",
"for",
"extract_tabular"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L190-L224 |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_columns | def extract_columns(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Column data extraction for extract_tabular
"""
result_list = []
try:
if type(selector) in [str, unicode]:
selectors = [selector]
elif type(selector) == list:
... | python | def extract_columns(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Column data extraction for extract_tabular
"""
result_list = []
try:
if type(selector) in [str, unicode]:
selectors = [selector]
elif type(selector) == list:
... | [
"def",
"extract_columns",
"(",
"self",
",",
"result",
"=",
"{",
"}",
",",
"selector",
"=",
"''",
",",
"table_headers",
"=",
"[",
"]",
",",
"attr",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"default",
"=",
"''",
",",
"verbosity",
"=",
"0",
",",
... | Column data extraction for extract_tabular | [
"Column",
"data",
"extraction",
"for",
"extract_tabular"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L227-L271 |
AlexMathew/scrapple | scrapple/cmd.py | runCLI | def runCLI():
"""
The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() ... | python | def runCLI():
"""
The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() ... | [
"def",
"runCLI",
"(",
")",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"'0.3.0'",
")",
"try",
":",
"check_arguments",
"(",
"args",
")",
"command_list",
"=",
"[",
"'genconfig'",
",",
"'run'",
",",
"'generate'",
"]",
"select",
"=",
"... | The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() method of the command clas... | [
"The",
"starting",
"point",
"for",
"the",
"execution",
"of",
"the",
"Scrapple",
"command",
"line",
"tool",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/cmd.py#L49-L67 |
AlexMathew/scrapple | scrapple/utils/exceptions.py | check_arguments | def check_arguments(args):
"""
Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None
"""
projectname_re = re.compile(r'[^a-zA-Z0-9_]')
if args['genconfig']:
if args['--type'] not in ['scraper', 'crawler']:
raise Inv... | python | def check_arguments(args):
"""
Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None
"""
projectname_re = re.compile(r'[^a-zA-Z0-9_]')
if args['genconfig']:
if args['--type'] not in ['scraper', 'crawler']:
raise Inv... | [
"def",
"check_arguments",
"(",
"args",
")",
":",
"projectname_re",
"=",
"re",
".",
"compile",
"(",
"r'[^a-zA-Z0-9_]'",
")",
"if",
"args",
"[",
"'genconfig'",
"]",
":",
"if",
"args",
"[",
"'--type'",
"]",
"not",
"in",
"[",
"'scraper'",
",",
"'crawler'",
"... | Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None | [
"Validates",
"the",
"arguments",
"passed",
"through",
"the",
"CLI",
"commands",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/exceptions.py#L36-L66 |
AlexMathew/scrapple | scrapple/utils/dynamicdispatch.py | get_command_class | def get_command_class(command):
"""
Called from runCLI() to select the command class for the selected command.
:param command: The command to be implemented
:return: The command class corresponding to the selected command
"""
from scrapple.commands import genconfig, generate, run, web
comma... | python | def get_command_class(command):
"""
Called from runCLI() to select the command class for the selected command.
:param command: The command to be implemented
:return: The command class corresponding to the selected command
"""
from scrapple.commands import genconfig, generate, run, web
comma... | [
"def",
"get_command_class",
"(",
"command",
")",
":",
"from",
"scrapple",
".",
"commands",
"import",
"genconfig",
",",
"generate",
",",
"run",
",",
"web",
"commandMapping",
"=",
"{",
"'genconfig'",
":",
"genconfig",
",",
"'generate'",
":",
"generate",
",",
"... | Called from runCLI() to select the command class for the selected command.
:param command: The command to be implemented
:return: The command class corresponding to the selected command | [
"Called",
"from",
"runCLI",
"()",
"to",
"select",
"the",
"command",
"class",
"for",
"the",
"selected",
"command",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/dynamicdispatch.py#L8-L23 |
AlexMathew/scrapple | scrapple/utils/form.py | form_to_json | def form_to_json(form):
"""
Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None
"""
config = dict()
if form['project_name'] == "":
raise Exception('Project name cannot be empty.')
if form['selector_type'] ... | python | def form_to_json(form):
"""
Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None
"""
config = dict()
if form['project_name'] == "":
raise Exception('Project name cannot be empty.')
if form['selector_type'] ... | [
"def",
"form_to_json",
"(",
"form",
")",
":",
"config",
"=",
"dict",
"(",
")",
"if",
"form",
"[",
"'project_name'",
"]",
"==",
"\"\"",
":",
"raise",
"Exception",
"(",
"'Project name cannot be empty.'",
")",
"if",
"form",
"[",
"'selector_type'",
"]",
"not",
... | Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None | [
"Takes",
"the",
"form",
"from",
"the",
"POST",
"request",
"in",
"the",
"web",
"interface",
"and",
"generates",
"the",
"JSON",
"config",
"\\",
"file"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/form.py#L13-L48 |
AlexMathew/scrapple | scrapple/commands/run.py | RunCommand.execute_command | def execute_command(self):
"""
The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the ext... | python | def execute_command(self):
"""
The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the ext... | [
"def",
"execute_command",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
"=",
"int",
"(",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
")",
"if",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
"not",
"in",
"[",... | The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the extractor run.
The extractor implementati... | [
"The",
"run",
"command",
"implements",
"the",
"web",
"content",
"extractor",
"corresponding",
"to",
"the",
"given",
"\\",
"configuration",
"file",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/commands/run.py#L29-L74 |
AlexMathew/scrapple | scrapple/utils/config.py | traverse_next | def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0):
"""
Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:pa... | python | def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0):
"""
Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:pa... | [
"def",
"traverse_next",
"(",
"page",
",",
"nextx",
",",
"results",
",",
"tabular_data_headers",
"=",
"[",
"]",
",",
"verbosity",
"=",
"0",
")",
":",
"for",
"link",
"in",
"page",
".",
"extract_links",
"(",
"selector",
"=",
"nextx",
"[",
"'follow_link'",
"... | Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:param results: The current extracted content, stored in a dict
:return: The extracted con... | [
"Recursive",
"generator",
"to",
"traverse",
"through",
"the",
"next",
"attribute",
"and",
"\\",
"crawl",
"through",
"the",
"links",
"to",
"be",
"followed",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L20-L58 |
AlexMathew/scrapple | scrapple/utils/config.py | validate_config | def validate_config(config):
"""
Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correcti... | python | def validate_config(config):
"""
Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correcti... | [
"def",
"validate_config",
"(",
"config",
")",
":",
"fields",
"=",
"[",
"f",
"for",
"f",
"in",
"get_fields",
"(",
"config",
")",
"]",
"if",
"len",
"(",
"fields",
")",
"!=",
"len",
"(",
"set",
"(",
"fields",
")",
")",
":",
"raise",
"InvalidConfigExcept... | Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correction to be made | [
"Validates",
"the",
"extractor",
"configuration",
"file",
".",
"Ensures",
"that",
"there",
"are",
"no",
"duplicate",
"field",
"names",
"etc",
"."
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L61-L74 |
AlexMathew/scrapple | scrapple/utils/config.py | get_fields | def get_fields(config):
"""
Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator
"""
for data in config['scraping']['data']:
... | python | def get_fields(config):
"""
Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator
"""
for data in config['scraping']['data']:
... | [
"def",
"get_fields",
"(",
"config",
")",
":",
"for",
"data",
"in",
"config",
"[",
"'scraping'",
"]",
"[",
"'data'",
"]",
":",
"if",
"data",
"[",
"'field'",
"]",
"!=",
"''",
":",
"yield",
"data",
"[",
"'field'",
"]",
"if",
"'next'",
"in",
"config",
... | Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator | [
"Recursive",
"generator",
"that",
"yields",
"the",
"field",
"names",
"in",
"the",
"config",
"file"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L77-L91 |
AlexMathew/scrapple | scrapple/utils/config.py | extract_fieldnames | def extract_fieldnames(config):
"""
Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file
"""
fields = []
for x in get_fields(config):
... | python | def extract_fieldnames(config):
"""
Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file
"""
fields = []
for x in get_fields(config):
... | [
"def",
"extract_fieldnames",
"(",
"config",
")",
":",
"fields",
"=",
"[",
"]",
"for",
"x",
"in",
"get_fields",
"(",
"config",
")",
":",
"if",
"x",
"in",
"fields",
":",
"fields",
".",
"append",
"(",
"x",
"+",
"'_'",
"+",
"str",
"(",
"fields",
".",
... | Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file | [
"Function",
"to",
"return",
"a",
"list",
"of",
"unique",
"field",
"names",
"from",
"the",
"config",
"file"
] | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L94-L108 |
AlexMathew/scrapple | scrapple/commands/genconfig.py | GenconfigCommand.execute_command | def execute_command(self):
"""
The genconfig command depends on predefined `Jinja2 <http://jinja.pocoo.org/>`_ \
templates for the skeleton configuration files. Taking the --type argument from the \
CLI input, the corresponding template file is used.
Settings for the configurat... | python | def execute_command(self):
"""
The genconfig command depends on predefined `Jinja2 <http://jinja.pocoo.org/>`_ \
templates for the skeleton configuration files. Taking the --type argument from the \
CLI input, the corresponding template file is used.
Settings for the configurat... | [
"def",
"execute_command",
"(",
"self",
")",
":",
"print",
"(",
"Back",
".",
"GREEN",
"+",
"Fore",
".",
"BLACK",
"+",
"\"Scrapple Genconfig\"",
")",
"print",
"(",
"Back",
".",
"RESET",
"+",
"Fore",
".",
"RESET",
")",
"directory",
"=",
"os",
".",
"path",... | The genconfig command depends on predefined `Jinja2 <http://jinja.pocoo.org/>`_ \
templates for the skeleton configuration files. Taking the --type argument from the \
CLI input, the corresponding template file is used.
Settings for the configuration file, like project name, selector type and ... | [
"The",
"genconfig",
"command",
"depends",
"on",
"predefined",
"Jinja2",
"<http",
":",
"//",
"jinja",
".",
"pocoo",
".",
"org",
"/",
">",
"_",
"\\",
"templates",
"for",
"the",
"skeleton",
"configuration",
"files",
".",
"Taking",
"the",
"--",
"type",
"argume... | train | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/commands/genconfig.py#L28-L57 |
CQCL/pytket | pytket/chemistry/aqua/qse_subs.py | _jordan_wigner_mode | def _jordan_wigner_mode(n):
"""
Jordan_Wigner mode.
Args:
n (int): number of modes
"""
a = []
for i in range(n):
xv = np.asarray([1] * i + [0] + [0] * (n - i - 1))
xw = np.asarray([0] * i + [1] + [0] * (n - i - 1))
yv = np.a... | python | def _jordan_wigner_mode(n):
"""
Jordan_Wigner mode.
Args:
n (int): number of modes
"""
a = []
for i in range(n):
xv = np.asarray([1] * i + [0] + [0] * (n - i - 1))
xw = np.asarray([0] * i + [1] + [0] * (n - i - 1))
yv = np.a... | [
"def",
"_jordan_wigner_mode",
"(",
"n",
")",
":",
"a",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"xv",
"=",
"np",
".",
"asarray",
"(",
"[",
"1",
"]",
"*",
"i",
"+",
"[",
"0",
"]",
"+",
"[",
"0",
"]",
"*",
"(",
"n",
"... | Jordan_Wigner mode.
Args:
n (int): number of modes | [
"Jordan_Wigner",
"mode",
".",
"Args",
":",
"n",
"(",
"int",
")",
":",
"number",
"of",
"modes"
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse_subs.py#L24-L37 |
CQCL/pytket | pytket/chemistry/aqua/qse_subs.py | _one_body_mapping | def _one_body_mapping(a_i, a_j, threshold=0.000001):
"""
Subroutine for one body mapping.
Args:
a_i (Pauli): pauli at index i
a_j (Pauli): pauli at index j
threshold: (float): threshold to remove a pauli
Returns:
Operator: Operator for thos... | python | def _one_body_mapping(a_i, a_j, threshold=0.000001):
"""
Subroutine for one body mapping.
Args:
a_i (Pauli): pauli at index i
a_j (Pauli): pauli at index j
threshold: (float): threshold to remove a pauli
Returns:
Operator: Operator for thos... | [
"def",
"_one_body_mapping",
"(",
"a_i",
",",
"a_j",
",",
"threshold",
"=",
"0.000001",
")",
":",
"pauli_list",
"=",
"[",
"]",
"for",
"alpha",
"in",
"range",
"(",
"2",
")",
":",
"for",
"beta",
"in",
"range",
"(",
"2",
")",
":",
"pauli_prod",
"=",
"P... | Subroutine for one body mapping.
Args:
a_i (Pauli): pauli at index i
a_j (Pauli): pauli at index j
threshold: (float): threshold to remove a pauli
Returns:
Operator: Operator for those paulis | [
"Subroutine",
"for",
"one",
"body",
"mapping",
".",
"Args",
":",
"a_i",
"(",
"Pauli",
")",
":",
"pauli",
"at",
"index",
"i",
"a_j",
"(",
"Pauli",
")",
":",
"pauli",
"at",
"index",
"j",
"threshold",
":",
"(",
"float",
")",
":",
"threshold",
"to",
"r... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse_subs.py#L39-L57 |
CQCL/pytket | pytket/cirq/cirq_convert.py | get_grid_qubits | def get_grid_qubits(arc: SquareGrid, nodes: Iterator[int]) -> List[cirq.GridQubit]:
"""Gets a list of :py:class:GridQubit` s corresponding to the qubit nodes provided on the given Architecture.
:param arc: The grid Architecture
:param nodes: An iterator of node index values
:return: The list ... | python | def get_grid_qubits(arc: SquareGrid, nodes: Iterator[int]) -> List[cirq.GridQubit]:
"""Gets a list of :py:class:GridQubit` s corresponding to the qubit nodes provided on the given Architecture.
:param arc: The grid Architecture
:param nodes: An iterator of node index values
:return: The list ... | [
"def",
"get_grid_qubits",
"(",
"arc",
":",
"SquareGrid",
",",
"nodes",
":",
"Iterator",
"[",
"int",
"]",
")",
"->",
"List",
"[",
"cirq",
".",
"GridQubit",
"]",
":",
"return",
"[",
"cirq",
".",
"GridQubit",
"(",
"*",
"arc",
".",
"qind_to_squind",
"(",
... | Gets a list of :py:class:GridQubit` s corresponding to the qubit nodes provided on the given Architecture.
:param arc: The grid Architecture
:param nodes: An iterator of node index values
:return: The list of qubits | [
"Gets",
"a",
"list",
"of",
":",
"py",
":",
"class",
":",
"GridQubit",
"s",
"corresponding",
"to",
"the",
"qubit",
"nodes",
"provided",
"on",
"the",
"given",
"Architecture",
"."
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/cirq_convert.py#L62-L71 |
CQCL/pytket | pytket/cirq/cirq_convert.py | cirq_to_tk | def cirq_to_tk(circuit: cirq.Circuit) -> Circuit:
"""Converts a Cirq :py:class:`Circuit` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object.
:param circuit: The input Cirq :py:class:`Circuit`
:raises NotImplementedError: If the input contains a Cirq :py:class:`Circuit` operation whi... | python | def cirq_to_tk(circuit: cirq.Circuit) -> Circuit:
"""Converts a Cirq :py:class:`Circuit` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object.
:param circuit: The input Cirq :py:class:`Circuit`
:raises NotImplementedError: If the input contains a Cirq :py:class:`Circuit` operation whi... | [
"def",
"cirq_to_tk",
"(",
"circuit",
":",
"cirq",
".",
"Circuit",
")",
"->",
"Circuit",
":",
"qubit_list",
"=",
"_indexed_qubits_from_circuit",
"(",
"circuit",
")",
"qid_to_num",
"=",
"{",
"q",
":",
"i",
"for",
"i",
",",
"q",
"in",
"enumerate",
"(",
"qub... | Converts a Cirq :py:class:`Circuit` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object.
:param circuit: The input Cirq :py:class:`Circuit`
:raises NotImplementedError: If the input contains a Cirq :py:class:`Circuit` operation which is not yet supported by pytket
:return: The :m... | [
"Converts",
"a",
"Cirq",
":",
"py",
":",
"class",
":",
"Circuit",
"to",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
"object",
".",
":",
"param",
"circuit",
":",
"The",
"inpu... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/cirq_convert.py#L73-L111 |
CQCL/pytket | pytket/cirq/cirq_convert.py | tk_to_cirq | def tk_to_cirq(tkcirc: Circuit, indexed_qubits: List[QubitId]) -> cirq.Circuit:
"""Converts a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object to a Cirq :py:class:`Circuit`.
:param tkcirc: The input :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`
:param indexed_qubits: Map from :math:`\\m... | python | def tk_to_cirq(tkcirc: Circuit, indexed_qubits: List[QubitId]) -> cirq.Circuit:
"""Converts a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object to a Cirq :py:class:`Circuit`.
:param tkcirc: The input :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`
:param indexed_qubits: Map from :math:`\\m... | [
"def",
"tk_to_cirq",
"(",
"tkcirc",
":",
"Circuit",
",",
"indexed_qubits",
":",
"List",
"[",
"QubitId",
"]",
")",
"->",
"cirq",
".",
"Circuit",
":",
"grid",
"=",
"tkcirc",
".",
"_int_routing_grid",
"(",
")",
"qubits",
"=",
"_grid_to_qubits",
"(",
"grid",
... | Converts a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` object to a Cirq :py:class:`Circuit`.
:param tkcirc: The input :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`
:param indexed_qubits: Map from :math:`\\mathrm{t|ket}\\rangle` qubit indices to Cirq :py:class:`QubitId` s
:return: The... | [
"Converts",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
"object",
"to",
"a",
"Cirq",
":",
"py",
":",
"class",
":",
"Circuit",
".",
":",
"param",
"tkcirc",
":",
"The",
"input... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/cirq_convert.py#L113-L157 |
CQCL/pytket | pytket/qiskit/dagcircuit_convert.py | dagcircuit_to_tk | def dagcircuit_to_tk(dag:DAGCircuit, _BOX_UNKNOWN:bool=BOX_UNKNOWN, _DROP_CONDS:bool=DROP_CONDS) -> Circuit :
"""Converts a :py:class:`qiskit.DAGCircuit` into a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`.
Note that not all Qiskit operations are currently supported by pytket. Classical registers are sup... | python | def dagcircuit_to_tk(dag:DAGCircuit, _BOX_UNKNOWN:bool=BOX_UNKNOWN, _DROP_CONDS:bool=DROP_CONDS) -> Circuit :
"""Converts a :py:class:`qiskit.DAGCircuit` into a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`.
Note that not all Qiskit operations are currently supported by pytket. Classical registers are sup... | [
"def",
"dagcircuit_to_tk",
"(",
"dag",
":",
"DAGCircuit",
",",
"_BOX_UNKNOWN",
":",
"bool",
"=",
"BOX_UNKNOWN",
",",
"_DROP_CONDS",
":",
"bool",
"=",
"DROP_CONDS",
")",
"->",
"Circuit",
":",
"qs",
"=",
"dag",
".",
"get_qubits",
"(",
")",
"qnames",
"=",
"... | Converts a :py:class:`qiskit.DAGCircuit` into a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit`.
Note that not all Qiskit operations are currently supported by pytket. Classical registers are supported only as
the output of measurements. This does not attempt to preserve the structure
of the quantum r... | [
"Converts",
"a",
":",
"py",
":",
"class",
":",
"qiskit",
".",
"DAGCircuit",
"into",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
".",
"Note",
"that",
"not",
"all",
"Qiskit",
... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/qiskit/dagcircuit_convert.py#L61-L104 |
CQCL/pytket | pytket/qiskit/dagcircuit_convert.py | tk_to_dagcircuit | def tk_to_dagcircuit(circ:Circuit,_qreg_name:str="q") -> DAGCircuit :
"""
Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`qiskit.DAGCircuit` . Requires
that the circuit only conatins :py:class:`OpType` s from the qelib set.
:param circ: A circuit to be converted
... | python | def tk_to_dagcircuit(circ:Circuit,_qreg_name:str="q") -> DAGCircuit :
"""
Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`qiskit.DAGCircuit` . Requires
that the circuit only conatins :py:class:`OpType` s from the qelib set.
:param circ: A circuit to be converted
... | [
"def",
"tk_to_dagcircuit",
"(",
"circ",
":",
"Circuit",
",",
"_qreg_name",
":",
"str",
"=",
"\"q\"",
")",
"->",
"DAGCircuit",
":",
"dc",
"=",
"DAGCircuit",
"(",
")",
"qreg",
"=",
"QuantumRegister",
"(",
"circ",
".",
"n_qubits",
"(",
")",
",",
"name",
"... | Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`qiskit.DAGCircuit` . Requires
that the circuit only conatins :py:class:`OpType` s from the qelib set.
:param circ: A circuit to be converted
:return: The converted circuit | [
"Convert",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
"to",
"a",
":",
"py",
":",
"class",
":",
"qiskit",
".",
"DAGCircuit",
".",
"Requires",
"that",
"the",
"circuit",
"only",... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/qiskit/dagcircuit_convert.py#L258-L293 |
CQCL/pytket | pytket/qiskit/dagcircuit_convert.py | coupling_to_arc | def coupling_to_arc(coupling_map:List[List[int]]) -> Architecture:
"""
Produces a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` corresponding to a (directed) coupling map,
stating the pairs of qubits between which two-qubit interactions
(e.g. CXs) can be applied.
:param coupling... | python | def coupling_to_arc(coupling_map:List[List[int]]) -> Architecture:
"""
Produces a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` corresponding to a (directed) coupling map,
stating the pairs of qubits between which two-qubit interactions
(e.g. CXs) can be applied.
:param coupling... | [
"def",
"coupling_to_arc",
"(",
"coupling_map",
":",
"List",
"[",
"List",
"[",
"int",
"]",
"]",
")",
"->",
"Architecture",
":",
"coupling",
"=",
"CouplingMap",
"(",
"couplinglist",
"=",
"coupling_map",
")",
"return",
"DirectedGraph",
"(",
"coupling_map",
",",
... | Produces a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` corresponding to a (directed) coupling map,
stating the pairs of qubits between which two-qubit interactions
(e.g. CXs) can be applied.
:param coupling_map: Pairs of indices where each pair [control, target]
permits the use of... | [
"Produces",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Architecture",
"corresponding",
"to",
"a",
"(",
"directed",
")",
"coupling",
"map",
"stating",
"the",
"pairs",
"of",
"qubits",
"betwe... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/qiskit/dagcircuit_convert.py#L368-L380 |
CQCL/pytket | pytket/qiskit/tket_pass.py | TketPass.run | def run(self, dag:DAGCircuit) -> DAGCircuit:
"""
Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit
"""
circ = dagcircuit_to_tk(dag, _DROP_CONDS=self.DROP_CONDS,_BO... | python | def run(self, dag:DAGCircuit) -> DAGCircuit:
"""
Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit
"""
circ = dagcircuit_to_tk(dag, _DROP_CONDS=self.DROP_CONDS,_BO... | [
"def",
"run",
"(",
"self",
",",
"dag",
":",
"DAGCircuit",
")",
"->",
"DAGCircuit",
":",
"circ",
"=",
"dagcircuit_to_tk",
"(",
"dag",
",",
"_DROP_CONDS",
"=",
"self",
".",
"DROP_CONDS",
",",
"_BOX_UNKNOWN",
"=",
"self",
".",
"BOX_UNKNOWN",
")",
"circ",
",... | Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit | [
"Run",
"one",
"pass",
"of",
"optimisation",
"on",
"the",
"circuit",
"and",
"route",
"for",
"the",
"given",
"backend",
"."
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/qiskit/tket_pass.py#L51-L68 |
CQCL/pytket | pytket/cirq/qubits.py | _sort_row_col | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
"""Sort grid qubits first by row then by column"""
return sorted(qubits, key=lambda x: (x.row, x.col)) | python | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
"""Sort grid qubits first by row then by column"""
return sorted(qubits, key=lambda x: (x.row, x.col)) | [
"def",
"_sort_row_col",
"(",
"qubits",
":",
"Iterator",
"[",
"GridQubit",
"]",
")",
"->",
"List",
"[",
"GridQubit",
"]",
":",
"return",
"sorted",
"(",
"qubits",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"row",
",",
"x",
".",
"col",
")",
... | Sort grid qubits first by row then by column | [
"Sort",
"grid",
"qubits",
"first",
"by",
"row",
"then",
"by",
"column"
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/qubits.py#L51-L54 |
CQCL/pytket | pytket/cirq/qubits.py | xmon_to_arc | def xmon_to_arc(xmon: XmonDevice) -> Architecture:
"""Generates a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` object for a Cirq :py:class:`XmonDevice` .
:param xmon: The device to convert
:return: The corresponding :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture`
"""
node... | python | def xmon_to_arc(xmon: XmonDevice) -> Architecture:
"""Generates a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` object for a Cirq :py:class:`XmonDevice` .
:param xmon: The device to convert
:return: The corresponding :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture`
"""
node... | [
"def",
"xmon_to_arc",
"(",
"xmon",
":",
"XmonDevice",
")",
"->",
"Architecture",
":",
"nodes",
"=",
"len",
"(",
"xmon",
".",
"qubits",
")",
"indexed_qubits",
"=",
"_sort_row_col",
"(",
"xmon",
".",
"qubits",
")",
"pairs",
"=",
"[",
"]",
"for",
"qb",
"i... | Generates a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` object for a Cirq :py:class:`XmonDevice` .
:param xmon: The device to convert
:return: The corresponding :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` | [
"Generates",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Architecture",
"object",
"for",
"a",
"Cirq",
":",
"py",
":",
"class",
":",
"XmonDevice",
".",
":",
"param",
"xmon",
":",
"The",
... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/qubits.py#L56-L73 |
CQCL/pytket | pytket/pyquil/pyquil_convert.py | pyquil_to_tk | def pyquil_to_tk(prog: Program) -> Circuit:
"""
Convert a :py:class:`pyquil.Program` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` .
Note that not all pyQuil operations are currently supported by pytket.
:param prog: A circuit to be converted
:return: The converted circuit
"""
... | python | def pyquil_to_tk(prog: Program) -> Circuit:
"""
Convert a :py:class:`pyquil.Program` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` .
Note that not all pyQuil operations are currently supported by pytket.
:param prog: A circuit to be converted
:return: The converted circuit
"""
... | [
"def",
"pyquil_to_tk",
"(",
"prog",
":",
"Program",
")",
"->",
"Circuit",
":",
"reg_name",
"=",
"None",
"qubits",
"=",
"prog",
".",
"get_qubits",
"(",
")",
"n_qubits",
"=",
"max",
"(",
"qubits",
")",
"+",
"1",
"tkc",
"=",
"Circuit",
"(",
"n_qubits",
... | Convert a :py:class:`pyquil.Program` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` .
Note that not all pyQuil operations are currently supported by pytket.
:param prog: A circuit to be converted
:return: The converted circuit | [
"Convert",
"a",
":",
"py",
":",
"class",
":",
"pyquil",
".",
"Program",
"to",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
".",
"Note",
"that",
"not",
"all",
"pyQuil",
"opera... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/pyquil/pyquil_convert.py#L47-L90 |
CQCL/pytket | pytket/pyquil/pyquil_convert.py | tk_to_pyquil | def tk_to_pyquil(circ: Circuit) -> Program:
"""
Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`pyquil.Program` .
:param circ: A circuit to be converted
:return: The converted circuit
"""
p = Program()
ro = p.declare('ro', 'BIT', circ.n_qubits())
gr... | python | def tk_to_pyquil(circ: Circuit) -> Program:
"""
Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`pyquil.Program` .
:param circ: A circuit to be converted
:return: The converted circuit
"""
p = Program()
ro = p.declare('ro', 'BIT', circ.n_qubits())
gr... | [
"def",
"tk_to_pyquil",
"(",
"circ",
":",
"Circuit",
")",
"->",
"Program",
":",
"p",
"=",
"Program",
"(",
")",
"ro",
"=",
"p",
".",
"declare",
"(",
"'ro'",
",",
"'BIT'",
",",
"circ",
".",
"n_qubits",
"(",
")",
")",
"grid",
"=",
"circ",
".",
"_int_... | Convert a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` to a :py:class:`pyquil.Program` .
:param circ: A circuit to be converted
:return: The converted circuit | [
"Convert",
"a",
":",
"math",
":",
"\\\\",
"mathrm",
"{",
"t|ket",
"}",
"\\\\",
"rangle",
":",
"py",
":",
"class",
":",
"Circuit",
"to",
"a",
":",
"py",
":",
"class",
":",
"pyquil",
".",
"Program",
".",
":",
"param",
"circ",
":",
"A",
"circuit",
"... | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/pyquil/pyquil_convert.py#L100-L135 |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE.print_setting | def print_setting(self) -> str:
"""
Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance
"""
ret = "\n"
ret += "==================== Setting of {} ============================\n".format(self.configuration['name'])
ret += "{}"... | python | def print_setting(self) -> str:
"""
Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance
"""
ret = "\n"
ret += "==================== Setting of {} ============================\n".format(self.configuration['name'])
ret += "{}"... | [
"def",
"print_setting",
"(",
"self",
")",
"->",
"str",
":",
"ret",
"=",
"\"\\n\"",
"ret",
"+=",
"\"==================== Setting of {} ============================\\n\"",
".",
"format",
"(",
"self",
".",
"configuration",
"[",
"'name'",
"]",
")",
"ret",
"+=",
"\"{}\... | Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance | [
"Presents",
"the",
"QSE",
"settings",
"as",
"a",
"string",
"."
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L117-L129 |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE._energy_evaluation | def _energy_evaluation(self, operator):
"""
Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian
"""
if self._quantum_state is not None:
input_circu... | python | def _energy_evaluation(self, operator):
"""
Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian
"""
if self._quantum_state is not None:
input_circu... | [
"def",
"_energy_evaluation",
"(",
"self",
",",
"operator",
")",
":",
"if",
"self",
".",
"_quantum_state",
"is",
"not",
"None",
":",
"input_circuit",
"=",
"self",
".",
"_quantum_state",
"else",
":",
"input_circuit",
"=",
"[",
"self",
".",
"opt_circuit",
"]",
... | Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian | [
"Evaluate",
"the",
"energy",
"of",
"the",
"current",
"input",
"circuit",
"with",
"respect",
"to",
"the",
"given",
"operator",
"."
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L131-L151 |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE._run | def _run(self) -> dict:
"""
Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results
"""
if not self._quantum_instance.is_statevector:
raise AquaError("Can only calculate state for QSE with statevector backends")
re... | python | def _run(self) -> dict:
"""
Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results
"""
if not self._quantum_instance.is_statevector:
raise AquaError("Can only calculate state for QSE with statevector backends")
re... | [
"def",
"_run",
"(",
"self",
")",
"->",
"dict",
":",
"if",
"not",
"self",
".",
"_quantum_instance",
".",
"is_statevector",
":",
"raise",
"AquaError",
"(",
"\"Can only calculate state for QSE with statevector backends\"",
")",
"ret",
"=",
"self",
".",
"_quantum_instan... | Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results | [
"Runs",
"the",
"QSE",
"algorithm",
"to",
"compute",
"the",
"eigenvalues",
"of",
"the",
"Hamiltonian",
"."
] | train | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L260-L274 |
bkabrda/flask-whooshee | flask_whooshee.py | WhoosheeQuery.whooshee_search | def whooshee_search(self, search_string, group=whoosh.qparser.OrGroup, whoosheer=None,
match_substrings=True, limit=None, order_by_relevance=10):
"""Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The... | python | def whooshee_search(self, search_string, group=whoosh.qparser.OrGroup, whoosheer=None,
match_substrings=True, limit=None, order_by_relevance=10):
"""Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The... | [
"def",
"whooshee_search",
"(",
"self",
",",
"search_string",
",",
"group",
"=",
"whoosh",
".",
"qparser",
".",
"OrGroup",
",",
"whoosheer",
"=",
"None",
",",
"match_substrings",
"=",
"True",
",",
"limit",
"=",
"None",
",",
"order_by_relevance",
"=",
"10",
... | Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The string to search for.
:param group: The whoosh group to use for searching.
Defaults to :class:`whoosh.qparser.OrGroup` which
sea... | [
"Do",
"a",
"fulltext",
"search",
"on",
"the",
"query",
".",
"Returns",
"a",
"query",
"filtered",
"with",
"results",
"of",
"the",
"fulltext",
"search",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L44-L123 |
bkabrda/flask-whooshee | flask_whooshee.py | AbstractWhoosheer.search | def search(cls, search_string, values_of='', group=whoosh.qparser.OrGroup, match_substrings=True, limit=None):
"""Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string t... | python | def search(cls, search_string, values_of='', group=whoosh.qparser.OrGroup, match_substrings=True, limit=None):
"""Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string t... | [
"def",
"search",
"(",
"cls",
",",
"search_string",
",",
"values_of",
"=",
"''",
",",
"group",
"=",
"whoosh",
".",
"qparser",
".",
"OrGroup",
",",
"match_substrings",
"=",
"True",
",",
"limit",
"=",
"None",
")",
":",
"index",
"=",
"Whooshee",
".",
"get_... | Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string to search for.
:param values_of: If given, the method will not return the whole
records, ... | [
"Searches",
"the",
"fields",
"for",
"given",
"search_string",
".",
"Returns",
"the",
"found",
"records",
"if",
"values_of",
"is",
"left",
"empty",
"else",
"the",
"values",
"of",
"the",
"given",
"columns",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L138-L163 |
bkabrda/flask-whooshee | flask_whooshee.py | AbstractWhoosheer.prep_search_string | def prep_search_string(cls, search_string, match_substrings):
"""Prepares search string as a proper whoosh search string.
:param search_string: The search string which should be prepared.
:param match_substrings: ``True`` if you want to match substrings,
``False... | python | def prep_search_string(cls, search_string, match_substrings):
"""Prepares search string as a proper whoosh search string.
:param search_string: The search string which should be prepared.
:param match_substrings: ``True`` if you want to match substrings,
``False... | [
"def",
"prep_search_string",
"(",
"cls",
",",
"search_string",
",",
"match_substrings",
")",
":",
"if",
"sys",
".",
"version",
"<",
"'3'",
"and",
"not",
"isinstance",
"(",
"search_string",
",",
"unicode",
")",
":",
"search_string",
"=",
"search_string",
".",
... | Prepares search string as a proper whoosh search string.
:param search_string: The search string which should be prepared.
:param match_substrings: ``True`` if you want to match substrings,
``False`` otherwise. | [
"Prepares",
"search",
"string",
"as",
"a",
"proper",
"whoosh",
"search",
"string",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L166-L184 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.init_app | def init_app(self, app):
"""Initialize the extension. It will create the `index_path_root`
directory upon initalization but it will **not** create the index.
Please use :meth:`reindex` for this.
:param app: The application instance for which the extension should
be i... | python | def init_app(self, app):
"""Initialize the extension. It will create the `index_path_root`
directory upon initalization but it will **not** create the index.
Please use :meth:`reindex` for this.
:param app: The application instance for which the extension should
be i... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"if",
"not",
"hasattr",
"(",
"app",
",",
"'extensions'",
")",
":",
"app",
".",
"extensions",
"=",
"{",
"}",
"config",
"=",
"app",
".",
"extensions",
".",
"setdefault",
"(",
"'whooshee'",
",",
"{",... | Initialize the extension. It will create the `index_path_root`
directory upon initalization but it will **not** create the index.
Please use :meth:`reindex` for this.
:param app: The application instance for which the extension should
be initialized. | [
"Initialize",
"the",
"extension",
".",
"It",
"will",
"create",
"the",
"index_path_root",
"directory",
"upon",
"initalization",
"but",
"it",
"will",
"**",
"not",
"**",
"create",
"the",
"index",
".",
"Please",
"use",
":",
"meth",
":",
"reindex",
"for",
"this",... | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L230-L257 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.register_whoosheer | def register_whoosheer(self, wh):
"""This will register the given whoosher on `whoosheers`, create the
neccessary SQLAlchemy event listeners, replace the `query_class` with
our own query class which will provide the search functionality
and store the app on the whoosheer, so that we can ... | python | def register_whoosheer(self, wh):
"""This will register the given whoosher on `whoosheers`, create the
neccessary SQLAlchemy event listeners, replace the `query_class` with
our own query class which will provide the search functionality
and store the app on the whoosheer, so that we can ... | [
"def",
"register_whoosheer",
"(",
"self",
",",
"wh",
")",
":",
"self",
".",
"whoosheers",
".",
"append",
"(",
"wh",
")",
"for",
"model",
"in",
"wh",
".",
"models",
":",
"event",
".",
"listen",
"(",
"model",
",",
"'after_{0}'",
".",
"format",
"(",
"IN... | This will register the given whoosher on `whoosheers`, create the
neccessary SQLAlchemy event listeners, replace the `query_class` with
our own query class which will provide the search functionality
and store the app on the whoosheer, so that we can always work
with that.
:param... | [
"This",
"will",
"register",
"the",
"given",
"whoosher",
"on",
"whoosheers",
"create",
"the",
"neccessary",
"SQLAlchemy",
"event",
"listeners",
"replace",
"the",
"query_class",
"with",
"our",
"own",
"query",
"class",
"which",
"will",
"provide",
"the",
"search",
"... | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L259-L292 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.register_model | def register_model(self, *index_fields, **kw):
"""Registers a single model for fulltext search. This basically creates
a simple Whoosheer for the model and calls :func:`register_whoosheer`
on it.
"""
# construct subclass of AbstractWhoosheer for a model
class ModelWhooshe... | python | def register_model(self, *index_fields, **kw):
"""Registers a single model for fulltext search. This basically creates
a simple Whoosheer for the model and calls :func:`register_whoosheer`
on it.
"""
# construct subclass of AbstractWhoosheer for a model
class ModelWhooshe... | [
"def",
"register_model",
"(",
"self",
",",
"*",
"index_fields",
",",
"*",
"*",
"kw",
")",
":",
"# construct subclass of AbstractWhoosheer for a model",
"class",
"ModelWhoosheer",
"(",
"AbstractWhoosheerMeta",
")",
":",
"@",
"classmethod",
"def",
"_assign_primary",
"("... | Registers a single model for fulltext search. This basically creates
a simple Whoosheer for the model and calls :func:`register_whoosheer`
on it. | [
"Registers",
"a",
"single",
"model",
"for",
"fulltext",
"search",
".",
"This",
"basically",
"creates",
"a",
"simple",
"Whoosheer",
"for",
"the",
"model",
"and",
"calls",
":",
"func",
":",
"register_whoosheer",
"on",
"it",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L294-L372 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.create_index | def create_index(cls, app, wh):
"""Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be create... | python | def create_index(cls, app, wh):
"""Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be create... | [
"def",
"create_index",
"(",
"cls",
",",
"app",
",",
"wh",
")",
":",
"# TODO: do we really want/need to use camel casing?",
"# everywhere else, there is just .lower()",
"if",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'memory_storage'",
"]",
":",
"storage",
... | Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be created. | [
"Creates",
"and",
"opens",
"an",
"index",
"for",
"the",
"given",
"whoosheer",
"and",
"app",
".",
"If",
"the",
"index",
"already",
"exists",
"it",
"just",
"opens",
"it",
"otherwise",
"it",
"creates",
"it",
"first",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L375-L399 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.camel_to_snake | def camel_to_snake(self, s):
"""Constructs nice dir name from class name, e.g. FooBar => foo_bar.
:param s: The string which should be converted to snake_case.
"""
return self._underscore_re2.sub(r'\1_\2', self._underscore_re1.sub(r'\1_\2', s)).lower() | python | def camel_to_snake(self, s):
"""Constructs nice dir name from class name, e.g. FooBar => foo_bar.
:param s: The string which should be converted to snake_case.
"""
return self._underscore_re2.sub(r'\1_\2', self._underscore_re1.sub(r'\1_\2', s)).lower() | [
"def",
"camel_to_snake",
"(",
"self",
",",
"s",
")",
":",
"return",
"self",
".",
"_underscore_re2",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"self",
".",
"_underscore_re1",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"s",
")",
")",
".",
"lower",
"(",
")"
] | Constructs nice dir name from class name, e.g. FooBar => foo_bar.
:param s: The string which should be converted to snake_case. | [
"Constructs",
"nice",
"dir",
"name",
"from",
"class",
"name",
"e",
".",
"g",
".",
"FooBar",
"=",
">",
"foo_bar",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L402-L407 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.get_or_create_index | def get_or_create_index(cls, app, wh):
"""Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created.
"""
... | python | def get_or_create_index(cls, app, wh):
"""Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created.
"""
... | [
"def",
"get_or_create_index",
"(",
"cls",
",",
"app",
",",
"wh",
")",
":",
"if",
"wh",
"in",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'whoosheers_indexes'",
"]",
":",
"return",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'whoos... | Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created. | [
"Gets",
"a",
"previously",
"cached",
"index",
"or",
"creates",
"a",
"new",
"one",
"for",
"the",
"given",
"app",
"and",
"whoosheer",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L410-L422 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.on_commit | def on_commit(self, changes):
"""Method that gets called when a model is changed. This serves
to do the actual index writing.
"""
if _get_config(self)['enable_indexing'] is False:
return None
for wh in self.whoosheers:
if not wh.auto_update:
... | python | def on_commit(self, changes):
"""Method that gets called when a model is changed. This serves
to do the actual index writing.
"""
if _get_config(self)['enable_indexing'] is False:
return None
for wh in self.whoosheers:
if not wh.auto_update:
... | [
"def",
"on_commit",
"(",
"self",
",",
"changes",
")",
":",
"if",
"_get_config",
"(",
"self",
")",
"[",
"'enable_indexing'",
"]",
"is",
"False",
":",
"return",
"None",
"for",
"wh",
"in",
"self",
".",
"whoosheers",
":",
"if",
"not",
"wh",
".",
"auto_upda... | Method that gets called when a model is changed. This serves
to do the actual index writing. | [
"Method",
"that",
"gets",
"called",
"when",
"a",
"model",
"is",
"changed",
".",
"This",
"serves",
"to",
"do",
"the",
"actual",
"index",
"writing",
"."
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L433-L454 |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.reindex | def reindex(self):
"""Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model.
"""
for wh in self.whoosheers:
index = type(self).get_or_create_index(_get_app(s... | python | def reindex(self):
"""Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model.
"""
for wh in self.whoosheers:
index = type(self).get_or_create_index(_get_app(s... | [
"def",
"reindex",
"(",
"self",
")",
":",
"for",
"wh",
"in",
"self",
".",
"whoosheers",
":",
"index",
"=",
"type",
"(",
"self",
")",
".",
"get_or_create_index",
"(",
"_get_app",
"(",
"self",
")",
",",
"wh",
")",
"writer",
"=",
"index",
".",
"writer",
... | Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model. | [
"Reindex",
"all",
"data"
] | train | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L456-L470 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.create_domain | def create_domain(self, domain, ipaddr, params=None):
''' /v1/dns/create_domain
POST - account
Create a domain name in DNS
Link: https://www.vultr.com/api/#dns_create_domain
'''
params = update_params(params, {
'domain': domain,
'ip': ipaddr
... | python | def create_domain(self, domain, ipaddr, params=None):
''' /v1/dns/create_domain
POST - account
Create a domain name in DNS
Link: https://www.vultr.com/api/#dns_create_domain
'''
params = update_params(params, {
'domain': domain,
'ip': ipaddr
... | [
"def",
"create_domain",
"(",
"self",
",",
"domain",
",",
"ipaddr",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
",",
"'ip'",
":",
"ipaddr",
"}",
")",
"return",
"self",
".",
... | /v1/dns/create_domain
POST - account
Create a domain name in DNS
Link: https://www.vultr.com/api/#dns_create_domain | [
"/",
"v1",
"/",
"dns",
"/",
"create_domain",
"POST",
"-",
"account",
"Create",
"a",
"domain",
"name",
"in",
"DNS"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L10-L21 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.create_record | def create_record(self, domain, name, _type, data, params=None):
''' /v1/dns/create_domain
POST - account
Add a DNS record
Link: https://www.vultr.com/api/#dns_create_record
'''
params = update_params(params, {
'domain': domain,
'name': name,
... | python | def create_record(self, domain, name, _type, data, params=None):
''' /v1/dns/create_domain
POST - account
Add a DNS record
Link: https://www.vultr.com/api/#dns_create_record
'''
params = update_params(params, {
'domain': domain,
'name': name,
... | [
"def",
"create_record",
"(",
"self",
",",
"domain",
",",
"name",
",",
"_type",
",",
"data",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
",",
"'name'",
":",
"name",
",",
"'t... | /v1/dns/create_domain
POST - account
Add a DNS record
Link: https://www.vultr.com/api/#dns_create_record | [
"/",
"v1",
"/",
"dns",
"/",
"create_domain",
"POST",
"-",
"account",
"Add",
"a",
"DNS",
"record"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L23-L36 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.delete_domain | def delete_domain(self, domain, params=None):
''' /v1/dns/delete_domain
POST - account
Delete a domain name (and all associated records)
Link: https://www.vultr.com/api/#dns_delete_domain
'''
params = update_params(params, {'domain': domain})
return self.request(... | python | def delete_domain(self, domain, params=None):
''' /v1/dns/delete_domain
POST - account
Delete a domain name (and all associated records)
Link: https://www.vultr.com/api/#dns_delete_domain
'''
params = update_params(params, {'domain': domain})
return self.request(... | [
"def",
"delete_domain",
"(",
"self",
",",
"domain",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
"}",
")",
"return",
"self",
".",
"request",
"(",
"'/v1/dns/delete_domain'",
",",
... | /v1/dns/delete_domain
POST - account
Delete a domain name (and all associated records)
Link: https://www.vultr.com/api/#dns_delete_domain | [
"/",
"v1",
"/",
"dns",
"/",
"delete_domain",
"POST",
"-",
"account",
"Delete",
"a",
"domain",
"name",
"(",
"and",
"all",
"associated",
"records",
")"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L38-L46 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.delete_record | def delete_record(self, domain, recordid, params=None):
''' /v1/dns/delete_record
POST - account
Deletes an individual DNS record
Link: https://www.vultr.com/api/#dns_delete_record
'''
params = update_params(params, {
'domain': domain,
'RECORDID':... | python | def delete_record(self, domain, recordid, params=None):
''' /v1/dns/delete_record
POST - account
Deletes an individual DNS record
Link: https://www.vultr.com/api/#dns_delete_record
'''
params = update_params(params, {
'domain': domain,
'RECORDID':... | [
"def",
"delete_record",
"(",
"self",
",",
"domain",
",",
"recordid",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
",",
"'RECORDID'",
":",
"recordid",
"}",
")",
"return",
"self",... | /v1/dns/delete_record
POST - account
Deletes an individual DNS record
Link: https://www.vultr.com/api/#dns_delete_record | [
"/",
"v1",
"/",
"dns",
"/",
"delete_record",
"POST",
"-",
"account",
"Deletes",
"an",
"individual",
"DNS",
"record"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L48-L59 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.records | def records(self, domain, params=None):
''' /v1/dns/records
GET - account
List all the records associated with a particular domain
Link: https://www.vultr.com/api/#dns_records
'''
params = update_params(params, {'domain': domain})
return self.request('/v1/dns/rec... | python | def records(self, domain, params=None):
''' /v1/dns/records
GET - account
List all the records associated with a particular domain
Link: https://www.vultr.com/api/#dns_records
'''
params = update_params(params, {'domain': domain})
return self.request('/v1/dns/rec... | [
"def",
"records",
"(",
"self",
",",
"domain",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
"}",
")",
"return",
"self",
".",
"request",
"(",
"'/v1/dns/records'",
",",
"params",
... | /v1/dns/records
GET - account
List all the records associated with a particular domain
Link: https://www.vultr.com/api/#dns_records | [
"/",
"v1",
"/",
"dns",
"/",
"records",
"GET",
"-",
"account",
"List",
"all",
"the",
"records",
"associated",
"with",
"a",
"particular",
"domain"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L71-L79 |
spry-group/python-vultr | vultr/v1_dns.py | VultrDNS.update_record | def update_record(self, domain, recordid, params=None):
''' /v1/dns/update_record
POST - account
Update a DNS record
Link: https://www.vultr.com/api/#dns_update_record
'''
params = update_params(params, {
'domain': domain,
'RECORDID': recordid
... | python | def update_record(self, domain, recordid, params=None):
''' /v1/dns/update_record
POST - account
Update a DNS record
Link: https://www.vultr.com/api/#dns_update_record
'''
params = update_params(params, {
'domain': domain,
'RECORDID': recordid
... | [
"def",
"update_record",
"(",
"self",
",",
"domain",
",",
"recordid",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'domain'",
":",
"domain",
",",
"'RECORDID'",
":",
"recordid",
"}",
")",
"return",
"self",... | /v1/dns/update_record
POST - account
Update a DNS record
Link: https://www.vultr.com/api/#dns_update_record | [
"/",
"v1",
"/",
"dns",
"/",
"update_record",
"POST",
"-",
"account",
"Update",
"a",
"DNS",
"record"
] | train | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_dns.py#L81-L92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.