partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | cure.__cluster_distance | !
@brief Calculate minimal distance between clusters using representative points.
@param[in] cluster1 (cure_cluster): The first cluster.
@param[in] cluster2 (cure_cluster): The second cluster.
@return (double) Euclidean distance between two clusters that is define... | pyclustering/cluster/cure.py | def __cluster_distance(self, cluster1, cluster2):
"""!
@brief Calculate minimal distance between clusters using representative points.
@param[in] cluster1 (cure_cluster): The first cluster.
@param[in] cluster2 (cure_cluster): The second cluster.
@return (... | def __cluster_distance(self, cluster1, cluster2):
"""!
@brief Calculate minimal distance between clusters using representative points.
@param[in] cluster1 (cure_cluster): The first cluster.
@param[in] cluster2 (cure_cluster): The second cluster.
@return (... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/cure.py#L519-L538 | [
"def",
"__cluster_distance",
"(",
"self",
",",
"cluster1",
",",
"cluster2",
")",
":",
"distance",
"=",
"float",
"(",
"'inf'",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"cluster1",
".",
"rep",
")",
")",
":",
"for",
"k",
"in",
"range... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_dynamic.allocate_observation_matrix | !
@brief Allocates observation matrix in line with output dynamic of the network.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration.
@return (list) Observation matrix of the network dynamic. | pyclustering/nnet/cnn.py | def allocate_observation_matrix(self):
"""!
@brief Allocates observation matrix in line with output dynamic of the network.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration.
@return (list) Observation matrix... | def allocate_observation_matrix(self):
"""!
@brief Allocates observation matrix in line with output dynamic of the network.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration.
@return (list) Observation matrix... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L95-L113 | [
"def",
"allocate_observation_matrix",
"(",
"self",
")",
":",
"number_neurons",
"=",
"len",
"(",
"self",
".",
"output",
"[",
"0",
"]",
")",
"observation_matrix",
"=",
"[",
"]",
"for",
"iteration",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"output",
")"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_dynamic.__allocate_neuron_patterns | !
@brief Allocates observation transposed matrix of neurons that is limited by specified periods of simulation.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each iteration.
@return (list) Transposed observation matrix that is l... | pyclustering/nnet/cnn.py | def __allocate_neuron_patterns(self, start_iteration, stop_iteration):
"""!
@brief Allocates observation transposed matrix of neurons that is limited by specified periods of simulation.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each i... | def __allocate_neuron_patterns(self, start_iteration, stop_iteration):
"""!
@brief Allocates observation transposed matrix of neurons that is limited by specified periods of simulation.
@details Matrix where state of each neuron is denoted by zero/one in line with Heaviside function on each i... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L116-L133 | [
"def",
"__allocate_neuron_patterns",
"(",
"self",
",",
"start_iteration",
",",
"stop_iteration",
")",
":",
"pattern_matrix",
"=",
"[",
"]",
"for",
"index_neuron",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"output",
"[",
"0",
"]",
")",
")",
":",
"pattern... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_dynamic.allocate_sync_ensembles | !
@brief Allocate clusters in line with ensembles of synchronous neurons where each synchronous ensemble corresponds to only one cluster.
@param[in] steps (double): Amount of steps from the end that is used for analysis. During specified period chaotic neural network should have stabl... | pyclustering/nnet/cnn.py | def allocate_sync_ensembles(self, steps):
"""!
@brief Allocate clusters in line with ensembles of synchronous neurons where each synchronous ensemble corresponds to only one cluster.
@param[in] steps (double): Amount of steps from the end that is used for analysis. During spe... | def allocate_sync_ensembles(self, steps):
"""!
@brief Allocate clusters in line with ensembles of synchronous neurons where each synchronous ensemble corresponds to only one cluster.
@param[in] steps (double): Amount of steps from the end that is used for analysis. During spe... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L136-L177 | [
"def",
"allocate_sync_ensembles",
"(",
"self",
",",
"steps",
")",
":",
"iterations",
"=",
"steps",
"if",
"iterations",
">=",
"len",
"(",
"self",
".",
"output",
")",
":",
"iterations",
"=",
"len",
"(",
"self",
".",
"output",
")",
"ensembles",
"=",
"[",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_visualizer.show_dynamic_matrix | !
@brief Shows output dynamic as matrix in grey colors.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural network.
@see show_output_dynamic
... | pyclustering/nnet/cnn.py | def show_dynamic_matrix(cnn_output_dynamic):
"""!
@brief Shows output dynamic as matrix in grey colors.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural netw... | def show_dynamic_matrix(cnn_output_dynamic):
"""!
@brief Shows output dynamic as matrix in grey colors.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural netw... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L202-L217 | [
"def",
"show_dynamic_matrix",
"(",
"cnn_output_dynamic",
")",
":",
"network_dynamic",
"=",
"numpy",
".",
"array",
"(",
"cnn_output_dynamic",
".",
"output",
")",
"plt",
".",
"imshow",
"(",
"network_dynamic",
".",
"T",
",",
"cmap",
"=",
"plt",
".",
"get_cmap",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_visualizer.show_observation_matrix | !
@brief Shows observation matrix as black/white blocks.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural network.
@see show_output_dynamic
... | pyclustering/nnet/cnn.py | def show_observation_matrix(cnn_output_dynamic):
"""!
@brief Shows observation matrix as black/white blocks.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural... | def show_observation_matrix(cnn_output_dynamic):
"""!
@brief Shows observation matrix as black/white blocks.
@details This type of visualization is convenient for observing allocated clusters.
@param[in] cnn_output_dynamic (cnn_dynamic): Output dynamic of the chaotic neural... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L221-L235 | [
"def",
"show_observation_matrix",
"(",
"cnn_output_dynamic",
")",
":",
"observation_matrix",
"=",
"numpy",
".",
"array",
"(",
"cnn_output_dynamic",
".",
"allocate_observation_matrix",
"(",
")",
")",
"plt",
".",
"imshow",
"(",
"observation_matrix",
".",
"T",
",",
"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.simulate | !
@brief Simulates chaotic neural network with extrnal stimulus during specified steps.
@details Stimulus are considered as a coordinates of neurons and in line with that weights
are initialized.
@param[in] steps (uint): Amount of steps for simulation.
@pa... | pyclustering/nnet/cnn.py | def simulate(self, steps, stimulus):
"""!
@brief Simulates chaotic neural network with extrnal stimulus during specified steps.
@details Stimulus are considered as a coordinates of neurons and in line with that weights
are initialized.
@param[in] steps (ui... | def simulate(self, steps, stimulus):
"""!
@brief Simulates chaotic neural network with extrnal stimulus during specified steps.
@details Stimulus are considered as a coordinates of neurons and in line with that weights
are initialized.
@param[in] steps (ui... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L306-L332 | [
"def",
"simulate",
"(",
"self",
",",
"steps",
",",
"stimulus",
")",
":",
"self",
".",
"__create_weights",
"(",
"stimulus",
")",
"self",
".",
"__location",
"=",
"stimulus",
"dynamic",
"=",
"cnn_dynamic",
"(",
"[",
"]",
",",
"[",
"]",
")",
"dynamic",
"."... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__calculate_states | !
@brief Calculates new state of each neuron.
@detail There is no any assignment.
@return (list) Returns new states (output). | pyclustering/nnet/cnn.py | def __calculate_states(self):
"""!
@brief Calculates new state of each neuron.
@detail There is no any assignment.
@return (list) Returns new states (output).
"""
output = [ 0.0 for _ in range(self.__num_osc) ]
for i ... | def __calculate_states(self):
"""!
@brief Calculates new state of each neuron.
@detail There is no any assignment.
@return (list) Returns new states (output).
"""
output = [ 0.0 for _ in range(self.__num_osc) ]
for i ... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L335-L349 | [
"def",
"__calculate_states",
"(",
"self",
")",
":",
"output",
"=",
"[",
"0.0",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"__num_osc",
")",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"__num_osc",
")",
":",
"output",
"[",
"i",
"]",
"=",
"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__neuron_evolution | !
@brief Calculates state of the neuron with specified index.
@param[in] index (uint): Index of neuron in the network.
@return (double) New output of the specified neuron. | pyclustering/nnet/cnn.py | def __neuron_evolution(self, index):
"""!
@brief Calculates state of the neuron with specified index.
@param[in] index (uint): Index of neuron in the network.
@return (double) New output of the specified neuron.
"""
value = 0.0
... | def __neuron_evolution(self, index):
"""!
@brief Calculates state of the neuron with specified index.
@param[in] index (uint): Index of neuron in the network.
@return (double) New output of the specified neuron.
"""
value = 0.0
... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L352-L366 | [
"def",
"__neuron_evolution",
"(",
"self",
",",
"index",
")",
":",
"value",
"=",
"0.0",
"for",
"index_neighbor",
"in",
"range",
"(",
"self",
".",
"__num_osc",
")",
":",
"value",
"+=",
"self",
".",
"__weights",
"[",
"index",
"]",
"[",
"index_neighbor",
"]"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__create_weights | !
@brief Create weights between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network. | pyclustering/nnet/cnn.py | def __create_weights(self, stimulus):
"""!
@brief Create weights between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
self.__average_distance = average_neighbor_distance(stimulu... | def __create_weights(self, stimulus):
"""!
@brief Create weights between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
self.__average_distance = average_neighbor_distance(stimulu... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L369-L386 | [
"def",
"__create_weights",
"(",
"self",
",",
"stimulus",
")",
":",
"self",
".",
"__average_distance",
"=",
"average_neighbor_distance",
"(",
"stimulus",
",",
"self",
".",
"__amount_neighbors",
")",
"self",
".",
"__weights",
"=",
"[",
"[",
"0.0",
"for",
"_",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__create_weights_all_to_all | !
@brief Create weight all-to-all structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network. | pyclustering/nnet/cnn.py | def __create_weights_all_to_all(self, stimulus):
"""!
@brief Create weight all-to-all structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
for i in range(len(stimulus)... | def __create_weights_all_to_all(self, stimulus):
"""!
@brief Create weight all-to-all structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
for i in range(len(stimulus)... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L389-L405 | [
"def",
"__create_weights_all_to_all",
"(",
"self",
",",
"stimulus",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"stimulus",
")",
")",
":",
"for",
"j",
"in",
"range",
"(",
"i",
"+",
"1",
",",
"len",
"(",
"stimulus",
")",
")",
":",
"weight"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__create_weights_delaunay_triangulation | !
@brief Create weight Denlauny triangulation structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network. | pyclustering/nnet/cnn.py | def __create_weights_delaunay_triangulation(self, stimulus):
"""!
@brief Create weight Denlauny triangulation structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
poin... | def __create_weights_delaunay_triangulation(self, stimulus):
"""!
@brief Create weight Denlauny triangulation structure between neurons in line with stimulus.
@param[in] stimulus (list): External stimulus for the chaotic neural network.
"""
poin... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L408-L431 | [
"def",
"__create_weights_delaunay_triangulation",
"(",
"self",
",",
"stimulus",
")",
":",
"points",
"=",
"numpy",
".",
"array",
"(",
"stimulus",
")",
"triangulation",
"=",
"Delaunay",
"(",
"points",
")",
"for",
"triangle",
"in",
"triangulation",
".",
"simplices"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__calculate_weight | !
@brief Calculate weight between neurons that have external stimulus1 and stimulus2.
@param[in] stimulus1 (list): External stimulus of the first neuron.
@param[in] stimulus2 (list): External stimulus of the second neuron.
@return (double) Weight between neurons t... | pyclustering/nnet/cnn.py | def __calculate_weight(self, stimulus1, stimulus2):
"""!
@brief Calculate weight between neurons that have external stimulus1 and stimulus2.
@param[in] stimulus1 (list): External stimulus of the first neuron.
@param[in] stimulus2 (list): External stimulus of the second neur... | def __calculate_weight(self, stimulus1, stimulus2):
"""!
@brief Calculate weight between neurons that have external stimulus1 and stimulus2.
@param[in] stimulus1 (list): External stimulus of the first neuron.
@param[in] stimulus2 (list): External stimulus of the second neur... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L434-L446 | [
"def",
"__calculate_weight",
"(",
"self",
",",
"stimulus1",
",",
"stimulus2",
")",
":",
"distance",
"=",
"euclidean_distance_square",
"(",
"stimulus1",
",",
"stimulus2",
")",
"return",
"math",
".",
"exp",
"(",
"-",
"distance",
"/",
"(",
"2.0",
"*",
"self",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.show_network | !
@brief Shows structure of the network: neurons and connections between them. | pyclustering/nnet/cnn.py | def show_network(self):
"""!
@brief Shows structure of the network: neurons and connections between them.
"""
dimension = len(self.__location[0])
if (dimension != 3) and (dimension != 2):
raise NameError('Network that is located in different ... | def show_network(self):
"""!
@brief Shows structure of the network: neurons and connections between them.
"""
dimension = len(self.__location[0])
if (dimension != 3) and (dimension != 2):
raise NameError('Network that is located in different ... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L449-L476 | [
"def",
"show_network",
"(",
"self",
")",
":",
"dimension",
"=",
"len",
"(",
"self",
".",
"__location",
"[",
"0",
"]",
")",
"if",
"(",
"dimension",
"!=",
"3",
")",
"and",
"(",
"dimension",
"!=",
"2",
")",
":",
"raise",
"NameError",
"(",
"'Network that... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cnn_network.__create_surface | !
@brief Prepares surface for showing network structure in line with specified dimension.
@param[in] dimension (uint): Dimension of processed data (external stimulus).
@return (tuple) Description of surface for drawing network structure. | pyclustering/nnet/cnn.py | def __create_surface(self, dimension):
"""!
@brief Prepares surface for showing network structure in line with specified dimension.
@param[in] dimension (uint): Dimension of processed data (external stimulus).
@return (tuple) Description of surface for drawing net... | def __create_surface(self, dimension):
"""!
@brief Prepares surface for showing network structure in line with specified dimension.
@param[in] dimension (uint): Dimension of processed data (external stimulus).
@return (tuple) Description of surface for drawing net... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/cnn.py#L479-L503 | [
"def",
"__create_surface",
"(",
"self",
",",
"dimension",
")",
":",
"rcParams",
"[",
"'font.sans-serif'",
"]",
"=",
"[",
"'Arial'",
"]",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"axes",
"=",
"None",
"i... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr_visualizer.show_pattern | !
@brief Displays evolution of phase oscillators as set of patterns where the last one means final result of recognition.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr network.
@param[in] image_height (uint): Height of the pattern (image_height * image_wi... | pyclustering/nnet/syncpr.py | def show_pattern(syncpr_output_dynamic, image_height, image_width):
"""!
@brief Displays evolution of phase oscillators as set of patterns where the last one means final result of recognition.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr network.
... | def show_pattern(syncpr_output_dynamic, image_height, image_width):
"""!
@brief Displays evolution of phase oscillators as set of patterns where the last one means final result of recognition.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr network.
... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L78-L125 | [
"def",
"show_pattern",
"(",
"syncpr_output_dynamic",
",",
"image_height",
",",
"image_width",
")",
":",
"number_pictures",
"=",
"len",
"(",
"syncpr_output_dynamic",
")",
"iteration_math_step",
"=",
"1.0",
"if",
"(",
"number_pictures",
">",
"50",
")",
":",
"iterati... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr_visualizer.animate_pattern_recognition | !
@brief Shows animation of pattern recognition process that has been preformed by the oscillatory network.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr network.
@param[in] image_height (uint): Height of the pattern (image_height * image_width should be ... | pyclustering/nnet/syncpr.py | def animate_pattern_recognition(syncpr_output_dynamic, image_height, image_width, animation_velocity = 75, title = None, save_movie = None):
"""!
@brief Shows animation of pattern recognition process that has been preformed by the oscillatory network.
@param[in] syncpr_output_dynamic (s... | def animate_pattern_recognition(syncpr_output_dynamic, image_height, image_width, animation_velocity = 75, title = None, save_movie = None):
"""!
@brief Shows animation of pattern recognition process that has been preformed by the oscillatory network.
@param[in] syncpr_output_dynamic (s... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L129-L170 | [
"def",
"animate_pattern_recognition",
"(",
"syncpr_output_dynamic",
",",
"image_height",
",",
"image_width",
",",
"animation_velocity",
"=",
"75",
",",
"title",
"=",
"None",
",",
"save_movie",
"=",
"None",
")",
":",
"figure",
"=",
"plt",
".",
"figure",
"(",
")... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr_visualizer.__show_pattern | !
@brief Draws pattern on specified ax.
@param[in] ax_handle (Axis): Axis where pattern should be drawn.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr network.
@param[in] image_height (uint): Height of the pattern (image_height * image_width shoul... | pyclustering/nnet/syncpr.py | def __show_pattern(ax_handle, syncpr_output_dynamic, image_height, image_width, iteration):
"""!
@brief Draws pattern on specified ax.
@param[in] ax_handle (Axis): Axis where pattern should be drawn.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr n... | def __show_pattern(ax_handle, syncpr_output_dynamic, image_height, image_width, iteration):
"""!
@brief Draws pattern on specified ax.
@param[in] ax_handle (Axis): Axis where pattern should be drawn.
@param[in] syncpr_output_dynamic (syncpr_dynamic): Output dynamic of a syncpr n... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L174-L209 | [
"def",
"__show_pattern",
"(",
"ax_handle",
",",
"syncpr_output_dynamic",
",",
"image_height",
",",
"image_width",
",",
"iteration",
")",
":",
"current_dynamic",
"=",
"syncpr_output_dynamic",
".",
"output",
"[",
"iteration",
"]",
"stage_picture",
"=",
"[",
"(",
"25... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.train | !
@brief Trains syncpr network using Hebbian rule for adjusting strength of connections between oscillators during training.
@param[in] samples (list): list of patterns where each pattern is represented by list of features that are equal to [-1; 1]. | pyclustering/nnet/syncpr.py | def train(self, samples):
"""!
@brief Trains syncpr network using Hebbian rule for adjusting strength of connections between oscillators during training.
@param[in] samples (list): list of patterns where each pattern is represented by list of features that are equal to [-1; 1].
... | def train(self, samples):
"""!
@brief Trains syncpr network using Hebbian rule for adjusting strength of connections between oscillators during training.
@param[in] samples (list): list of patterns where each pattern is represented by list of features that are equal to [-1; 1].
... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L285-L314 | [
"def",
"train",
"(",
"self",
",",
"samples",
")",
":",
"# Verify pattern for learning",
"for",
"pattern",
"in",
"samples",
":",
"self",
".",
"__validate_pattern",
"(",
"pattern",
")",
"if",
"(",
"self",
".",
"_ccore_network_pointer",
"is",
"not",
"None",
")",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.simulate_dynamic | !
@brief Performs dynamic simulation of the network until stop condition is not reached.
@details In other words network performs pattern recognition during simulation.
Stop condition is defined by input argument 'order' that represents memory order, but
process of sim... | pyclustering/nnet/syncpr.py | def simulate_dynamic(self, pattern, order = 0.998, solution = solve_type.RK4, collect_dynamic = False, step = 0.1, int_step = 0.01, threshold_changes = 0.0000001):
"""!
@brief Performs dynamic simulation of the network until stop condition is not reached.
@details In other words network performs... | def simulate_dynamic(self, pattern, order = 0.998, solution = solve_type.RK4, collect_dynamic = False, step = 0.1, int_step = 0.01, threshold_changes = 0.0000001):
"""!
@brief Performs dynamic simulation of the network until stop condition is not reached.
@details In other words network performs... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L339-L415 | [
"def",
"simulate_dynamic",
"(",
"self",
",",
"pattern",
",",
"order",
"=",
"0.998",
",",
"solution",
"=",
"solve_type",
".",
"RK4",
",",
"collect_dynamic",
"=",
"False",
",",
"step",
"=",
"0.1",
",",
"int_step",
"=",
"0.01",
",",
"threshold_changes",
"=",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.simulate_static | !
@brief Performs static simulation of syncpr oscillatory network.
@details In other words network performs pattern recognition during simulation.
@param[in] steps (uint): Number steps of simulations during simulation.
@param[in] time (double): Time of simulation.
@param... | pyclustering/nnet/syncpr.py | def simulate_static(self, steps, time, pattern, solution = solve_type.FAST, collect_dynamic = False):
"""!
@brief Performs static simulation of syncpr oscillatory network.
@details In other words network performs pattern recognition during simulation.
@param[in] steps (uint): Nu... | def simulate_static(self, steps, time, pattern, solution = solve_type.FAST, collect_dynamic = False):
"""!
@brief Performs static simulation of syncpr oscillatory network.
@details In other words network performs pattern recognition during simulation.
@param[in] steps (uint): Nu... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L418-L449 | [
"def",
"simulate_static",
"(",
"self",
",",
"steps",
",",
"time",
",",
"pattern",
",",
"solution",
"=",
"solve_type",
".",
"FAST",
",",
"collect_dynamic",
"=",
"False",
")",
":",
"self",
".",
"__validate_pattern",
"(",
"pattern",
")",
"if",
"(",
"self",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.memory_order | !
@brief Calculates function of the memorized pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern for recognition represented by list of feature... | pyclustering/nnet/syncpr.py | def memory_order(self, pattern):
"""!
@brief Calculates function of the memorized pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern fo... | def memory_order(self, pattern):
"""!
@brief Calculates function of the memorized pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern fo... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L452-L469 | [
"def",
"memory_order",
"(",
"self",
",",
"pattern",
")",
":",
"self",
".",
"__validate_pattern",
"(",
"pattern",
")",
"if",
"(",
"self",
".",
"_ccore_network_pointer",
"is",
"not",
"None",
")",
":",
"return",
"wrapper",
".",
"syncpr_memory_order",
"(",
"self... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.__calculate_memory_order | !
@brief Calculates function of the memorized pattern without any pattern validation.
@param[in] pattern (list): Pattern for recognition represented by list of features that are equal to [-1; 1].
@return (double) Order of memory for the specified pattern. | pyclustering/nnet/syncpr.py | def __calculate_memory_order(self, pattern):
"""!
@brief Calculates function of the memorized pattern without any pattern validation.
@param[in] pattern (list): Pattern for recognition represented by list of features that are equal to [-1; 1].
@return (double) Order of ... | def __calculate_memory_order(self, pattern):
"""!
@brief Calculates function of the memorized pattern without any pattern validation.
@param[in] pattern (list): Pattern for recognition represented by list of features that are equal to [-1; 1].
@return (double) Order of ... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L472-L487 | [
"def",
"__calculate_memory_order",
"(",
"self",
",",
"pattern",
")",
":",
"memory_order",
"=",
"0.0",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"memory_order",
"+=",
"pattern",
"[",
"index",
"]",
"*",
"cmath",
".",
"exp",
"... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr._phase_kuramoto | !
@brief Returns result of phase calculation for specified oscillator in the network.
@param[in] teta (double): Phase of the oscillator that is differentiated.
@param[in] t (double): Current time of simulation.
@param[in] argv (tuple): Index of the oscillator in the list.
... | pyclustering/nnet/syncpr.py | def _phase_kuramoto(self, teta, t, argv):
"""!
@brief Returns result of phase calculation for specified oscillator in the network.
@param[in] teta (double): Phase of the oscillator that is differentiated.
@param[in] t (double): Current time of simulation.
@param[in] argv... | def _phase_kuramoto(self, teta, t, argv):
"""!
@brief Returns result of phase calculation for specified oscillator in the network.
@param[in] teta (double): Phase of the oscillator that is differentiated.
@param[in] t (double): Current time of simulation.
@param[in] argv... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L490-L518 | [
"def",
"_phase_kuramoto",
"(",
"self",
",",
"teta",
",",
"t",
",",
"argv",
")",
":",
"index",
"=",
"argv",
"phase",
"=",
"0.0",
"term",
"=",
"0.0",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"self",
".",
"_num_osc",
")",
":",
"if",
"(",
"k",
"!=... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | syncpr.__validate_pattern | !
@brief Validates pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern for recognition represented by list of features that are equal to [-1; 1]... | pyclustering/nnet/syncpr.py | def __validate_pattern(self, pattern):
"""!
@brief Validates pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern for recognition represe... | def __validate_pattern(self, pattern):
"""!
@brief Validates pattern.
@details Throws exception if length of pattern is not equal to size of the network or if it consists feature with value that are not equal to [-1; 1].
@param[in] pattern (list): Pattern for recognition represe... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncpr.py#L521-L534 | [
"def",
"__validate_pattern",
"(",
"self",
",",
"pattern",
")",
":",
"if",
"(",
"len",
"(",
"pattern",
")",
"!=",
"len",
"(",
"self",
")",
")",
":",
"raise",
"NameError",
"(",
"'syncpr: length of the pattern ('",
"+",
"len",
"(",
"pattern",
")",
"+",
"') ... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | kmedians.process | !
@brief Performs cluster analysis in line with rules of K-Medians algorithm.
@return (kmedians) Returns itself (K-Medians instance).
@remark Results of clustering can be obtained using corresponding get methods.
@see get_clusters()
@see get_medians() | pyclustering/cluster/kmedians.py | def process(self):
"""!
@brief Performs cluster analysis in line with rules of K-Medians algorithm.
@return (kmedians) Returns itself (K-Medians instance).
@remark Results of clustering can be obtained using corresponding get methods.
@see get_clusters()
... | def process(self):
"""!
@brief Performs cluster analysis in line with rules of K-Medians algorithm.
@return (kmedians) Returns itself (K-Medians instance).
@remark Results of clustering can be obtained using corresponding get methods.
@see get_clusters()
... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/kmedians.py#L104-L139 | [
"def",
"process",
"(",
"self",
")",
":",
"if",
"self",
".",
"__ccore",
"is",
"True",
":",
"ccore_metric",
"=",
"metric_wrapper",
".",
"create_instance",
"(",
"self",
".",
"__metric",
")",
"self",
".",
"__clusters",
",",
"self",
".",
"__medians",
"=",
"wr... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | kmedians.__update_clusters | !
@brief Calculate Manhattan distance to each point from the each cluster.
@details Nearest points are captured by according clusters and as a result clusters are updated.
@return (list) updated clusters as list of clusters where each cluster contains indexes of objects from data. | pyclustering/cluster/kmedians.py | def __update_clusters(self):
"""!
@brief Calculate Manhattan distance to each point from the each cluster.
@details Nearest points are captured by according clusters and as a result clusters are updated.
@return (list) updated clusters as list of clusters where each cluste... | def __update_clusters(self):
"""!
@brief Calculate Manhattan distance to each point from the each cluster.
@details Nearest points are captured by according clusters and as a result clusters are updated.
@return (list) updated clusters as list of clusters where each cluste... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/kmedians.py#L179-L205 | [
"def",
"__update_clusters",
"(",
"self",
")",
":",
"clusters",
"=",
"[",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__medians",
")",
")",
"]",
"for",
"index_point",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__pointer_data... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | kmedians.__update_medians | !
@brief Calculate medians of clusters in line with contained objects.
@return (list) list of medians for current number of clusters. | pyclustering/cluster/kmedians.py | def __update_medians(self):
"""!
@brief Calculate medians of clusters in line with contained objects.
@return (list) list of medians for current number of clusters.
"""
medians = [[] for i in range(len(self.__clusters))]
for... | def __update_medians(self):
"""!
@brief Calculate medians of clusters in line with contained objects.
@return (list) list of medians for current number of clusters.
"""
medians = [[] for i in range(len(self.__clusters))]
for... | [
"!"
] | annoviko/pyclustering | python | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/kmedians.py#L208-L235 | [
"def",
"__update_medians",
"(",
"self",
")",
":",
"medians",
"=",
"[",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__clusters",
")",
")",
"]",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__clusters",
")",
... | 98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0 |
valid | cleanup_old_versions | Deletes old deployed versions of the function in AWS Lambda.
Won't delete $Latest and any aliased version
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param int keep_last_versions:
The number ... | aws_lambda/aws_lambda.py | def cleanup_old_versions(
src, keep_last_versions,
config_file='config.yaml', profile_name=None,
):
"""Deletes old deployed versions of the function in AWS Lambda.
Won't delete $Latest and any aliased version
:param str src:
The path to your Lambda ready project (folder must contain a vali... | def cleanup_old_versions(
src, keep_last_versions,
config_file='config.yaml', profile_name=None,
):
"""Deletes old deployed versions of the function in AWS Lambda.
Won't delete $Latest and any aliased version
:param str src:
The path to your Lambda ready project (folder must contain a vali... | [
"Deletes",
"old",
"deployed",
"versions",
"of",
"the",
"function",
"in",
"AWS",
"Lambda",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L40-L86 | [
"def",
"cleanup_old_versions",
"(",
"src",
",",
"keep_last_versions",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
")",
":",
"if",
"keep_last_versions",
"<=",
"0",
":",
"print",
"(",
"\"Won't delete all versions. Please do this manu... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | deploy | Deploys a new function to AWS Lambda.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_package:
The path to a local package with should be included in the deploy as
well (and/or... | aws_lambda/aws_lambda.py | def deploy(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function to AWS Lambda.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler... | def deploy(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function to AWS Lambda.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler... | [
"Deploys",
"a",
"new",
"function",
"to",
"AWS",
"Lambda",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L89-L121 | [
"def",
"deploy",
"(",
"src",
",",
"requirements",
"=",
"None",
",",
"local_package",
"=",
"None",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
"preserve_vpc",
"=",
"False",
")",
":",
"# Load and parse the config file.",
"path_... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | deploy_s3 | Deploys a new function via AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_package:
The path to a local package with should be included in the deploy as
well (and/or is... | aws_lambda/aws_lambda.py | def deploy_s3(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function via AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g... | def deploy_s3(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function via AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g... | [
"Deploys",
"a",
"new",
"function",
"via",
"AWS",
"S3",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L124-L158 | [
"def",
"deploy_s3",
"(",
"src",
",",
"requirements",
"=",
"None",
",",
"local_package",
"=",
"None",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
"preserve_vpc",
"=",
"False",
")",
":",
"# Load and parse the config file.",
"pa... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | upload | Uploads a new function to AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_package:
The path to a local package with should be included in the deploy as
well (and/or is ... | aws_lambda/aws_lambda.py | def upload(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Uploads a new function to AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
... | def upload(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Uploads a new function to AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
... | [
"Uploads",
"a",
"new",
"function",
"to",
"AWS",
"S3",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L161-L187 | [
"def",
"upload",
"(",
"src",
",",
"requirements",
"=",
"None",
",",
"local_package",
"=",
"None",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
")",
":",
"# Load and parse the config file.",
"path_to_config_file",
"=",
"os",
".... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | invoke | Simulates a call to your function.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str alt_event:
An optional argument to override which event file to use.
:param bool verbose:
Wheth... | aws_lambda/aws_lambda.py | def invoke(
src, event_file='event.json',
config_file='config.yaml', profile_name=None,
verbose=False,
):
"""Simulates a call to your function.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:... | def invoke(
src, event_file='event.json',
config_file='config.yaml', profile_name=None,
verbose=False,
):
"""Simulates a call to your function.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:... | [
"Simulates",
"a",
"call",
"to",
"your",
"function",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L190-L248 | [
"def",
"invoke",
"(",
"src",
",",
"event_file",
"=",
"'event.json'",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
")",
":",
"# Load and parse the config file.",
"path_to_config_file",
"=",
"os",
"... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | init | Copies template files to a given directory.
:param str src:
The path to output the template lambda project files.
:param bool minimal:
Minimal possible template files (excludes event.json). | aws_lambda/aws_lambda.py | def init(src, minimal=False):
"""Copies template files to a given directory.
:param str src:
The path to output the template lambda project files.
:param bool minimal:
Minimal possible template files (excludes event.json).
"""
templates_path = os.path.join(
os.path.dirname(... | def init(src, minimal=False):
"""Copies template files to a given directory.
:param str src:
The path to output the template lambda project files.
:param bool minimal:
Minimal possible template files (excludes event.json).
"""
templates_path = os.path.join(
os.path.dirname(... | [
"Copies",
"template",
"files",
"to",
"a",
"given",
"directory",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L251-L269 | [
"def",
"init",
"(",
"src",
",",
"minimal",
"=",
"False",
")",
":",
"templates_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"'project_temp... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | build | Builds the file bundle.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_package:
The path to a local package with should be included in the deploy as
well (and/or is not availab... | aws_lambda/aws_lambda.py | def build(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Builds the file bundle.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_pa... | def build(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Builds the file bundle.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_pa... | [
"Builds",
"the",
"file",
"bundle",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L272-L366 | [
"def",
"build",
"(",
"src",
",",
"requirements",
"=",
"None",
",",
"local_package",
"=",
"None",
",",
"config_file",
"=",
"'config.yaml'",
",",
"profile_name",
"=",
"None",
",",
")",
":",
"# Load and parse the config file.",
"path_to_config_file",
"=",
"os",
"."... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | get_callable_handler_function | Tranlate a string of the form "module.function" into a callable
function.
:param str src:
The path to your Lambda project containing a valid handler file.
:param str handler:
A dot delimited string representing the `<module>.<function name>`. | aws_lambda/aws_lambda.py | def get_callable_handler_function(src, handler):
"""Tranlate a string of the form "module.function" into a callable
function.
:param str src:
The path to your Lambda project containing a valid handler file.
:param str handler:
A dot delimited string representing the `<module>.<function name... | def get_callable_handler_function(src, handler):
"""Tranlate a string of the form "module.function" into a callable
function.
:param str src:
The path to your Lambda project containing a valid handler file.
:param str handler:
A dot delimited string representing the `<module>.<function name... | [
"Tranlate",
"a",
"string",
"of",
"the",
"form",
"module",
".",
"function",
"into",
"a",
"callable",
"function",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L369-L387 | [
"def",
"get_callable_handler_function",
"(",
"src",
",",
"handler",
")",
":",
"# \"cd\" into `src` directory.",
"os",
".",
"chdir",
"(",
"src",
")",
"module_name",
",",
"function_name",
"=",
"handler",
".",
"split",
"(",
"'.'",
")",
"filename",
"=",
"get_handler... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | _install_packages | Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:param list packages:
A list of packages ... | aws_lambda/aws_lambda.py | def _install_packages(path, packages):
"""Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:pa... | def _install_packages(path, packages):
"""Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:pa... | [
"Install",
"all",
"packages",
"listed",
"to",
"the",
"target",
"directory",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L400-L421 | [
"def",
"_install_packages",
"(",
"path",
",",
"packages",
")",
":",
"def",
"_filter_blacklist",
"(",
"package",
")",
":",
"blacklist",
"=",
"[",
"'-i'",
",",
"'#'",
",",
"'Python=='",
",",
"'python-lambda=='",
"]",
"return",
"all",
"(",
"package",
".",
"st... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | pip_install_to_target | For a given active virtualenv, gather all installed pip packages then
copy (re-install) them to the path provided.
:param str path:
Path to copy installed pip packages to.
:param str requirements:
If set, only the packages in the supplied requirements file are
installed.
If ... | aws_lambda/aws_lambda.py | def pip_install_to_target(path, requirements=None, local_package=None):
"""For a given active virtualenv, gather all installed pip packages then
copy (re-install) them to the path provided.
:param str path:
Path to copy installed pip packages to.
:param str requirements:
If set, only th... | def pip_install_to_target(path, requirements=None, local_package=None):
"""For a given active virtualenv, gather all installed pip packages then
copy (re-install) them to the path provided.
:param str path:
Path to copy installed pip packages to.
:param str requirements:
If set, only th... | [
"For",
"a",
"given",
"active",
"virtualenv",
"gather",
"all",
"installed",
"pip",
"packages",
"then",
"copy",
"(",
"re",
"-",
"install",
")",
"them",
"to",
"the",
"path",
"provided",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L424-L457 | [
"def",
"pip_install_to_target",
"(",
"path",
",",
"requirements",
"=",
"None",
",",
"local_package",
"=",
"None",
")",
":",
"packages",
"=",
"[",
"]",
"if",
"not",
"requirements",
":",
"print",
"(",
"'Gathering pip packages'",
")",
"pkgStr",
"=",
"subprocess",... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | get_role_name | Shortcut to insert the `account_id` and `role` into the iam string. | aws_lambda/aws_lambda.py | def get_role_name(region, account_id, role):
"""Shortcut to insert the `account_id` and `role` into the iam string."""
prefix = ARN_PREFIXES.get(region, 'aws')
return 'arn:{0}:iam::{1}:role/{2}'.format(prefix, account_id, role) | def get_role_name(region, account_id, role):
"""Shortcut to insert the `account_id` and `role` into the iam string."""
prefix = ARN_PREFIXES.get(region, 'aws')
return 'arn:{0}:iam::{1}:role/{2}'.format(prefix, account_id, role) | [
"Shortcut",
"to",
"insert",
"the",
"account_id",
"and",
"role",
"into",
"the",
"iam",
"string",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L460-L463 | [
"def",
"get_role_name",
"(",
"region",
",",
"account_id",
",",
"role",
")",
":",
"prefix",
"=",
"ARN_PREFIXES",
".",
"get",
"(",
"region",
",",
"'aws'",
")",
"return",
"'arn:{0}:iam::{1}:role/{2}'",
".",
"format",
"(",
"prefix",
",",
"account_id",
",",
"role... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | get_account_id | Query STS for a users' account_id | aws_lambda/aws_lambda.py | def get_account_id(
profile_name, aws_access_key_id, aws_secret_access_key,
region=None,
):
"""Query STS for a users' account_id"""
client = get_client(
'sts', profile_name, aws_access_key_id, aws_secret_access_key,
region,
)
return client.get_caller_identity().get('Account') | def get_account_id(
profile_name, aws_access_key_id, aws_secret_access_key,
region=None,
):
"""Query STS for a users' account_id"""
client = get_client(
'sts', profile_name, aws_access_key_id, aws_secret_access_key,
region,
)
return client.get_caller_identity().get('Account') | [
"Query",
"STS",
"for",
"a",
"users",
"account_id"
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L466-L475 | [
"def",
"get_account_id",
"(",
"profile_name",
",",
"aws_access_key_id",
",",
"aws_secret_access_key",
",",
"region",
"=",
"None",
",",
")",
":",
"client",
"=",
"get_client",
"(",
"'sts'",
",",
"profile_name",
",",
"aws_access_key_id",
",",
"aws_secret_access_key",
... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | get_client | Shortcut for getting an initialized instance of the boto3 client. | aws_lambda/aws_lambda.py | def get_client(
client, profile_name, aws_access_key_id, aws_secret_access_key,
region=None,
):
"""Shortcut for getting an initialized instance of the boto3 client."""
boto3.setup_default_session(
profile_name=profile_name,
aws_access_key_id=aws_access_key_id,
aws_secret_access_... | def get_client(
client, profile_name, aws_access_key_id, aws_secret_access_key,
region=None,
):
"""Shortcut for getting an initialized instance of the boto3 client."""
boto3.setup_default_session(
profile_name=profile_name,
aws_access_key_id=aws_access_key_id,
aws_secret_access_... | [
"Shortcut",
"for",
"getting",
"an",
"initialized",
"instance",
"of",
"the",
"boto3",
"client",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L478-L490 | [
"def",
"get_client",
"(",
"client",
",",
"profile_name",
",",
"aws_access_key_id",
",",
"aws_secret_access_key",
",",
"region",
"=",
"None",
",",
")",
":",
"boto3",
".",
"setup_default_session",
"(",
"profile_name",
"=",
"profile_name",
",",
"aws_access_key_id",
"... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | create_function | Register and upload a function to AWS Lambda. | aws_lambda/aws_lambda.py | def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
"""Register and upload a function to AWS Lambda."""
print('Creating your new Lambda function')
byte_stream = read(path_to_zip_file, binary_file=True)
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key... | def create_function(cfg, path_to_zip_file, use_s3=False, s3_file=None):
"""Register and upload a function to AWS Lambda."""
print('Creating your new Lambda function')
byte_stream = read(path_to_zip_file, binary_file=True)
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key... | [
"Register",
"and",
"upload",
"a",
"function",
"to",
"AWS",
"Lambda",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L493-L585 | [
"def",
"create_function",
"(",
"cfg",
",",
"path_to_zip_file",
",",
"use_s3",
"=",
"False",
",",
"s3_file",
"=",
"None",
")",
":",
"print",
"(",
"'Creating your new Lambda function'",
")",
"byte_stream",
"=",
"read",
"(",
"path_to_zip_file",
",",
"binary_file",
... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | update_function | Updates the code of an existing Lambda function | aws_lambda/aws_lambda.py | def update_function(
cfg, path_to_zip_file, existing_cfg, use_s3=False, s3_file=None, preserve_vpc=False
):
"""Updates the code of an existing Lambda function"""
print('Updating your Lambda function')
byte_stream = read(path_to_zip_file, binary_file=True)
profile_name = cfg.get('profile')
a... | def update_function(
cfg, path_to_zip_file, existing_cfg, use_s3=False, s3_file=None, preserve_vpc=False
):
"""Updates the code of an existing Lambda function"""
print('Updating your Lambda function')
byte_stream = read(path_to_zip_file, binary_file=True)
profile_name = cfg.get('profile')
a... | [
"Updates",
"the",
"code",
"of",
"an",
"existing",
"Lambda",
"function"
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L588-L686 | [
"def",
"update_function",
"(",
"cfg",
",",
"path_to_zip_file",
",",
"existing_cfg",
",",
"use_s3",
"=",
"False",
",",
"s3_file",
"=",
"None",
",",
"preserve_vpc",
"=",
"False",
")",
":",
"print",
"(",
"'Updating your Lambda function'",
")",
"byte_stream",
"=",
... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | upload_s3 | Upload a function to AWS S3. | aws_lambda/aws_lambda.py | def upload_s3(cfg, path_to_zip_file, *use_s3):
"""Upload a function to AWS S3."""
print('Uploading your new Lambda function')
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key_id')
aws_secret_access_key = cfg.get('aws_secret_access_key')
client = get_client(
... | def upload_s3(cfg, path_to_zip_file, *use_s3):
"""Upload a function to AWS S3."""
print('Uploading your new Lambda function')
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key_id')
aws_secret_access_key = cfg.get('aws_secret_access_key')
client = get_client(
... | [
"Upload",
"a",
"function",
"to",
"AWS",
"S3",
"."
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L689-L726 | [
"def",
"upload_s3",
"(",
"cfg",
",",
"path_to_zip_file",
",",
"*",
"use_s3",
")",
":",
"print",
"(",
"'Uploading your new Lambda function'",
")",
"profile_name",
"=",
"cfg",
".",
"get",
"(",
"'profile'",
")",
"aws_access_key_id",
"=",
"cfg",
".",
"get",
"(",
... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | get_function_config | Check whether a function exists or not and return its config | aws_lambda/aws_lambda.py | def get_function_config(cfg):
"""Check whether a function exists or not and return its config"""
function_name = cfg.get('function_name')
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key_id')
aws_secret_access_key = cfg.get('aws_secret_access_key')
client = get_clie... | def get_function_config(cfg):
"""Check whether a function exists or not and return its config"""
function_name = cfg.get('function_name')
profile_name = cfg.get('profile')
aws_access_key_id = cfg.get('aws_access_key_id')
aws_secret_access_key = cfg.get('aws_secret_access_key')
client = get_clie... | [
"Check",
"whether",
"a",
"function",
"exists",
"or",
"not",
"and",
"return",
"its",
"config"
] | nficano/python-lambda | python | https://github.com/nficano/python-lambda/blob/b0bd25404df70212d7fa057758760366406d64f2/aws_lambda/aws_lambda.py#L729-L745 | [
"def",
"get_function_config",
"(",
"cfg",
")",
":",
"function_name",
"=",
"cfg",
".",
"get",
"(",
"'function_name'",
")",
"profile_name",
"=",
"cfg",
".",
"get",
"(",
"'profile'",
")",
"aws_access_key_id",
"=",
"cfg",
".",
"get",
"(",
"'aws_access_key_id'",
... | b0bd25404df70212d7fa057758760366406d64f2 |
valid | cached_download | Download the data at a URL, and cache it under the given name.
The file is stored under `pyav/test` with the given name in the directory
:envvar:`PYAV_TESTDATA_DIR`, or the first that is writeable of:
- the current virtualenv
- ``/usr/local/share``
- ``/usr/local/lib``
- ``/usr/share``
- `... | av/datasets.py | def cached_download(url, name):
"""Download the data at a URL, and cache it under the given name.
The file is stored under `pyav/test` with the given name in the directory
:envvar:`PYAV_TESTDATA_DIR`, or the first that is writeable of:
- the current virtualenv
- ``/usr/local/share``
- ``/usr/... | def cached_download(url, name):
"""Download the data at a URL, and cache it under the given name.
The file is stored under `pyav/test` with the given name in the directory
:envvar:`PYAV_TESTDATA_DIR`, or the first that is writeable of:
- the current virtualenv
- ``/usr/local/share``
- ``/usr/... | [
"Download",
"the",
"data",
"at",
"a",
"URL",
"and",
"cache",
"it",
"under",
"the",
"given",
"name",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/av/datasets.py#L53-L105 | [
"def",
"cached_download",
"(",
"url",
",",
"name",
")",
":",
"clean_name",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"name",
")",
"if",
"clean_name",
"!=",
"name",
":",
"raise",
"ValueError",
"(",
"\"{} is not normalized.\"",
".",
"format",
"(",
"name"... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | fate | Download and return a path to a sample from the FFmpeg test suite.
Data is handled by :func:`cached_download`.
See the `FFmpeg Automated Test Environment <https://www.ffmpeg.org/fate.html>`_ | av/datasets.py | def fate(name):
"""Download and return a path to a sample from the FFmpeg test suite.
Data is handled by :func:`cached_download`.
See the `FFmpeg Automated Test Environment <https://www.ffmpeg.org/fate.html>`_
"""
return cached_download('http://fate.ffmpeg.org/fate-suite/' + name,
... | def fate(name):
"""Download and return a path to a sample from the FFmpeg test suite.
Data is handled by :func:`cached_download`.
See the `FFmpeg Automated Test Environment <https://www.ffmpeg.org/fate.html>`_
"""
return cached_download('http://fate.ffmpeg.org/fate-suite/' + name,
... | [
"Download",
"and",
"return",
"a",
"path",
"to",
"a",
"sample",
"from",
"the",
"FFmpeg",
"test",
"suite",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/av/datasets.py#L108-L117 | [
"def",
"fate",
"(",
"name",
")",
":",
"return",
"cached_download",
"(",
"'http://fate.ffmpeg.org/fate-suite/'",
"+",
"name",
",",
"os",
".",
"path",
".",
"join",
"(",
"'fate-suite'",
",",
"name",
".",
"replace",
"(",
"'/'",
",",
"os",
".",
"path",
".",
"... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | curated | Download and return a path to a sample that is curated by the PyAV developers.
Data is handled by :func:`cached_download`. | av/datasets.py | def curated(name):
"""Download and return a path to a sample that is curated by the PyAV developers.
Data is handled by :func:`cached_download`.
"""
return cached_download('https://docs.mikeboers.com/pyav/samples/' + name,
os.path.join('pyav-curated', name.replace('/', os.pa... | def curated(name):
"""Download and return a path to a sample that is curated by the PyAV developers.
Data is handled by :func:`cached_download`.
"""
return cached_download('https://docs.mikeboers.com/pyav/samples/' + name,
os.path.join('pyav-curated', name.replace('/', os.pa... | [
"Download",
"and",
"return",
"a",
"path",
"to",
"a",
"sample",
"that",
"is",
"curated",
"by",
"the",
"PyAV",
"developers",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/av/datasets.py#L120-L127 | [
"def",
"curated",
"(",
"name",
")",
":",
"return",
"cached_download",
"(",
"'https://docs.mikeboers.com/pyav/samples/'",
"+",
"name",
",",
"os",
".",
"path",
".",
"join",
"(",
"'pyav-curated'",
",",
"name",
".",
"replace",
"(",
"'/'",
",",
"os",
".",
"path",... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | get_library_config | Get distutils-compatible extension extras for the given library.
This requires ``pkg-config``. | setup.py | def get_library_config(name):
"""Get distutils-compatible extension extras for the given library.
This requires ``pkg-config``.
"""
try:
proc = Popen(['pkg-config', '--cflags', '--libs', name], stdout=PIPE, stderr=PIPE)
except OSError:
print('pkg-config is required for building PyA... | def get_library_config(name):
"""Get distutils-compatible extension extras for the given library.
This requires ``pkg-config``.
"""
try:
proc = Popen(['pkg-config', '--cflags', '--libs', name], stdout=PIPE, stderr=PIPE)
except OSError:
print('pkg-config is required for building PyA... | [
"Get",
"distutils",
"-",
"compatible",
"extension",
"extras",
"for",
"the",
"given",
"library",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/setup.py#L76-L97 | [
"def",
"get_library_config",
"(",
"name",
")",
":",
"try",
":",
"proc",
"=",
"Popen",
"(",
"[",
"'pkg-config'",
",",
"'--cflags'",
",",
"'--libs'",
",",
"name",
"]",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
")",
"except",
"OSError",
":",... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | update_extend | Update the `dst` with the `src`, extending values where lists.
Primiarily useful for integrating results from `get_library_config`. | setup.py | def update_extend(dst, src):
"""Update the `dst` with the `src`, extending values where lists.
Primiarily useful for integrating results from `get_library_config`.
"""
for k, v in src.items():
existing = dst.setdefault(k, [])
for x in v:
if x not in existing:
... | def update_extend(dst, src):
"""Update the `dst` with the `src`, extending values where lists.
Primiarily useful for integrating results from `get_library_config`.
"""
for k, v in src.items():
existing = dst.setdefault(k, [])
for x in v:
if x not in existing:
... | [
"Update",
"the",
"dst",
"with",
"the",
"src",
"extending",
"values",
"where",
"lists",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/setup.py#L100-L110 | [
"def",
"update_extend",
"(",
"dst",
",",
"src",
")",
":",
"for",
"k",
",",
"v",
"in",
"src",
".",
"items",
"(",
")",
":",
"existing",
"=",
"dst",
".",
"setdefault",
"(",
"k",
",",
"[",
"]",
")",
"for",
"x",
"in",
"v",
":",
"if",
"x",
"not",
... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | dump_config | Print out all the config information we have so far (for debugging). | setup.py | def dump_config():
"""Print out all the config information we have so far (for debugging)."""
print('PyAV:', version, git_commit or '(unknown commit)')
print('Python:', sys.version.encode('unicode_escape' if PY3 else 'string-escape'))
print('platform:', platform.platform())
print('extension_extra:')... | def dump_config():
"""Print out all the config information we have so far (for debugging)."""
print('PyAV:', version, git_commit or '(unknown commit)')
print('Python:', sys.version.encode('unicode_escape' if PY3 else 'string-escape'))
print('platform:', platform.platform())
print('extension_extra:')... | [
"Print",
"out",
"all",
"the",
"config",
"information",
"we",
"have",
"so",
"far",
"(",
"for",
"debugging",
")",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/setup.py#L169-L179 | [
"def",
"dump_config",
"(",
")",
":",
"print",
"(",
"'PyAV:'",
",",
"version",
",",
"git_commit",
"or",
"'(unknown commit)'",
")",
"print",
"(",
"'Python:'",
",",
"sys",
".",
"version",
".",
"encode",
"(",
"'unicode_escape'",
"if",
"PY3",
"else",
"'string-esc... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | _CCompiler_spawn_silent | Spawn a process, and eat the stdio. | setup.py | def _CCompiler_spawn_silent(cmd, dry_run=None):
"""Spawn a process, and eat the stdio."""
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
if proc.returncode:
raise DistutilsExecError(err) | def _CCompiler_spawn_silent(cmd, dry_run=None):
"""Spawn a process, and eat the stdio."""
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
if proc.returncode:
raise DistutilsExecError(err) | [
"Spawn",
"a",
"process",
"and",
"eat",
"the",
"stdio",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/setup.py#L183-L188 | [
"def",
"_CCompiler_spawn_silent",
"(",
"cmd",
",",
"dry_run",
"=",
"None",
")",
":",
"proc",
"=",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
")",
"out",
",",
"err",
"=",
"proc",
".",
"communicate",
"(",
")",
"if",
... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | new_compiler | Create a C compiler.
:param bool silent: Eat all stdio? Defaults to ``True``.
All other arguments passed to ``distutils.ccompiler.new_compiler``. | setup.py | def new_compiler(*args, **kwargs):
"""Create a C compiler.
:param bool silent: Eat all stdio? Defaults to ``True``.
All other arguments passed to ``distutils.ccompiler.new_compiler``.
"""
make_silent = kwargs.pop('silent', True)
cc = _new_compiler(*args, **kwargs)
# If MSVC10, initialize ... | def new_compiler(*args, **kwargs):
"""Create a C compiler.
:param bool silent: Eat all stdio? Defaults to ``True``.
All other arguments passed to ``distutils.ccompiler.new_compiler``.
"""
make_silent = kwargs.pop('silent', True)
cc = _new_compiler(*args, **kwargs)
# If MSVC10, initialize ... | [
"Create",
"a",
"C",
"compiler",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/setup.py#L190-L215 | [
"def",
"new_compiler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"make_silent",
"=",
"kwargs",
".",
"pop",
"(",
"'silent'",
",",
"True",
")",
"cc",
"=",
"_new_compiler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# If MSVC10, initializ... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | iter_cython | Yield all ``.pyx`` and ``.pxd`` files in the given root. | docs/includes.py | def iter_cython(path):
'''Yield all ``.pyx`` and ``.pxd`` files in the given root.'''
for dir_path, dir_names, file_names in os.walk(path):
for file_name in file_names:
if file_name.startswith('.'):
continue
if os.path.splitext(file_name)[1] not in ('.pyx', '.pxd'... | def iter_cython(path):
'''Yield all ``.pyx`` and ``.pxd`` files in the given root.'''
for dir_path, dir_names, file_names in os.walk(path):
for file_name in file_names:
if file_name.startswith('.'):
continue
if os.path.splitext(file_name)[1] not in ('.pyx', '.pxd'... | [
"Yield",
"all",
".",
"pyx",
"and",
".",
"pxd",
"files",
"in",
"the",
"given",
"root",
"."
] | mikeboers/PyAV | python | https://github.com/mikeboers/PyAV/blob/9414187088b9b8dbaa180cfe1db6ceba243184ea/docs/includes.py#L123-L131 | [
"def",
"iter_cython",
"(",
"path",
")",
":",
"for",
"dir_path",
",",
"dir_names",
",",
"file_names",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"file_name",
"in",
"file_names",
":",
"if",
"file_name",
".",
"startswith",
"(",
"'.'",
")",
":"... | 9414187088b9b8dbaa180cfe1db6ceba243184ea |
valid | cleanup_text | It scrubs the garbled from its stream...
Or it gets the debugger again. | scrub.py | def cleanup_text (text):
"""
It scrubs the garbled from its stream...
Or it gets the debugger again.
"""
x = " ".join(map(lambda s: s.strip(), text.split("\n"))).strip()
x = x.replace('“', '"').replace('”', '"')
x = x.replace("‘", "'").replace("’", "'").replace("`", "'")
x = x.replace('... | def cleanup_text (text):
"""
It scrubs the garbled from its stream...
Or it gets the debugger again.
"""
x = " ".join(map(lambda s: s.strip(), text.split("\n"))).strip()
x = x.replace('“', '"').replace('”', '"')
x = x.replace("‘", "'").replace("’", "'").replace("`", "'")
x = x.replace('... | [
"It",
"scrubs",
"the",
"garbled",
"from",
"its",
"stream",
"...",
"Or",
"it",
"gets",
"the",
"debugger",
"again",
"."
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/scrub.py#L10-L29 | [
"def",
"cleanup_text",
"(",
"text",
")",
":",
"x",
"=",
"\" \"",
".",
"join",
"(",
"map",
"(",
"lambda",
"s",
":",
"s",
".",
"strip",
"(",
")",
",",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
")",
")",
".",
"strip",
"(",
")",
"x",
"=",
"x",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | split_grafs | segment the raw text into paragraphs | pytextrank/pytextrank.py | def split_grafs (lines):
"""
segment the raw text into paragraphs
"""
graf = []
for line in lines:
line = line.strip()
if len(line) < 1:
if len(graf) > 0:
yield "\n".join(graf)
graf = []
else:
graf.append(line)
if... | def split_grafs (lines):
"""
segment the raw text into paragraphs
"""
graf = []
for line in lines:
line = line.strip()
if len(line) < 1:
if len(graf) > 0:
yield "\n".join(graf)
graf = []
else:
graf.append(line)
if... | [
"segment",
"the",
"raw",
"text",
"into",
"paragraphs"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L34-L51 | [
"def",
"split_grafs",
"(",
"lines",
")",
":",
"graf",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"len",
"(",
"line",
")",
"<",
"1",
":",
"if",
"len",
"(",
"graf",
")",
">",
"0",
":",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | filter_quotes | filter the quoted text out of a message | pytextrank/pytextrank.py | def filter_quotes (text, is_email=True):
"""
filter the quoted text out of a message
"""
global DEBUG
global PAT_FORWARD, PAT_REPLIED, PAT_UNSUBSC
if is_email:
text = filter(lambda x: x in string.printable, text)
if DEBUG:
print("text:", text)
# strip off q... | def filter_quotes (text, is_email=True):
"""
filter the quoted text out of a message
"""
global DEBUG
global PAT_FORWARD, PAT_REPLIED, PAT_UNSUBSC
if is_email:
text = filter(lambda x: x in string.printable, text)
if DEBUG:
print("text:", text)
# strip off q... | [
"filter",
"the",
"quoted",
"text",
"out",
"of",
"a",
"message"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L54-L94 | [
"def",
"filter_quotes",
"(",
"text",
",",
"is_email",
"=",
"True",
")",
":",
"global",
"DEBUG",
"global",
"PAT_FORWARD",
",",
"PAT_REPLIED",
",",
"PAT_UNSUBSC",
"if",
"is_email",
":",
"text",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
"in",
"string",
"... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | get_word_id | lookup/assign a unique identify for each word root | pytextrank/pytextrank.py | def get_word_id (root):
"""
lookup/assign a unique identify for each word root
"""
global UNIQ_WORDS
# in practice, this should use a microservice via some robust
# distributed cache, e.g., Redis, Cassandra, etc.
if root not in UNIQ_WORDS:
UNIQ_WORDS[root] = len(UNIQ_WORDS)
ret... | def get_word_id (root):
"""
lookup/assign a unique identify for each word root
"""
global UNIQ_WORDS
# in practice, this should use a microservice via some robust
# distributed cache, e.g., Redis, Cassandra, etc.
if root not in UNIQ_WORDS:
UNIQ_WORDS[root] = len(UNIQ_WORDS)
ret... | [
"lookup",
"/",
"assign",
"a",
"unique",
"identify",
"for",
"each",
"word",
"root"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L112-L123 | [
"def",
"get_word_id",
"(",
"root",
")",
":",
"global",
"UNIQ_WORDS",
"# in practice, this should use a microservice via some robust",
"# distributed cache, e.g., Redis, Cassandra, etc.",
"if",
"root",
"not",
"in",
"UNIQ_WORDS",
":",
"UNIQ_WORDS",
"[",
"root",
"]",
"=",
"len... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | fix_microsoft | fix special case for `c#`, `f#`, etc.; thanks Microsoft | pytextrank/pytextrank.py | def fix_microsoft (foo):
"""
fix special case for `c#`, `f#`, etc.; thanks Microsoft
"""
i = 0
bar = []
while i < len(foo):
text, lemma, pos, tag = foo[i]
if (text == "#") and (i > 0):
prev_tok = bar[-1]
prev_tok[0] += "#"
prev_tok[1] += "#"... | def fix_microsoft (foo):
"""
fix special case for `c#`, `f#`, etc.; thanks Microsoft
"""
i = 0
bar = []
while i < len(foo):
text, lemma, pos, tag = foo[i]
if (text == "#") and (i > 0):
prev_tok = bar[-1]
prev_tok[0] += "#"
prev_tok[1] += "#"... | [
"fix",
"special",
"case",
"for",
"c#",
"f#",
"etc",
".",
";",
"thanks",
"Microsoft"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L126-L148 | [
"def",
"fix_microsoft",
"(",
"foo",
")",
":",
"i",
"=",
"0",
"bar",
"=",
"[",
"]",
"while",
"i",
"<",
"len",
"(",
"foo",
")",
":",
"text",
",",
"lemma",
",",
"pos",
",",
"tag",
"=",
"foo",
"[",
"i",
"]",
"if",
"(",
"text",
"==",
"\"#\"",
")... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | fix_hypenation | fix hyphenation in the word list for a parsed sentence | pytextrank/pytextrank.py | def fix_hypenation (foo):
"""
fix hyphenation in the word list for a parsed sentence
"""
i = 0
bar = []
while i < len(foo):
text, lemma, pos, tag = foo[i]
if (tag == "HYPH") and (i > 0) and (i < len(foo) - 1):
prev_tok = bar[-1]
next_tok = foo[i + 1]
... | def fix_hypenation (foo):
"""
fix hyphenation in the word list for a parsed sentence
"""
i = 0
bar = []
while i < len(foo):
text, lemma, pos, tag = foo[i]
if (tag == "HYPH") and (i > 0) and (i < len(foo) - 1):
prev_tok = bar[-1]
next_tok = foo[i + 1]
... | [
"fix",
"hyphenation",
"in",
"the",
"word",
"list",
"for",
"a",
"parsed",
"sentence"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L151-L174 | [
"def",
"fix_hypenation",
"(",
"foo",
")",
":",
"i",
"=",
"0",
"bar",
"=",
"[",
"]",
"while",
"i",
"<",
"len",
"(",
"foo",
")",
":",
"text",
",",
"lemma",
",",
"pos",
",",
"tag",
"=",
"foo",
"[",
"i",
"]",
"if",
"(",
"tag",
"==",
"\"HYPH\"",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | parse_graf | CORE ALGORITHM: parse and markup sentences in the given paragraph | pytextrank/pytextrank.py | def parse_graf (doc_id, graf_text, base_idx, spacy_nlp=None):
"""
CORE ALGORITHM: parse and markup sentences in the given paragraph
"""
global DEBUG
global POS_KEEPS, POS_LEMMA, SPACY_NLP
# set up the spaCy NLP parser
if not spacy_nlp:
if not SPACY_NLP:
SPACY_NLP = spacy... | def parse_graf (doc_id, graf_text, base_idx, spacy_nlp=None):
"""
CORE ALGORITHM: parse and markup sentences in the given paragraph
"""
global DEBUG
global POS_KEEPS, POS_LEMMA, SPACY_NLP
# set up the spaCy NLP parser
if not spacy_nlp:
if not SPACY_NLP:
SPACY_NLP = spacy... | [
"CORE",
"ALGORITHM",
":",
"parse",
"and",
"markup",
"sentences",
"in",
"the",
"given",
"paragraph"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L177-L245 | [
"def",
"parse_graf",
"(",
"doc_id",
",",
"graf_text",
",",
"base_idx",
",",
"spacy_nlp",
"=",
"None",
")",
":",
"global",
"DEBUG",
"global",
"POS_KEEPS",
",",
"POS_LEMMA",
",",
"SPACY_NLP",
"# set up the spaCy NLP parser",
"if",
"not",
"spacy_nlp",
":",
"if",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | parse_doc | parse one document to prep for TextRank | pytextrank/pytextrank.py | def parse_doc (json_iter):
"""
parse one document to prep for TextRank
"""
global DEBUG
for meta in json_iter:
base_idx = 0
for graf_text in filter_quotes(meta["text"], is_email=False):
if DEBUG:
print("graf_text:", graf_text)
grafs, new_bas... | def parse_doc (json_iter):
"""
parse one document to prep for TextRank
"""
global DEBUG
for meta in json_iter:
base_idx = 0
for graf_text in filter_quotes(meta["text"], is_email=False):
if DEBUG:
print("graf_text:", graf_text)
grafs, new_bas... | [
"parse",
"one",
"document",
"to",
"prep",
"for",
"TextRank"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L248-L265 | [
"def",
"parse_doc",
"(",
"json_iter",
")",
":",
"global",
"DEBUG",
"for",
"meta",
"in",
"json_iter",
":",
"base_idx",
"=",
"0",
"for",
"graf_text",
"in",
"filter_quotes",
"(",
"meta",
"[",
"\"text\"",
"]",
",",
"is_email",
"=",
"False",
")",
":",
"if",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | get_tiles | generate word pairs for the TextRank graph | pytextrank/pytextrank.py | def get_tiles (graf, size=3):
"""
generate word pairs for the TextRank graph
"""
keeps = list(filter(lambda w: w.word_id > 0, graf))
keeps_len = len(keeps)
for i in iter(range(0, keeps_len - 1)):
w0 = keeps[i]
for j in iter(range(i + 1, min(keeps_len, i + 1 + size))):
... | def get_tiles (graf, size=3):
"""
generate word pairs for the TextRank graph
"""
keeps = list(filter(lambda w: w.word_id > 0, graf))
keeps_len = len(keeps)
for i in iter(range(0, keeps_len - 1)):
w0 = keeps[i]
for j in iter(range(i + 1, min(keeps_len, i + 1 + size))):
... | [
"generate",
"word",
"pairs",
"for",
"the",
"TextRank",
"graph"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L271-L285 | [
"def",
"get_tiles",
"(",
"graf",
",",
"size",
"=",
"3",
")",
":",
"keeps",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"w",
":",
"w",
".",
"word_id",
">",
"0",
",",
"graf",
")",
")",
"keeps_len",
"=",
"len",
"(",
"keeps",
")",
"for",
"i",
"in",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | build_graph | construct the TextRank graph from parsed paragraphs | pytextrank/pytextrank.py | def build_graph (json_iter):
"""
construct the TextRank graph from parsed paragraphs
"""
global DEBUG, WordNode
graph = nx.DiGraph()
for meta in json_iter:
if DEBUG:
print(meta["graf"])
for pair in get_tiles(map(WordNode._make, meta["graf"])):
if DEBUG:
... | def build_graph (json_iter):
"""
construct the TextRank graph from parsed paragraphs
"""
global DEBUG, WordNode
graph = nx.DiGraph()
for meta in json_iter:
if DEBUG:
print(meta["graf"])
for pair in get_tiles(map(WordNode._make, meta["graf"])):
if DEBUG:
... | [
"construct",
"the",
"TextRank",
"graph",
"from",
"parsed",
"paragraphs"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L288-L312 | [
"def",
"build_graph",
"(",
"json_iter",
")",
":",
"global",
"DEBUG",
",",
"WordNode",
"graph",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"for",
"meta",
"in",
"json_iter",
":",
"if",
"DEBUG",
":",
"print",
"(",
"meta",
"[",
"\"graf\"",
"]",
")",
"for",
"pa... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | write_dot | output the graph in Dot file format | pytextrank/pytextrank.py | def write_dot (graph, ranks, path="graph.dot"):
"""
output the graph in Dot file format
"""
dot = Digraph()
for node in graph.nodes():
dot.node(node, "%s %0.3f" % (node, ranks[node]))
for edge in graph.edges():
dot.edge(edge[0], edge[1], constraint="false")
with open(path,... | def write_dot (graph, ranks, path="graph.dot"):
"""
output the graph in Dot file format
"""
dot = Digraph()
for node in graph.nodes():
dot.node(node, "%s %0.3f" % (node, ranks[node]))
for edge in graph.edges():
dot.edge(edge[0], edge[1], constraint="false")
with open(path,... | [
"output",
"the",
"graph",
"in",
"Dot",
"file",
"format"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L315-L328 | [
"def",
"write_dot",
"(",
"graph",
",",
"ranks",
",",
"path",
"=",
"\"graph.dot\"",
")",
":",
"dot",
"=",
"Digraph",
"(",
")",
"for",
"node",
"in",
"graph",
".",
"nodes",
"(",
")",
":",
"dot",
".",
"node",
"(",
"node",
",",
"\"%s %0.3f\"",
"%",
"(",... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | render_ranks | render the TextRank graph for visual formats | pytextrank/pytextrank.py | def render_ranks (graph, ranks, dot_file="graph.dot"):
"""
render the TextRank graph for visual formats
"""
if dot_file:
write_dot(graph, ranks, path=dot_file) | def render_ranks (graph, ranks, dot_file="graph.dot"):
"""
render the TextRank graph for visual formats
"""
if dot_file:
write_dot(graph, ranks, path=dot_file) | [
"render",
"the",
"TextRank",
"graph",
"for",
"visual",
"formats"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L331-L336 | [
"def",
"render_ranks",
"(",
"graph",
",",
"ranks",
",",
"dot_file",
"=",
"\"graph.dot\"",
")",
":",
"if",
"dot_file",
":",
"write_dot",
"(",
"graph",
",",
"ranks",
",",
"path",
"=",
"dot_file",
")"
] | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | text_rank | run the TextRank algorithm | pytextrank/pytextrank.py | def text_rank (path):
"""
run the TextRank algorithm
"""
graph = build_graph(json_iter(path))
ranks = nx.pagerank(graph)
return graph, ranks | def text_rank (path):
"""
run the TextRank algorithm
"""
graph = build_graph(json_iter(path))
ranks = nx.pagerank(graph)
return graph, ranks | [
"run",
"the",
"TextRank",
"algorithm"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L345-L352 | [
"def",
"text_rank",
"(",
"path",
")",
":",
"graph",
"=",
"build_graph",
"(",
"json_iter",
"(",
"path",
")",
")",
"ranks",
"=",
"nx",
".",
"pagerank",
"(",
"graph",
")",
"return",
"graph",
",",
"ranks"
] | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | find_chunk | leverage noun phrase chunking | pytextrank/pytextrank.py | def find_chunk (phrase, np):
"""
leverage noun phrase chunking
"""
for i in iter(range(0, len(phrase))):
parsed_np = find_chunk_sub(phrase, np, i)
if parsed_np:
return parsed_np | def find_chunk (phrase, np):
"""
leverage noun phrase chunking
"""
for i in iter(range(0, len(phrase))):
parsed_np = find_chunk_sub(phrase, np, i)
if parsed_np:
return parsed_np | [
"leverage",
"noun",
"phrase",
"chunking"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L403-L411 | [
"def",
"find_chunk",
"(",
"phrase",
",",
"np",
")",
":",
"for",
"i",
"in",
"iter",
"(",
"range",
"(",
"0",
",",
"len",
"(",
"phrase",
")",
")",
")",
":",
"parsed_np",
"=",
"find_chunk_sub",
"(",
"phrase",
",",
"np",
",",
"i",
")",
"if",
"parsed_n... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | enumerate_chunks | iterate through the noun phrases | pytextrank/pytextrank.py | def enumerate_chunks (phrase, spacy_nlp):
"""
iterate through the noun phrases
"""
if (len(phrase) > 1):
found = False
text = " ".join([rl.text for rl in phrase])
doc = spacy_nlp(text.strip(), parse=True)
for np in doc.noun_chunks:
if np.text != text:
... | def enumerate_chunks (phrase, spacy_nlp):
"""
iterate through the noun phrases
"""
if (len(phrase) > 1):
found = False
text = " ".join([rl.text for rl in phrase])
doc = spacy_nlp(text.strip(), parse=True)
for np in doc.noun_chunks:
if np.text != text:
... | [
"iterate",
"through",
"the",
"noun",
"phrases"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L414-L429 | [
"def",
"enumerate_chunks",
"(",
"phrase",
",",
"spacy_nlp",
")",
":",
"if",
"(",
"len",
"(",
"phrase",
")",
">",
"1",
")",
":",
"found",
"=",
"False",
"text",
"=",
"\" \"",
".",
"join",
"(",
"[",
"rl",
".",
"text",
"for",
"rl",
"in",
"phrase",
"]... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | collect_keyword | iterator for collecting the single-word keyphrases | pytextrank/pytextrank.py | def collect_keyword (sent, ranks, stopwords):
"""
iterator for collecting the single-word keyphrases
"""
for w in sent:
if (w.word_id > 0) and (w.root in ranks) and (w.pos[0] in "NV") and (w.root not in stopwords):
rl = RankedLexeme(text=w.raw.lower(), rank=ranks[w.root]/2.0, ids=[w.... | def collect_keyword (sent, ranks, stopwords):
"""
iterator for collecting the single-word keyphrases
"""
for w in sent:
if (w.word_id > 0) and (w.root in ranks) and (w.pos[0] in "NV") and (w.root not in stopwords):
rl = RankedLexeme(text=w.raw.lower(), rank=ranks[w.root]/2.0, ids=[w.... | [
"iterator",
"for",
"collecting",
"the",
"single",
"-",
"word",
"keyphrases"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L432-L443 | [
"def",
"collect_keyword",
"(",
"sent",
",",
"ranks",
",",
"stopwords",
")",
":",
"for",
"w",
"in",
"sent",
":",
"if",
"(",
"w",
".",
"word_id",
">",
"0",
")",
"and",
"(",
"w",
".",
"root",
"in",
"ranks",
")",
"and",
"(",
"w",
".",
"pos",
"[",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | collect_entities | iterator for collecting the named-entities | pytextrank/pytextrank.py | def collect_entities (sent, ranks, stopwords, spacy_nlp):
"""
iterator for collecting the named-entities
"""
global DEBUG
sent_text = " ".join([w.raw for w in sent])
if DEBUG:
print("sent:", sent_text)
for ent in spacy_nlp(sent_text).ents:
if DEBUG:
print("NER:"... | def collect_entities (sent, ranks, stopwords, spacy_nlp):
"""
iterator for collecting the named-entities
"""
global DEBUG
sent_text = " ".join([w.raw for w in sent])
if DEBUG:
print("sent:", sent_text)
for ent in spacy_nlp(sent_text).ents:
if DEBUG:
print("NER:"... | [
"iterator",
"for",
"collecting",
"the",
"named",
"-",
"entities"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L470-L493 | [
"def",
"collect_entities",
"(",
"sent",
",",
"ranks",
",",
"stopwords",
",",
"spacy_nlp",
")",
":",
"global",
"DEBUG",
"sent_text",
"=",
"\" \"",
".",
"join",
"(",
"[",
"w",
".",
"raw",
"for",
"w",
"in",
"sent",
"]",
")",
"if",
"DEBUG",
":",
"print",... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | collect_phrases | iterator for collecting the noun phrases | pytextrank/pytextrank.py | def collect_phrases (sent, ranks, spacy_nlp):
"""
iterator for collecting the noun phrases
"""
tail = 0
last_idx = sent[0].idx - 1
phrase = []
while tail < len(sent):
w = sent[tail]
if (w.word_id > 0) and (w.root in ranks) and ((w.idx - last_idx) == 1):
# keep c... | def collect_phrases (sent, ranks, spacy_nlp):
"""
iterator for collecting the noun phrases
"""
tail = 0
last_idx = sent[0].idx - 1
phrase = []
while tail < len(sent):
w = sent[tail]
if (w.word_id > 0) and (w.root in ranks) and ((w.idx - last_idx) == 1):
# keep c... | [
"iterator",
"for",
"collecting",
"the",
"noun",
"phrases"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L496-L527 | [
"def",
"collect_phrases",
"(",
"sent",
",",
"ranks",
",",
"spacy_nlp",
")",
":",
"tail",
"=",
"0",
"last_idx",
"=",
"sent",
"[",
"0",
"]",
".",
"idx",
"-",
"1",
"phrase",
"=",
"[",
"]",
"while",
"tail",
"<",
"len",
"(",
"sent",
")",
":",
"w",
"... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | normalize_key_phrases | collect keyphrases, named entities, etc., while removing stop words | pytextrank/pytextrank.py | def normalize_key_phrases (path, ranks, stopwords=None, spacy_nlp=None, skip_ner=True):
"""
collect keyphrases, named entities, etc., while removing stop words
"""
global STOPWORDS, SPACY_NLP
# set up the stop words
if (type(stopwords) is list) or (type(stopwords) is set):
# explicit co... | def normalize_key_phrases (path, ranks, stopwords=None, spacy_nlp=None, skip_ner=True):
"""
collect keyphrases, named entities, etc., while removing stop words
"""
global STOPWORDS, SPACY_NLP
# set up the stop words
if (type(stopwords) is list) or (type(stopwords) is set):
# explicit co... | [
"collect",
"keyphrases",
"named",
"entities",
"etc",
".",
"while",
"removing",
"stop",
"words"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L539-L638 | [
"def",
"normalize_key_phrases",
"(",
"path",
",",
"ranks",
",",
"stopwords",
"=",
"None",
",",
"spacy_nlp",
"=",
"None",
",",
"skip_ner",
"=",
"True",
")",
":",
"global",
"STOPWORDS",
",",
"SPACY_NLP",
"# set up the stop words",
"if",
"(",
"type",
"(",
"stop... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | mh_digest | create a MinHash digest | pytextrank/pytextrank.py | def mh_digest (data):
"""
create a MinHash digest
"""
num_perm = 512
m = MinHash(num_perm)
for d in data:
m.update(d.encode('utf8'))
return m | def mh_digest (data):
"""
create a MinHash digest
"""
num_perm = 512
m = MinHash(num_perm)
for d in data:
m.update(d.encode('utf8'))
return m | [
"create",
"a",
"MinHash",
"digest"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L644-L654 | [
"def",
"mh_digest",
"(",
"data",
")",
":",
"num_perm",
"=",
"512",
"m",
"=",
"MinHash",
"(",
"num_perm",
")",
"for",
"d",
"in",
"data",
":",
"m",
".",
"update",
"(",
"d",
".",
"encode",
"(",
"'utf8'",
")",
")",
"return",
"m"
] | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | rank_kernel | return a list (matrix-ish) of the key phrases and their ranks | pytextrank/pytextrank.py | def rank_kernel (path):
"""
return a list (matrix-ish) of the key phrases and their ranks
"""
kernel = []
if isinstance(path, str):
path = json_iter(path)
for meta in path:
if not isinstance(meta, RankedLexeme):
rl = RankedLexeme(**meta)
else:
rl... | def rank_kernel (path):
"""
return a list (matrix-ish) of the key phrases and their ranks
"""
kernel = []
if isinstance(path, str):
path = json_iter(path)
for meta in path:
if not isinstance(meta, RankedLexeme):
rl = RankedLexeme(**meta)
else:
rl... | [
"return",
"a",
"list",
"(",
"matrix",
"-",
"ish",
")",
"of",
"the",
"key",
"phrases",
"and",
"their",
"ranks"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L657-L675 | [
"def",
"rank_kernel",
"(",
"path",
")",
":",
"kernel",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"path",
"=",
"json_iter",
"(",
"path",
")",
"for",
"meta",
"in",
"path",
":",
"if",
"not",
"isinstance",
"(",
"meta",
",",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | top_sentences | determine distance for each sentence | pytextrank/pytextrank.py | def top_sentences (kernel, path):
"""
determine distance for each sentence
"""
key_sent = {}
i = 0
if isinstance(path, str):
path = json_iter(path)
for meta in path:
graf = meta["graf"]
tagged_sent = [WordNode._make(x) for x in graf]
text = " ".join([w.raw f... | def top_sentences (kernel, path):
"""
determine distance for each sentence
"""
key_sent = {}
i = 0
if isinstance(path, str):
path = json_iter(path)
for meta in path:
graf = meta["graf"]
tagged_sent = [WordNode._make(x) for x in graf]
text = " ".join([w.raw f... | [
"determine",
"distance",
"for",
"each",
"sentence"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L678-L699 | [
"def",
"top_sentences",
"(",
"kernel",
",",
"path",
")",
":",
"key_sent",
"=",
"{",
"}",
"i",
"=",
"0",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"path",
"=",
"json_iter",
"(",
"path",
")",
"for",
"meta",
"in",
"path",
":",
"graf",
"... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | limit_keyphrases | iterator for the most significant key phrases | pytextrank/pytextrank.py | def limit_keyphrases (path, phrase_limit=20):
"""
iterator for the most significant key phrases
"""
rank_thresh = None
if isinstance(path, str):
lex = []
for meta in json_iter(path):
rl = RankedLexeme(**meta)
lex.append(rl)
else:
lex = path
... | def limit_keyphrases (path, phrase_limit=20):
"""
iterator for the most significant key phrases
"""
rank_thresh = None
if isinstance(path, str):
lex = []
for meta in json_iter(path):
rl = RankedLexeme(**meta)
lex.append(rl)
else:
lex = path
... | [
"iterator",
"for",
"the",
"most",
"significant",
"key",
"phrases"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L705-L733 | [
"def",
"limit_keyphrases",
"(",
"path",
",",
"phrase_limit",
"=",
"20",
")",
":",
"rank_thresh",
"=",
"None",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"lex",
"=",
"[",
"]",
"for",
"meta",
"in",
"json_iter",
"(",
"path",
")",
":",
"rl",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | limit_sentences | iterator for the most significant sentences, up to a specified limit | pytextrank/pytextrank.py | def limit_sentences (path, word_limit=100):
"""
iterator for the most significant sentences, up to a specified limit
"""
word_count = 0
if isinstance(path, str):
path = json_iter(path)
for meta in path:
if not isinstance(meta, SummarySent):
p = SummarySent(**meta)
... | def limit_sentences (path, word_limit=100):
"""
iterator for the most significant sentences, up to a specified limit
"""
word_count = 0
if isinstance(path, str):
path = json_iter(path)
for meta in path:
if not isinstance(meta, SummarySent):
p = SummarySent(**meta)
... | [
"iterator",
"for",
"the",
"most",
"significant",
"sentences",
"up",
"to",
"a",
"specified",
"limit"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L736-L758 | [
"def",
"limit_sentences",
"(",
"path",
",",
"word_limit",
"=",
"100",
")",
":",
"word_count",
"=",
"0",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"path",
"=",
"json_iter",
"(",
"path",
")",
"for",
"meta",
"in",
"path",
":",
"if",
"not",
... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | make_sentence | construct a sentence text, with proper spacing | pytextrank/pytextrank.py | def make_sentence (sent_text):
"""
construct a sentence text, with proper spacing
"""
lex = []
idx = 0
for word in sent_text:
if len(word) > 0:
if (idx > 0) and not (word[0] in ",.:;!?-\"'"):
lex.append(" ")
lex.append(word)
idx += 1
... | def make_sentence (sent_text):
"""
construct a sentence text, with proper spacing
"""
lex = []
idx = 0
for word in sent_text:
if len(word) > 0:
if (idx > 0) and not (word[0] in ",.:;!?-\"'"):
lex.append(" ")
lex.append(word)
idx += 1
... | [
"construct",
"a",
"sentence",
"text",
"with",
"proper",
"spacing"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L761-L777 | [
"def",
"make_sentence",
"(",
"sent_text",
")",
":",
"lex",
"=",
"[",
"]",
"idx",
"=",
"0",
"for",
"word",
"in",
"sent_text",
":",
"if",
"len",
"(",
"word",
")",
">",
"0",
":",
"if",
"(",
"idx",
">",
"0",
")",
"and",
"not",
"(",
"word",
"[",
"... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | json_iter | iterator for JSON-per-line in a file pattern | pytextrank/pytextrank.py | def json_iter (path):
"""
iterator for JSON-per-line in a file pattern
"""
with open(path, 'r') as f:
for line in f.readlines():
yield json.loads(line) | def json_iter (path):
"""
iterator for JSON-per-line in a file pattern
"""
with open(path, 'r') as f:
for line in f.readlines():
yield json.loads(line) | [
"iterator",
"for",
"JSON",
"-",
"per",
"-",
"line",
"in",
"a",
"file",
"pattern"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L783-L789 | [
"def",
"json_iter",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
"yield",
"json",
".",
"loads",
"(",
"line",
")"
] | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | pretty_print | pretty print a JSON object | pytextrank/pytextrank.py | def pretty_print (obj, indent=False):
"""
pretty print a JSON object
"""
if indent:
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '))
else:
return json.dumps(obj, sort_keys=True) | def pretty_print (obj, indent=False):
"""
pretty print a JSON object
"""
if indent:
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '))
else:
return json.dumps(obj, sort_keys=True) | [
"pretty",
"print",
"a",
"JSON",
"object"
] | DerwenAI/pytextrank | python | https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L792-L800 | [
"def",
"pretty_print",
"(",
"obj",
",",
"indent",
"=",
"False",
")",
":",
"if",
"indent",
":",
"return",
"json",
".",
"dumps",
"(",
"obj",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"2",
",",
"separators",
"=",
"(",
"','",
",",
"': '",
")",... | 181ea41375d29922eb96768cf6550e57a77a0c95 |
valid | Snapshot.get_object | Class method that will return a Snapshot object by ID. | digitalocean/Snapshot.py | def get_object(cls, api_token, snapshot_id):
"""
Class method that will return a Snapshot object by ID.
"""
snapshot = cls(token=api_token, id=snapshot_id)
snapshot.load()
return snapshot | def get_object(cls, api_token, snapshot_id):
"""
Class method that will return a Snapshot object by ID.
"""
snapshot = cls(token=api_token, id=snapshot_id)
snapshot.load()
return snapshot | [
"Class",
"method",
"that",
"will",
"return",
"a",
"Snapshot",
"object",
"by",
"ID",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Snapshot.py#L19-L25 | [
"def",
"get_object",
"(",
"cls",
",",
"api_token",
",",
"snapshot_id",
")",
":",
"snapshot",
"=",
"cls",
"(",
"token",
"=",
"api_token",
",",
"id",
"=",
"snapshot_id",
")",
"snapshot",
".",
"load",
"(",
")",
"return",
"snapshot"
] | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.load | Fetch data about tag | digitalocean/Tag.py | def load(self):
"""
Fetch data about tag
"""
tags = self.get_data("tags/%s" % self.name)
tag = tags['tag']
for attr in tag.keys():
setattr(self, attr, tag[attr])
return self | def load(self):
"""
Fetch data about tag
"""
tags = self.get_data("tags/%s" % self.name)
tag = tags['tag']
for attr in tag.keys():
setattr(self, attr, tag[attr])
return self | [
"Fetch",
"data",
"about",
"tag"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L18-L28 | [
"def",
"load",
"(",
"self",
")",
":",
"tags",
"=",
"self",
".",
"get_data",
"(",
"\"tags/%s\"",
"%",
"self",
".",
"name",
")",
"tag",
"=",
"tags",
"[",
"'tag'",
"]",
"for",
"attr",
"in",
"tag",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.create | Create the tag. | digitalocean/Tag.py | def create(self, **kwargs):
"""
Create the tag.
"""
for attr in kwargs.keys():
setattr(self, attr, kwargs[attr])
params = {"name": self.name}
output = self.get_data("tags", type="POST", params=params)
if output:
self.name = output['ta... | def create(self, **kwargs):
"""
Create the tag.
"""
for attr in kwargs.keys():
setattr(self, attr, kwargs[attr])
params = {"name": self.name}
output = self.get_data("tags", type="POST", params=params)
if output:
self.name = output['ta... | [
"Create",
"the",
"tag",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L31-L43 | [
"def",
"create",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"attr",
"in",
"kwargs",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"attr",
",",
"kwargs",
"[",
"attr",
"]",
")",
"params",
"=",
"{",
"\"name\"",
":",
"self",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.__get_resources | Method used to talk directly to the API (TAGs' Resources) | digitalocean/Tag.py | def __get_resources(self, resources, method):
""" Method used to talk directly to the API (TAGs' Resources) """
tagged = self.get_data(
'tags/%s/resources' % self.name, params={
"resources": resources
},
type=method,
)
return tagged | def __get_resources(self, resources, method):
""" Method used to talk directly to the API (TAGs' Resources) """
tagged = self.get_data(
'tags/%s/resources' % self.name, params={
"resources": resources
},
type=method,
)
return tagged | [
"Method",
"used",
"to",
"talk",
"directly",
"to",
"the",
"API",
"(",
"TAGs",
"Resources",
")"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L50-L59 | [
"def",
"__get_resources",
"(",
"self",
",",
"resources",
",",
"method",
")",
":",
"tagged",
"=",
"self",
".",
"get_data",
"(",
"'tags/%s/resources'",
"%",
"self",
".",
"name",
",",
"params",
"=",
"{",
"\"resources\"",
":",
"resources",
"}",
",",
"type",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.__extract_resources_from_droplets | Private method to extract from a value, the resources.
It will check the type of object in the array provided and build
the right structure for the API. | digitalocean/Tag.py | def __extract_resources_from_droplets(self, data):
"""
Private method to extract from a value, the resources.
It will check the type of object in the array provided and build
the right structure for the API.
"""
resources = []
if not isinstance(data, l... | def __extract_resources_from_droplets(self, data):
"""
Private method to extract from a value, the resources.
It will check the type of object in the array provided and build
the right structure for the API.
"""
resources = []
if not isinstance(data, l... | [
"Private",
"method",
"to",
"extract",
"from",
"a",
"value",
"the",
"resources",
".",
"It",
"will",
"check",
"the",
"type",
"of",
"object",
"in",
"the",
"array",
"provided",
"and",
"build",
"the",
"right",
"structure",
"for",
"the",
"API",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L82-L107 | [
"def",
"__extract_resources_from_droplets",
"(",
"self",
",",
"data",
")",
":",
"resources",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"return",
"data",
"for",
"a_droplet",
"in",
"data",
":",
"res",
"=",
"{",
"}",
"t... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.add_droplets | Add the Tag to a Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets. | digitalocean/Tag.py | def add_droplets(self, droplet):
"""
Add the Tag to a Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets.
"""
droplets = droplet
if not isinstance(droplets, list):
droplets = [... | def add_droplets(self, droplet):
"""
Add the Tag to a Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets.
"""
droplets = droplet
if not isinstance(droplets, list):
droplets = [... | [
"Add",
"the",
"Tag",
"to",
"a",
"Droplet",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L110-L126 | [
"def",
"add_droplets",
"(",
"self",
",",
"droplet",
")",
":",
"droplets",
"=",
"droplet",
"if",
"not",
"isinstance",
"(",
"droplets",
",",
"list",
")",
":",
"droplets",
"=",
"[",
"droplet",
"]",
"# Extracting data from the Droplet object",
"resources",
"=",
"s... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Tag.remove_droplets | Remove the Tag from the Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets. | digitalocean/Tag.py | def remove_droplets(self, droplet):
"""
Remove the Tag from the Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets.
"""
droplets = droplet
if not isinstance(droplets, list):
dr... | def remove_droplets(self, droplet):
"""
Remove the Tag from the Droplet.
Attributes accepted at creation time:
droplet: array of string or array of int, or array of Droplets.
"""
droplets = droplet
if not isinstance(droplets, list):
dr... | [
"Remove",
"the",
"Tag",
"from",
"the",
"Droplet",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Tag.py#L129-L145 | [
"def",
"remove_droplets",
"(",
"self",
",",
"droplet",
")",
":",
"droplets",
"=",
"droplet",
"if",
"not",
"isinstance",
"(",
"droplets",
",",
"list",
")",
":",
"droplets",
"=",
"[",
"droplet",
"]",
"# Extracting data from the Droplet object",
"resources",
"=",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Action.get_object | Class method that will return a Action object by ID. | digitalocean/Action.py | def get_object(cls, api_token, action_id):
"""
Class method that will return a Action object by ID.
"""
action = cls(token=api_token, id=action_id)
action.load_directly()
return action | def get_object(cls, api_token, action_id):
"""
Class method that will return a Action object by ID.
"""
action = cls(token=api_token, id=action_id)
action.load_directly()
return action | [
"Class",
"method",
"that",
"will",
"return",
"a",
"Action",
"object",
"by",
"ID",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Action.py#L25-L31 | [
"def",
"get_object",
"(",
"cls",
",",
"api_token",
",",
"action_id",
")",
":",
"action",
"=",
"cls",
"(",
"token",
"=",
"api_token",
",",
"id",
"=",
"action_id",
")",
"action",
".",
"load_directly",
"(",
")",
"return",
"action"
] | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Action.wait | Wait until the action is marked as completed or with an error.
It will return True in case of success, otherwise False.
Optional Args:
update_every_seconds - int : number of seconds to wait before
checking if the action is completed. | digitalocean/Action.py | def wait(self, update_every_seconds=1):
"""
Wait until the action is marked as completed or with an error.
It will return True in case of success, otherwise False.
Optional Args:
update_every_seconds - int : number of seconds to wait before
... | def wait(self, update_every_seconds=1):
"""
Wait until the action is marked as completed or with an error.
It will return True in case of success, otherwise False.
Optional Args:
update_every_seconds - int : number of seconds to wait before
... | [
"Wait",
"until",
"the",
"action",
"is",
"marked",
"as",
"completed",
"or",
"with",
"an",
"error",
".",
"It",
"will",
"return",
"True",
"in",
"case",
"of",
"success",
"otherwise",
"False",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Action.py#L54-L67 | [
"def",
"wait",
"(",
"self",
",",
"update_every_seconds",
"=",
"1",
")",
":",
"while",
"self",
".",
"status",
"==",
"u'in-progress'",
":",
"sleep",
"(",
"update_every_seconds",
")",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"status",
"==",
"u'... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.get_object | Class method that will return a Droplet object by ID.
Args:
api_token (str): token
droplet_id (int): droplet id | digitalocean/Droplet.py | def get_object(cls, api_token, droplet_id):
"""Class method that will return a Droplet object by ID.
Args:
api_token (str): token
droplet_id (int): droplet id
"""
droplet = cls(token=api_token, id=droplet_id)
droplet.load()
return droplet | def get_object(cls, api_token, droplet_id):
"""Class method that will return a Droplet object by ID.
Args:
api_token (str): token
droplet_id (int): droplet id
"""
droplet = cls(token=api_token, id=droplet_id)
droplet.load()
return droplet | [
"Class",
"method",
"that",
"will",
"return",
"a",
"Droplet",
"object",
"by",
"ID",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L102-L111 | [
"def",
"get_object",
"(",
"cls",
",",
"api_token",
",",
"droplet_id",
")",
":",
"droplet",
"=",
"cls",
"(",
"token",
"=",
"api_token",
",",
"id",
"=",
"droplet_id",
")",
"droplet",
".",
"load",
"(",
")",
"return",
"droplet"
] | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.get_data | Customized version of get_data to perform __check_actions_in_data | digitalocean/Droplet.py | def get_data(self, *args, **kwargs):
"""
Customized version of get_data to perform __check_actions_in_data
"""
data = super(Droplet, self).get_data(*args, **kwargs)
if "type" in kwargs:
if kwargs["type"] == POST:
self.__check_actions_in_data(data)
... | def get_data(self, *args, **kwargs):
"""
Customized version of get_data to perform __check_actions_in_data
"""
data = super(Droplet, self).get_data(*args, **kwargs)
if "type" in kwargs:
if kwargs["type"] == POST:
self.__check_actions_in_data(data)
... | [
"Customized",
"version",
"of",
"get_data",
"to",
"perform",
"__check_actions_in_data"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L158-L166 | [
"def",
"get_data",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"Droplet",
",",
"self",
")",
".",
"get_data",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"\"type\"",
"in",
"kwargs",
":",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.load | Fetch data about droplet - use this instead of get_data() | digitalocean/Droplet.py | def load(self):
"""
Fetch data about droplet - use this instead of get_data()
"""
droplets = self.get_data("droplets/%s" % self.id)
droplet = droplets['droplet']
for attr in droplet.keys():
setattr(self, attr, droplet[attr])
for net in self.networ... | def load(self):
"""
Fetch data about droplet - use this instead of get_data()
"""
droplets = self.get_data("droplets/%s" % self.id)
droplet = droplets['droplet']
for attr in droplet.keys():
setattr(self, attr, droplet[attr])
for net in self.networ... | [
"Fetch",
"data",
"about",
"droplet",
"-",
"use",
"this",
"instead",
"of",
"get_data",
"()"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L168-L202 | [
"def",
"load",
"(",
"self",
")",
":",
"droplets",
"=",
"self",
".",
"get_data",
"(",
"\"droplets/%s\"",
"%",
"self",
".",
"id",
")",
"droplet",
"=",
"droplets",
"[",
"'droplet'",
"]",
"for",
"attr",
"in",
"droplet",
".",
"keys",
"(",
")",
":",
"setat... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet._perform_action | Perform a droplet action.
Args:
params (dict): parameters of the action
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Returns dict or Action | digitalocean/Droplet.py | def _perform_action(self, params, return_dict=True):
"""
Perform a droplet action.
Args:
params (dict): parameters of the action
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Act... | def _perform_action(self, params, return_dict=True):
"""
Perform a droplet action.
Args:
params (dict): parameters of the action
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Act... | [
"Perform",
"a",
"droplet",
"action",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L204-L230 | [
"def",
"_perform_action",
"(",
"self",
",",
"params",
",",
"return_dict",
"=",
"True",
")",
":",
"action",
"=",
"self",
".",
"get_data",
"(",
"\"droplets/%s/actions/\"",
"%",
"self",
".",
"id",
",",
"type",
"=",
"POST",
",",
"params",
"=",
"params",
")",... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.resize | Resize the droplet to a new size slug.
https://developers.digitalocean.com/documentation/v2/#resize-a-droplet
Args:
new_size_slug (str): name of new size
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise retu... | digitalocean/Droplet.py | def resize(self, new_size_slug, return_dict=True, disk=True):
"""Resize the droplet to a new size slug.
https://developers.digitalocean.com/documentation/v2/#resize-a-droplet
Args:
new_size_slug (str): name of new size
Optional Args:
return_dict (bool): Return a... | def resize(self, new_size_slug, return_dict=True, disk=True):
"""Resize the droplet to a new size slug.
https://developers.digitalocean.com/documentation/v2/#resize-a-droplet
Args:
new_size_slug (str): name of new size
Optional Args:
return_dict (bool): Return a... | [
"Resize",
"the",
"droplet",
"to",
"a",
"new",
"size",
"slug",
".",
"https",
":",
"//",
"developers",
".",
"digitalocean",
".",
"com",
"/",
"documentation",
"/",
"v2",
"/",
"#resize",
"-",
"a",
"-",
"droplet"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L304-L321 | [
"def",
"resize",
"(",
"self",
",",
"new_size_slug",
",",
"return_dict",
"=",
"True",
",",
"disk",
"=",
"True",
")",
":",
"options",
"=",
"{",
"\"type\"",
":",
"\"resize\"",
",",
"\"size\"",
":",
"new_size_slug",
"}",
"if",
"disk",
":",
"options",
"[",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.take_snapshot | Take a snapshot!
Args:
snapshot_name (str): name of snapshot
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
power_off (bool): Before taking the snapshot the droplet will be
turned off... | digitalocean/Droplet.py | def take_snapshot(self, snapshot_name, return_dict=True, power_off=False):
"""Take a snapshot!
Args:
snapshot_name (str): name of snapshot
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
power... | def take_snapshot(self, snapshot_name, return_dict=True, power_off=False):
"""Take a snapshot!
Args:
snapshot_name (str): name of snapshot
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
power... | [
"Take",
"a",
"snapshot!"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L323-L346 | [
"def",
"take_snapshot",
"(",
"self",
",",
"snapshot_name",
",",
"return_dict",
"=",
"True",
",",
"power_off",
"=",
"False",
")",
":",
"if",
"power_off",
"is",
"True",
"and",
"self",
".",
"status",
"!=",
"\"off\"",
":",
"action",
"=",
"self",
".",
"power_... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.rebuild | Restore the droplet to an image ( snapshot or backup )
Args:
image_id (int): id of image
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Returns dict or Action | digitalocean/Droplet.py | def rebuild(self, image_id=None, return_dict=True):
"""Restore the droplet to an image ( snapshot or backup )
Args:
image_id (int): id of image
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Ret... | def rebuild(self, image_id=None, return_dict=True):
"""Restore the droplet to an image ( snapshot or backup )
Args:
image_id (int): id of image
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Ret... | [
"Restore",
"the",
"droplet",
"to",
"an",
"image",
"(",
"snapshot",
"or",
"backup",
")"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L365-L383 | [
"def",
"rebuild",
"(",
"self",
",",
"image_id",
"=",
"None",
",",
"return_dict",
"=",
"True",
")",
":",
"if",
"not",
"image_id",
":",
"image_id",
"=",
"self",
".",
"image",
"[",
"'id'",
"]",
"return",
"self",
".",
"_perform_action",
"(",
"{",
"\"type\"... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.change_kernel | Change the kernel to a new one
Args:
kernel : instance of digitalocean.Kernel.Kernel
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Returns dict or Action | digitalocean/Droplet.py | def change_kernel(self, kernel, return_dict=True):
"""Change the kernel to a new one
Args:
kernel : instance of digitalocean.Kernel.Kernel
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Returns ... | def change_kernel(self, kernel, return_dict=True):
"""Change the kernel to a new one
Args:
kernel : instance of digitalocean.Kernel.Kernel
Optional Args:
return_dict (bool): Return a dict when True (default),
otherwise return an Action.
Returns ... | [
"Change",
"the",
"kernel",
"to",
"a",
"new",
"one"
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L461-L479 | [
"def",
"change_kernel",
"(",
"self",
",",
"kernel",
",",
"return_dict",
"=",
"True",
")",
":",
"if",
"type",
"(",
"kernel",
")",
"!=",
"Kernel",
":",
"raise",
"BadKernelObject",
"(",
"\"Use Kernel object\"",
")",
"return",
"self",
".",
"_perform_action",
"("... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.__get_ssh_keys_id_or_fingerprint | Check and return a list of SSH key IDs or fingerprints according
to DigitalOcean's API. This method is used to check and create a
droplet with the correct SSH keys. | digitalocean/Droplet.py | def __get_ssh_keys_id_or_fingerprint(ssh_keys, token, name):
"""
Check and return a list of SSH key IDs or fingerprints according
to DigitalOcean's API. This method is used to check and create a
droplet with the correct SSH keys.
"""
ssh_keys_id = list()
... | def __get_ssh_keys_id_or_fingerprint(ssh_keys, token, name):
"""
Check and return a list of SSH key IDs or fingerprints according
to DigitalOcean's API. This method is used to check and create a
droplet with the correct SSH keys.
"""
ssh_keys_id = list()
... | [
"Check",
"and",
"return",
"a",
"list",
"of",
"SSH",
"key",
"IDs",
"or",
"fingerprints",
"according",
"to",
"DigitalOcean",
"s",
"API",
".",
"This",
"method",
"is",
"used",
"to",
"check",
"and",
"create",
"a",
"droplet",
"with",
"the",
"correct",
"SSH",
"... | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L482-L527 | [
"def",
"__get_ssh_keys_id_or_fingerprint",
"(",
"ssh_keys",
",",
"token",
",",
"name",
")",
":",
"ssh_keys_id",
"=",
"list",
"(",
")",
"for",
"ssh_key",
"in",
"ssh_keys",
":",
"if",
"type",
"(",
"ssh_key",
")",
"in",
"[",
"int",
",",
"type",
"(",
"2",
... | d0221b57856fb1e131cafecf99d826f7b07a947c |
valid | Droplet.create | Create the droplet with object properties.
Note: Every argument and parameter given to this method will be
assigned to the object. | digitalocean/Droplet.py | def create(self, *args, **kwargs):
"""
Create the droplet with object properties.
Note: Every argument and parameter given to this method will be
assigned to the object.
"""
for attr in kwargs.keys():
setattr(self, attr, kwargs[attr])
# P... | def create(self, *args, **kwargs):
"""
Create the droplet with object properties.
Note: Every argument and parameter given to this method will be
assigned to the object.
"""
for attr in kwargs.keys():
setattr(self, attr, kwargs[attr])
# P... | [
"Create",
"the",
"droplet",
"with",
"object",
"properties",
"."
] | koalalorenzo/python-digitalocean | python | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L529-L570 | [
"def",
"create",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"attr",
"in",
"kwargs",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"attr",
",",
"kwargs",
"[",
"attr",
"]",
")",
"# Provide backwards compatibilit... | d0221b57856fb1e131cafecf99d826f7b07a947c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.