MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

Functiontest_rectangle_with_collinear_points
Test rectangle with points on the edges (collinear with vertices).
geometry/tests/test_graham_scan.py:152
Methodtest_rectangle_with_interior_point
Test rectangle with interior point - interior point excluded.
geometry/tests/test_jarvis_march.py:53
Functiontest_rectangle_with_interior_points
Test rectangle with points inside.
geometry/tests/test_graham_scan.py:94
Methodtest_remove
(self)
data_structures/binary_tree/binary_search_tree_recursive.py:378
Methodtest_remove_2
(self)
data_structures/binary_tree/binary_search_tree_recursive.py:468
Methodtest_remove_edge
(self)
graphs/graph_adjacency_matrix.py:467
Methodtest_remove_edge
(self)
graphs/graph_adjacency_list.py:455
Methodtest_remove_edge_exception_check
(self)
graphs/graph_adjacency_matrix.py:564
Methodtest_remove_edge_exception_check
(self)
graphs/graph_adjacency_list.py:552
Methodtest_remove_vertex_exception_check
(self)
graphs/graph_adjacency_matrix.py:535
Methodtest_remove_vertex_exception_check
(self)
graphs/graph_adjacency_list.py:523
Methodtest_remove_vertices
(self)
graphs/graph_adjacency_matrix.py:351
Methodtest_remove_vertices
(self)
graphs/graph_adjacency_list.py:339
Functiontest_scalar_multiply
()
matrix/tests/test_matrix_operation.py:97
Methodtest_schur_complement
(self)
linear_algebra/src/schur_complement.py:62
Methodtest_search
(self)
data_structures/binary_tree/binary_search_tree_recursive.py:366
Methodtest_search_empty_pattern
Test searching for an empty pattern.
data_structures/suffix_tree/tests/test_suffix_tree.py:38
Methodtest_search_existing_patterns
Test searching for patterns that exist in the suffix tree.
data_structures/suffix_tree/tests/test_suffix_tree.py:20
Methodtest_search_full_text
Test searching for the full text.
data_structures/suffix_tree/tests/test_suffix_tree.py:42
Methodtest_search_non_existing_patterns
Test searching for patterns that do not exist in the suffix tree.
data_structures/suffix_tree/tests/test_suffix_tree.py:29
Methodtest_search_substrings
Test searching for substrings of the full text.
data_structures/suffix_tree/tests/test_suffix_tree.py:48
Functiontest_send_file_running_as_expected
(file, sock)
file_transfer/tests/test_send_file.py:8
Functiontest_sepia
()
digital_image_processing/test_digital_image_processing.py:81
Functiontest_sha1_hash
()
hashes/sha1.py:133
Functiontest_signum
Tests the signum function >>> test_signum()
maths/signum.py:39
Functiontest_single_point
Test with a single point.
geometry/tests/test_graham_scan.py:13
Methodtest_single_point
Test single point returns empty hull.
geometry/tests/test_jarvis_march.py:81
Functiontest_singly_linked_list
>>> test_singly_linked_list()
data_structures/linked_list/singly_linked_list.py:366
Functiontest_singly_linked_list_2
This section of the test used varying data types for input. >>> test_singly_linked_list_2()
data_structures/linked_list/singly_linked_list.py:411
Methodtest_size
test for method size()
linear_algebra/src/test_linear_algebra.py:41
Functiontest_sobel_filter
()
digital_image_processing/test_digital_image_processing.py:75
Methodtest_sorted
kp.calc_profit takes the required argument (profit, weight, max_weight) and returns whether the answer matches to the expected ones
knapsack/tests/test_greedy_knapsack.py:13
Methodtest_square
Test convex hull of a square.
geometry/tests/test_jarvis_march.py:89
Methodtest_square_zero_matrix
test for global function square_zero_matrix()
linear_algebra/src/test_linear_algebra.py:202
Functiontest_star_shape
Test with a star shape where only tips are on the convex hull.
geometry/tests/test_graham_scan.py:121
Methodtest_star_shape
Test star shape - only tips are in hull.
geometry/tests/test_jarvis_march.py:62
Methodtest_str
test for method toString()
linear_algebra/src/test_linear_algebra.py:34
Methodtest_str_matrix
test for Matrix method str()
linear_algebra/src/test_linear_algebra.py:128
Methodtest_sub
test for - operator
linear_algebra/src/test_linear_algebra.py:71
Functiontest_subtraction
(mat1, mat2)
matrix/tests/test_matrix_operation.py:58
Functiontest_transpose
(mat)
matrix/tests/test_matrix_operation.py:112
Functiontest_triangle
Test with a triangle (3 points).
geometry/tests/test_graham_scan.py:42
Methodtest_triangle
Test convex hull of a triangle.
geometry/tests/test_jarvis_march.py:40
Functiontest_triangle_with_interior_points
Test triangle with points inside.
geometry/tests/test_graham_scan.py:69
Functiontest_two_points
Test with two points.
geometry/tests/test_graham_scan.py:18
Methodtest_two_points
Test two points return empty hull.
geometry/tests/test_jarvis_march.py:85
Methodtest_unequal_list_length
Returns IndexError if length of lists (profit and weight) are unequal. :return: IndexError
knapsack/tests/test_greedy_knapsack.py:63
Methodtest_unit_basis_vector
test for global function unit_basis_vector()
linear_algebra/src/test_linear_algebra.py:97
Functiontest_vector
>>> g = Graph(8) >>> for u_v_w in ((0, 1, 10), (0, 2, 6), (0, 3, 5), (1, 3, 15), (2, 3, 4), ... (3, 4, 8), (4, 5, 10), (4, 6, 6), (4,
graphs/boruvka.py:141
Functiontest_vector
# Creates a list to store x vertices. >>> x = 5 >>> G = [Vertex(n) for n in range(x)] >>> connect(G, 1, 2, 15) >>> connect(G, 1,
graphs/prim.py:118
Functiontest_zero
(function)
maths/test_factorial.py:14
Methodtest_zero_vector
test for global function zero_vector()
linear_algebra/src/test_linear_algebra.py:91
Functiontext_from_bits
>>> text_from_bits('011011010111001101100111') 'msg'
hashes/hamming_code.py:61
Functiontext_justification
Will format the string such that each line has exactly (max_width) characters and is fully (left and right) justified, and return the lis
strings/text_justification.py:1
Functiontext_to_bits
>>> text_to_bits("msg") '011011010111001101100111'
hashes/hamming_code.py:52
Functiontf_idf
Combine the term frequency and inverse document frequency functions to calculate the originality of a term. This 'originality' is cal
machine_learning/word_frequency_functions.py:123
Functiontf_k_means_cluster
K-Means Clustering using TensorFlow. 'vectors' should be a n*k 2-D NumPy array, where n is the number of vectors of dimensionality k.
dynamic_programming/k_means_clustering_tensorflow.py:7
Functionthree_sum
Find all unique triplets in a sorted array of integers that sum up to zero. Args: nums: A sorted list of integers. Returns:
maths/three_sum.py:6
Functionthree_way_radix_quicksort
Three-way radix quicksort: https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort First divide the list into three parts.
sorts/quick_sort_3_partition.py:91
Functionthrow_dice
Return probability list of all possible sums when throwing dice. >>> random.seed(0) >>> throw_dice(10, 1) [10.0, 0.0, 30.0, 50.0, 10
maths/monte_carlo_dice.py:17
Functionto_camel_case
>>> to_camel_case("one two 31235three4four") 'oneTwo31235three4four'
strings/string_switch_case.py:89
Functionto_kebab_case
>>> to_kebab_case("one two 31235three4four", True) 'ONE-TWO-31235THREE4FOUR' >>> to_kebab_case("one two 31235three4four", False) 'one
strings/string_switch_case.py:111
Methodto_minimize
Opposite of the function to maximize Args: candidate (ndarray): candidate array to test Return:
machine_learning/support_vector_machines.py:130
Functionto_pascal_case
>>> to_pascal_case("one two 31235three4four") 'OneTwo31235three4four'
strings/string_switch_case.py:81
Functionto_snake_case
>>> to_snake_case("one two 31235three4four", True) 'ONE_TWO_31235THREE4FOUR' >>> to_snake_case("one two 31235three4four", False) 'one
strings/string_switch_case.py:101
Methodto_sorted_list
Returns sorted list containing all the values in the heap. >>> rh = RandomizedHeap([3, 1, 3, 7]) >>> rh.to_sorted_list()
data_structures/heap/randomized_heap.py:188
Functiontop_k_frequent_words
Returns the `k_value` most frequently occurring words, in non-increasing order of occurrence. In this context, a word is defined as an el
strings/top_k_frequent_words.py:67
Functiontopo
(g, ind=None, q=None)
graphs/basic_graphs.py:189
Functiontopological_sort
Perform topological sorting of a Directed Acyclic Graph (DAG) using Kahn's Algorithm via Breadth-First Search (BFS). Topological sorting
graphs/kahns_algorithm_topo.py:1
Methodtopological_sort
(self, s=-2)
graphs/directed_and_undirected_weighted_graph.py:113
Functiontotient
>>> n = 10 >>> totient_calculation = totient(n) >>> for i in range(1, n): ... print(f"{i} has {totient_calculation[i]} relative p
maths/eulers_totient.py:2
Methodtrain
( self, patterns, datas_train, datas_teach, n_repeat, error_accuracy, draw_e=bool )
neural_network/convolution_neural_network.py:212
Methodtraversal_tree
This function traversal the tree. You can pass a function to traversal the tree as needed by client code
data_structures/binary_tree/binary_search_tree.py:308
Functiontriangular_number
Generate the triangular number at the specified position. Args: position (int): The position of the triangular number to generate.
maths/special_numbers/triangular_numbers.py:11
Functiontribonacci
Given a number, return first n Tribonacci Numbers. >>> tribonacci(5) [0, 0, 1, 1, 2] >>> tribonacci(8) [0, 0, 1, 1, 2, 4, 7, 13]
dynamic_programming/tribonacci.py:4
Functiontriplet_sum1
Returns a triplet in the array with sum equal to target, else (0, 0, 0). >>> triplet_sum1([13, 29, 7, 23, 5], 35) (5, 7, 23) >>>
maths/triplet_sum.py:23
Functiontriplet_sum2
Returns a triplet in the array with sum equal to target, else (0, 0, 0). >>> triplet_sum2([13, 29, 7, 23, 5], 35) (5, 7, 23) >>>
maths/triplet_sum.py:42
Methodtvi
Transformed Vegetation Index https://www.indexdatabase.de/db/i-single.php?id=98 :return: index
digital_image_processing/index_calculation.py:520
Functiontwin_prime
# doctest: +NORMALIZE_WHITESPACE This functions takes an integer number as input. returns n+2 if n and n+2 are prime numbers and -1 other
maths/twin_prime.py:14
Functiontwos_complement
Take in a negative integer 'number'. Return the two's complement representation of 'number'. >>> twos_complement(0) '0b0' >>> tw
bit_manipulation/binary_twos_complement.py:4
Methodunbound
(self)
machine_learning/sequential_minimum_optimization.py:392
Functionunique_prime_factors
Returns unique prime factors of n as a list. >>> unique_prime_factors(0) [] >>> unique_prime_factors(100) [2, 5] >>> unique_
maths/prime_factors.py:50
Functionupdate
(frame: int)
physics/n_body_simulation.py:242
Methodupdate
Set index to value in O(lg^2 N) Parameters: index: index to update value: value to set Returns:
data_structures/binary_tree/maximum_fenwick_tree.py:67
Methodupdate_item
Updates given item value in heap if present
data_structures/heap/heap_generic.py:79
Functionupper
Convert an entire string to ASCII uppercase letters by looking for lowercase ASCII letters and subtracting 32 from their integer representati
strings/upper.py:1
Methodusername
(self)
web_programming/instagram_crawler.py:66
Functionvalidate_grid
Validate that the rows and columns of the grid is sorted in decreasing order. >>> for grid in test_grids: ... validate_grid(grid)
matrix/count_negative_numbers_in_sorted_matrix.py:27
Methodvalue
Return the value of the node. >>> SkewNode(0).value 0 >>> SkewNode(3.14159).value 3.14159 >>> SkewNo
data_structures/heap/skew_heap.py:23
Methodvalue
Return the value of the node. >>> rhn = RandomizedHeapNode(10) >>> rhn.value 10 >>> rhn = RandomizedHeapNode
data_structures/heap/randomized_heap.py:24
Methodvalue_weight
(self)
other/greedy.py:19
Methodvelocity
(self)
physics/n_body_simulation.py:56
Functionvisualise
Visually displays the Wa-Tor planet using an ascii code in terminal to clear and re-print the Wa-Tor planet at intervals. Uses ascii
cellular_automata/wa_tor.py:481
Functionviterbi
Viterbi Algorithm, to find the most likely path of states from the start and the expected output. https://en.wikipedia.org/wiki/Viterbi_
dynamic_programming/viterbi.py:4
Functionvolume_conversion
Conversion between volume units. >>> volume_conversion(4, "cubic meter", "litre") 4000 >>> volume_conversion(1, "litre", "gallon"
conversions/volume_conversions.py:40
Functionvolume_of_gas_system
>>> volume_of_gas_system(2, 100, 5) 332.57848 >>> volume_of_gas_system(0.5, 273, 0.004) 283731.01575 >>> volume_of_gas_system(3,
physics/ideal_gas_law.py:40
Functionwave
Returns a so called 'wave' of a given string >>> wave('cat') ['Cat', 'cAt', 'caT'] >>> wave('one') ['One', 'oNe', 'onE'] >>>
strings/wave_string.py:1
Methodwebsite
(self)
web_programming/instagram_crawler.py:82
Functionweierstrass_method
Approximates all complex roots of a polynomial using the Weierstrass (Durand-Kerner) method. Args: polynomial: A function that ta
maths/numerical_analysis/weierstrass_method.py:6
Functionweight_conversion
Conversion of weight unit with the help of KILOGRAM_CHART "kilogram" : 1, "gram" : pow(10, 3), "milligram" : pow(10, 6), "metric
conversions/weight_conversion.py:62
← previousnext →3,801–3,900 of 3,909, ranked by callers