MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 1 callersFunctionget_data
>>> get_data([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]]) [[20.0, 23.0, 22.0], [60.0, 90.0, 50.0], [2012.0, 2015.0, 2011.0]]
other/scoring_algorithm.py:27
↓ 1 callersFunctionget_dataset
- label_dir <type: str>: Path to label include annotation of images - img_dir <type: str>: Path to folder contain images Return <type: li
computer_vision/mosaic_augmentation.py:57
↓ 1 callersFunctionget_dataset
- label_dir <type: str>: Path to label include annotation of images - img_dir <type: str>: Path to folder contain images Return <type: li
computer_vision/flip_augmentation.py:45
↓ 1 callersFunctionget_descriptors
Calculate all Haralick descriptors for a sequence of different co-occurrence matrices, given input masks and coordinates. Example:
computer_vision/haralick_descriptors.py:313
↓ 1 callersMethodget_dict
(self)
sorts/external_sort.py:66
↓ 1 callersFunctionget_digit_power
Get digit^power using memoization (DP optimization).
dynamic_programming/narcissistic_number.py:65
↓ 1 callersFunctionget_digits
Computes the sorted sequence of digits of the cube of num. >>> get_digits(3) '27' >>> get_digits(99) '027999' >>> get_digits
project_euler/problem_062/sol1.py:47
↓ 1 callersFunctionget_distance
Get the distance between a car (at index car_index) and the next car >>> get_distance([6, -1, 6, -1, 6], 2) 1 >>> get_distance([2, -1
cellular_automata/nagel_schrekenberg.py:60
↓ 1 callersFunctionget_distance
Return the relative distance (= step/max_step) after which the complex number constituted by this x-y-pair diverges. Members of the Mandelb
fractals/mandelbrot.py:23
↓ 1 callersFunctionget_distances
Calculate all Euclidean distances between a selected base descriptor and all other Haralick descriptors The resulting comparison is retur
computer_vision/haralick_descriptors.py:352
↓ 1 callersFunctionget_distinct_edge
Return Distinct edges from edge array of multiple graphs >>> sorted(get_distinct_edge(edge_array)) ['a', 'b', 'c', 'd', 'e', 'f', 'g',
graphs/frequent_pattern_graph_miner.py:27
↓ 1 callersFunctionget_distrib
>>> get_distrib(None) namedtuple("CoinsDistribResult", "0 2")
data_structures/binary_tree/distribute_coins.py:106
↓ 1 callersFunctionget_divisors
input: positive integer 'n' >= 1 returns all divisors of n (inclusive 1 and 'n') >>> get_divisors(8) [1, 2, 4, 8] >>> get_diviso
maths/primelib.py:651
↓ 1 callersFunctionget_domain_name
This function get the main domain name >>> get_domain_name("https://a.b.c.d/e/f?g=h,i=j#k") 'c.d' >>> get_domain_name("Not a URL!")
web_programming/emails_from_url.py:47
↓ 1 callersFunctionget_edges
Return a set of couples that represents all of the edges. @input: graph (graph stored in an adjacency list where each vertex is r
graphs/matching_min_vertex_cover.py:39
↓ 1 callersFunctionget_english_count
(message: str)
strings/detecting_english_programmatically.py:19
↓ 1 callersMethodget_file_handles
(self, filenames, buffer_size)
sorts/external_sort.py:100
↓ 1 callersFunctionget_files_url
Return the pull request number which triggered this action.
scripts/validate_solutions.py:51
↓ 1 callersFunctionget_filter_points
Calculate the filter points and frequencies for mel frequency filters. Args: sample_rate: The sample rate of the audio. freq
machine_learning/mfcc.py:383
↓ 1 callersFunctionget_filters
Generate filters for audio processing. Args: filter_points: A list of filter points. ftt_size: The size of the FFT. Ret
machine_learning/mfcc.py:351
↓ 1 callersFunctionget_forbes_real_time_billionaires
Get the top 10 real-time billionaires using Forbes API. Returns: List of top 10 realtime billionaires data.
web_programming/get_top_billionaires.py:61
↓ 1 callersFunctionget_frequency_order
Get the frequency order of the letters in the given string >>> get_frequency_order('Hello World') 'LOWDRHEZQXJKVBPYGFMUCSNIAT' >>> ge
strings/frequency_finder.py:51
↓ 1 callersFunctionget_frequency_table
Returns Frequency Table
graphs/frequent_pattern_graph_miner.py:53
↓ 1 callersFunctionget_gauss_kernel
(kernel_size: int, spatial_variance: float)
digital_image_processing/filters/bilateral_filter.py:32
↓ 1 callersFunctionget_gifs
Get a list of URLs of GIFs based on a given query..
web_programming/giphy.py:16
↓ 1 callersFunctionget_greatest_common_divisor
get gcd of n numbers: >>> get_greatest_common_divisor(18, 45) 9 >>> get_greatest_common_divisor(23, 37) 1 >>> get_greatest_co
maths/gcd_of_n_numbers.py:63
↓ 1 callersFunctionget_hackernews_story
(story_id: str)
web_programming/get_top_hn_posts.py:13
↓ 1 callersMethodget_height
(self)
data_structures/binary_tree/avl_tree.py:59
↓ 1 callersMethodget_height
(self)
data_structures/binary_tree/avl_tree.py:282
↓ 1 callersFunctionget_image
Function to generate the image of the Mandelbrot set. Two types of coordinates are used: image-coordinates that refer to the pixels and fig
fractals/mandelbrot.py:86
↓ 1 callersFunctionget_imdb_top_250_movies
(url: str = "")
web_programming/get_imdb_top_250_movies_csv.py:17
↓ 1 callersFunctionget_initial_centroids
Randomly choose k data points as initial centroids
machine_learning/k_means_clust.py:62
↓ 1 callersFunctionget_initial_point
(a: float)
maths/numerical_analysis/square_root.py:12
↓ 1 callersFunctionget_ip_geolocation
(ip_address: str)
web_programming/get_ip_geolocation.py:12
↓ 1 callersMethodget_json
Return a dict of user information
web_programming/instagram_crawler.py:48
↓ 1 callersMethodget_left_child_idx
(self, idx)
data_structures/heap/min_heap.py:45
↓ 1 callersFunctionget_left_most
(root: MyNode)
data_structures/binary_tree/avl_tree.py:189
↓ 1 callersFunctionget_letter_count
(message: str)
strings/frequency_finder.py:38
↓ 1 callersMethodget_max
We go deep on the right branch >>> BinarySearchTree().insert(10, 20, 30, 40, 50).get_max() 50 >>> BinarySearchTree()
data_structures/binary_tree/binary_search_tree.py:234
↓ 1 callersMethodget_min
Returns the smallest element in this tree. This method is guaranteed to run in O(log(n)) time.
data_structures/binary_tree/red_black_tree.py:412
↓ 1 callersFunctionget_multiplier
Function returns the multiplier value associated with the color. Function takes color as input and returns multiplier value >>> get_mult
electronics/resistor_color_code.py:161
↓ 1 callersMethodget_negative
Returns a dictionary with only the elements of this enum that has a negative value @example >>> from itertools import
conversions/prefix_conversions_string.py:71
↓ 1 callersMethodget_neighbours
Return the neighbours of cell
machine_learning/astar.py:61
↓ 1 callersMethodget_next
Get next index in O(1)
data_structures/binary_tree/maximum_fenwick_tree.py:54
↓ 1 callersMethodget_node
(self, item: DataType)
data_structures/linked_list/doubly_linked_list_two.py:133
↓ 1 callersFunctionget_nodes
Returns nodes format nodes={bitcode:edges that represent the bitcode} >>> get_nodes([['ab', 5, '11111'], ['ac', 5, '11111'], ['df', 5,
graphs/frequent_pattern_graph_miner.py:74
↓ 1 callersMethodget_nodes
(self)
graphs/markov_chain.py:27
↓ 1 callersFunctionget_nodes_from_right_to_left
Returns a list of nodes value from a particular level: Right to left direction of the binary tree. >>> list(get_nodes_from_right_to_le
data_structures/binary_tree/binary_tree_traversals.py:141
↓ 1 callersMethodget_number_blocks
(self, filename, block_size)
sorts/external_sort.py:124
↓ 1 callersFunctionget_opponent
>>> get_opponent(generate_table('marvin')[0], 'M') 'T'
ciphers/porta_cipher.py:74
↓ 1 callersFunctionget_pascal_triangle_unique_coefficients
Returns the unique coefficients of a Pascal's triangle of depth "depth". The coefficients of this triangle are symmetric. A further improvem
project_euler/problem_203/sol1.py:34
↓ 1 callersFunctionget_position
>>> get_position(generate_table('marvin')[0], 'M') (0, 12)
ciphers/porta_cipher.py:63
↓ 1 callersMethodget_positive
Returns a dictionary with only the elements of this enum that has a positive value >>> from itertools import islice >
conversions/prefix_conversions_string.py:56
↓ 1 callersFunctionget_prime_numbers
input: positive integer 'N' > 2 returns a list of prime numbers from 2 up to N (inclusive) This function is more efficient as function 's
maths/primelib.py:141
↓ 1 callersMethodget_right_child_idx
(self, idx)
data_structures/heap/min_heap.py:48
↓ 1 callersFunctionget_set_bits_count_using_brian_kernighans_algorithm
Count the number of set bits in a 32 bit integer >>> get_set_bits_count_using_brian_kernighans_algorithm(25) 3 >>> get_set_bits_count
bit_manipulation/count_number_of_one_bits.py:4
↓ 1 callersFunctionget_set_bits_count_using_modulo_operator
Count the number of set bits in a 32 bit integer >>> get_set_bits_count_using_modulo_operator(25) 3 >>> get_set_bits_count_using_modu
bit_manipulation/count_number_of_one_bits.py:33
↓ 1 callersFunctionget_significant_digits
Function returns the digit associated with the color. Function takes a list containing colors as input and returns digits as string >>>
electronics/resistor_color_code.py:138
↓ 1 callersFunctionget_slice
(img: np.ndarray, x: int, y: int, kernel_size: int)
digital_image_processing/filters/bilateral_filter.py:27
↓ 1 callersFunctionget_squarefrees
Calculates the squarefree numbers inside unique_coefficients. Based on the definition of a non-squarefree number, then any non-squarefree
project_euler/problem_203/sol1.py:63
↓ 1 callersFunctionget_squares
>>> get_squares(0) [] >>> get_squares(1) [0] >>> get_squares(2) [0, 1] >>> get_squares(3) [0, 1, 4] >>> get_squar
project_euler/problem_009/sol4.py:20
↓ 1 callersFunctionget_sub_domain_name
>>> get_sub_domain_name("https://a.b.c.d/e/f?g=h,i=j#k") 'a.b.c.d' >>> get_sub_domain_name("Not a URL!") ''
web_programming/emails_from_url.py:60
↓ 1 callersFunctionget_subreddit_data
subreddit : Subreddit to query limit : Number of posts to fetch age : ["new", "top", "hot"] wanted_data : Get only the required data
web_programming/reddit.py:25
↓ 1 callersMethodget_successors
Returns a list of successors (both in the grid and free spaces)
graphs/greedy_best_first.py:147
↓ 1 callersFunctionget_support
Returns support >>> get_support({5: {'11111': ['ab', 'ac', 'df', 'bd', 'bc']}, ... 4: {'11101': ['ef', 'eg', 'de', 'fg'],
graphs/frequent_pattern_graph_miner.py:99
↓ 1 callersMethodget_surrounding_prey
Returns all the prey entities around (N, S, E, W) a predator entity. Subtly different to the `move_and_reproduce`. >>> wt =
cellular_automata/wa_tor.py:215
↓ 1 callersFunctionget_temperature_coeffecient
Function returns the temperature coeffecient value associated with the color. Function takes color as input and returns temperature coeffecie
electronics/resistor_color_code.py:201
↓ 1 callersFunctionget_text_from_blocks
( block_ints: list[int], message_length: int, block_size: int = DEFAULT_BLOCK_SIZE )
ciphers/rsa_cipher.py:24
↓ 1 callersFunctionget_tolerance
Function returns the tolerance value associated with the color. Function takes color as input and returns tolerance value. >>> get_toler
electronics/resistor_color_code.py:181
↓ 1 callersMethodget_top
Returns top item tuple (Calculated value, item) from heap if present
data_structures/heap/heap_generic.py:116
↓ 1 callersFunctionget_totients
Calculates a list of totients from 0 to max_one exclusive, using the definition of Euler's product formula. >>> get_totients(5) [0,
project_euler/problem_070/sol1.py:37
↓ 1 callersFunctionget_valid_pos
Find all the valid positions a knight can move to from the current position. >>> get_valid_pos((1, 3), 4) [(2, 1), (0, 1), (3, 2)]
backtracking/knight_tour.py:6
↓ 1 callersMethodget_value
(self, key)
data_structures/heap/min_heap.py:51
↓ 1 callersMethodget_value
(self)
other/greedy.py:10
↓ 1 callersMethodget_vertices
Returns all vertices in the graph
graphs/minimum_spanning_tree_boruvka.py:78
↓ 1 callersFunctionget_word_pattern
Returns numerical pattern of character appearances in given word >>> get_word_pattern("") '' >>> get_word_pattern(" ") '0' >>
strings/word_patterns.py:1
↓ 1 callersMethodget_x
Get parent X coordinate for destination X :param x: Destination X coordinate :return: Parent X coordinate based on `x ratio`
digital_image_processing/resize/resize.py:35
↓ 1 callersMethodget_y
Get parent Y coordinate for destination Y :param y: Destination X coordinate :return: Parent X coordinate based on `y ratio`
digital_image_processing/resize/resize.py:48
↓ 1 callersFunctiongnome_sort
Pure implementation of the gnome sort algorithm in Python Take some mutable ordered collection with heterogeneous comparable items inside as
sorts/gnome_sort.py:16
↓ 1 callersFunctiongo_next
Check if we have to move forward to the next characters or not
strings/z_function.py:52
↓ 1 callersMethodgradient
Calculate the negative gradient (pseudo-residuals) for logistic loss. Parameters: - target (np.ndarray): The target values.
machine_learning/gradient_boosting_classifier.py:83
↓ 1 callersMethodgradient
Reverse accumulation of partial derivatives to calculate gradients of target variable with respect to source variable. Args:
machine_learning/automatic_differentiation.py:247
↓ 1 callersFunctiongray_code_sequence_string
Will output the n-bit grey sequence as a string of bits >>> gray_code_sequence_string(2) ['00', '01', '11', '10'] >>> gray_code
bit_manipulation/gray_code_sequence.py:50
↓ 1 callersFunctiongray_to_binary
Return binary image from gray image >>> gray_to_binary(np.array([[127, 255, 0]])) array([[False, True, False]]) >>> gray_to_bi
digital_image_processing/morphological_operations/erosion_operation.py:24
↓ 1 callersFunctiongray_to_binary
Return binary image from gray image >>> gray_to_binary(np.array([[127, 255, 0]])) array([[False, True, False]]) >>> gray_to_bina
digital_image_processing/morphological_operations/dilation_operation.py:23
↓ 1 callersFunctiongrayscale
Uses luminance weights to transform RGB channel to greyscale, by taking the dot product between the channel and the weights. Example:
computer_vision/haralick_descriptors.py:74
↓ 1 callersFunctiongreatest_common_divisor
Euclid's Lemma : d divides a and b, if and only if d divides a-b and b Euclid's Algorithm >>> greatest_common_divisor(7,5) 1 N
maths/modular_division.py:129
↓ 1 callersFunctiongreedy_min_vertex_cover
Greedy APX Algorithm for min Vertex Cover @input: graph (graph stored in an adjacency list where each vertex is represented with
graphs/greedy_min_vertex_cover.py:12
↓ 1 callersFunctionguess_the_number
The `guess_the_number` function that guess the number by some operations and using inner functions >>> guess_the_number(10, 1000, 17)
other/guess_the_number_search.py:79
↓ 1 callersFunctionhackernews_top_stories
Get the top max_stories posts from HackerNews - https://news.ycombinator.com/
web_programming/get_top_hn_posts.py:18
↓ 1 callersFunctionhackernews_top_stories_as_markdown
(max_stories: int = 10)
web_programming/get_top_hn_posts.py:27
↓ 1 callersFunctionhamming
This function creates an ordered list of n length as requested, and afterwards returns the last value of the list. It must be given a positiv
maths/special_numbers/hamming_numbers.py:8
↓ 1 callersFunctionharalick_descriptors
Calculates all 8 Haralick descriptors based on co-occurrence input matrix. All descriptors are as follows: Maximum probability, Inverse Differ
computer_vision/haralick_descriptors.py:256
↓ 1 callersFunctionharmonic_series
Pure Python implementation of Harmonic Series algorithm :param n_term: The last (nth) term of Harmonic Series :return: The Harmonic Series st
maths/series/harmonic_series.py:15
↓ 1 callersFunctionhas_same_digits
Return True if num1 and num2 have the same frequency of every digit, False otherwise. >>> has_same_digits(123456789, 987654321) True
project_euler/problem_070/sol1.py:58
↓ 1 callersFunctionhaversine_distance
Calculate great circle distance between two points in a sphere, given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formul
geodesy/haversine_distance.py:8
↓ 1 callersFunctionheap_sort
A pure Python implementation of the heap sort algorithm :param collection: a mutable ordered collection of heterogeneous comparable items
sorts/heap_sort.py:34
↓ 1 callersFunctionheap_sort
>>> heap_sort([4, 2, 6, 8, 1, 7, 8, 22, 14, 56, 27, 79, 23, 45, 14, 12]) [1, 2, 4, 6, 7, 8, 8, 12, 14, 14, 22, 23, 27, 45, 56, 79] >>> he
sorts/intro_sort.py:59
↓ 1 callersMethodheap_sort
(self)
data_structures/heap/heap.py:232
↓ 1 callersFunctionheaps
Pure python implementation of the Heap's algorithm (recursive version), returning all permutations of a list. >>> heaps([]) [()]
divide_and_conquer/heaps_algorithm.py:10
← previousnext →1,301–1,400 of 3,909, ranked by callers