MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

Functionsecond_effusion_rate
Input Parameters: ----------------- effusion_rate: Effustion rate of second gas (m^2/s, mm^2/s, etc.) molar_mass_1: Molar mass of the
physics/grahams_law.py:103
Functionsecond_molar_mass
Input Parameters: ----------------- molar_mass: Molar mass of the first gas (g/mol, kg/kmol, etc.) effusion_rate_1: Effustion rate of
physics/grahams_law.py:175
Functionsentence_to_title_case
Converts a string to title case, preserving the input as is >>> sentence_to_title_case("Aakash Giri") 'Aakash Giri' >>> sente
strings/title.py:34
MethodsetUp
Set up the initial conditions for each test.
data_structures/suffix_tree/tests/test_suffix_tree.py:15
Functionset_bit
Set the bit at position to 1. Details: perform bitwise or for given number and X. Where X is a number with all the bits - zeroes and bit
bit_manipulation/single_bit_manipulation_operations.py:6
Methodset_side
>>> Polygon().set_side(0, Side(5)) Traceback (most recent call last): ... IndexError: list assignment index out o
geometry/geometry.py:213
Functionshear_stress
This function can calculate any one of the three - 1. Shear Stress 2. Tangential Force 3. Cross-sectional Area This is calculated
physics/shear_stress.py:12
Functionshell_sort
Implementation of shell sort algorithm in Python :param collection: Some mutable ordered collection with heterogeneous comparable items insid
sorts/shrink_shell_sort.py:24
Functionshow_frequency_response
Show frequency response of a filter >>> from audio_filters.iir_filter import IIRFilter >>> filt = IIRFilter(4) >>> show_frequency_re
audio_filters/show_response.py:38
Functionshow_phase_response
Show phase response of a filter >>> from audio_filters.iir_filter import IIRFilter >>> filt = IIRFilter(4) >>> show_phase_response(f
audio_filters/show_response.py:70
Methodshowcell
(self)
machine_learning/astar.py:42
Methodsibling
Get the current node's sibling, or None if it doesn't exist.
data_structures/binary_tree/red_black_tree.py:431
Functionsieve_er
input: positive integer 'N' > 2 returns a list of prime numbers from 2 up to N. This function implements the algorithm called sieve
maths/primelib.py:95
Functionsigmoid
(x: np.ndarray)
neural_network/back_propagation_neural_network.py:25
Functionsigmoid
Implements the sigmoid function Parameters: vector (np.array): A numpy array of shape (1,n) consisting of real values
maths/sigmoid.py:14
Functionsigmoid_linear_unit
Implements the Sigmoid Linear Unit (SiLU) or swish function Parameters: vector (np.ndarray): A numpy array consisting of real value
neural_network/activation_functions/swish.py:33
Functionsimilarity_search
:param dataset: Set containing the vectors. Should be ndarray. :param value_array: vector/vectors we want to know the nearest vector from dat
machine_learning/similarity_search.py:37
Functionsimple_fibonacci
Returns the nth number of the Fibonacci sequence that starts with f1 and f2 Uses the definition >>> simple_fibonacci(1, 5, 6) 5
maths/matrix_exponentiation.py:67
Functionsimple_interest
>>> simple_interest(18000.0, 0.06, 3) 3240.0 >>> simple_interest(0.5, 0.06, 3) 0.09 >>> simple_interest(18000.0, 0.01, 10) 18
financial/interest.py:6
Functionsimplify_fraction
input: two integer 'numerator' and 'denominator' assumes: 'denominator' != 0 returns: a tuple with simplify numerator and denominator.
maths/primelib.py:728
Functionsimpson_integration
Args: function : the function which's integration is desired a : the lower limit of integration b : upper limit of integr
maths/numerical_analysis/integration_by_simpson_approx.py:37
Functionsimulate
The main function, it will simulate the evolution of the highway >>> simulate([[-1, 2, -1, -1, -1, 3]], 2, 0.0, 3) [[-1, 2, -1, -1, -1, 3
cellular_automata/nagel_schrekenberg.py:108
Methodsingle_line
(row_vector: list[float])
matrix/sherman_morrison.py:44
Methodsize
(self)
graphs/breadth_first_search_zero_one_shortest_path.py:34
Methodsize
(self)
data_structures/queues/queue_on_pseudo_stack.py:58
Functionsliding_window_maximum
Return a list containing the maximum of each sliding window of size window_size. This implementation uses a monotonic deque to achieve O(n)
other/sliding_window_maximum.py:4
Functionslow_primes
Return a list of all primes numbers up to max. >>> list(slow_primes(0)) [] >>> list(slow_primes(-1)) [] >>> list(slow_primes(
maths/prime_numbers.py:5
Functionslow_solution
To evaluate the solution, use solution() >>> slow_solution(3) 120 >>> slow_solution(6) 18720 >>> slow_solution(7) 68720
project_euler/problem_145/sol1.py:80
Functionslow_solution
Returns the number of composite integers below max_number have precisely two, not necessarily distinct, prime factors. >>> slow_solution
project_euler/problem_187/sol1.py:71
Functionslowsort
Sorts sequence[start..end] (both inclusive) in-place. start defaults to 0 if not given. end defaults to len(sequence) - 1 if not given.
sorts/slowsort.py:15
Methodsmall_tree
Return a small binary tree with 3 nodes. >>> binary_tree = BinaryTree.small_tree() >>> len(binary_tree) 3 >>>
data_structures/binary_tree/basic_binary_tree.py:42
Functionsmallest_prime_factor
input: integer 'number' >= 0 returns the smallest prime number factor of 'number' >>> smallest_prime_factor(0) 0 >>> smallest_pr
maths/primelib.py:277
Functionsmooth_l1_loss
Calculate the Smooth L1 Loss between y_true and y_pred. The Smooth L1 Loss is less sensitive to outliers than the L2 Loss and is often used
machine_learning/loss_functions.py:576
Functionsnake_to_camel_case
Transforms a snake_case given string to camelCase (or PascalCase if indicated) (defaults to not use Pascal) >>> snake_to_camel_case("som
strings/snake_case_to_camel_pascal_case.py:1
Functionsoboleva_modified_hyperbolic_tangent
Implements the Soboleva Modified Hyperbolic Tangent function Parameters: vector (ndarray): A vector that consists of numeric values
neural_network/activation_functions/soboleva_modified_hyperbolic_tangent.py:14
Functionsolovay_strassen
Check whether the input number is prime or not using the Solovay-Strassen Primality test Parameters: number: The number that is
maths/solovay_strassen_primality_test.py:64
Functionsolution
Returns the side length of the square spiral of odd length greater than 1 for which the ratio of primes along both diagonals first falls
project_euler/problem_058/sol1.py:79
Functionsolution
Considering any range can be provided, because as per the problem, the digit d < 1000 >>> solution(1, 10) 7 >>> solution(10, 100)
project_euler/problem_026/sol1.py:27
Functionsolution
Returns the sum of truncated primes
project_euler/problem_037/sol1.py:111
Functionsolution
>>> solution() 55
project_euler/problem_035/sol1.py:74
Functionsolution
Considering natural numbers of the form, a**b, where a, b < 100, what is the maximum digital sum? :param a: :param b: :return:
project_euler/problem_056/sol1.py:13
Functionsolution_fast
Returns the product of a,b,c which are Pythagorean Triplet that satisfies the following: 1. a < b < c 2. a**2 + b**2 = c**2
project_euler/problem_009/sol1.py:41
Functionsolve
>>> solve(13, 2) 1 >>> solve(10, 2) 1 >>> solve(10, 3) 0 >>> solve(20, 2) 1 >>> solve(15, 10) 0 >>> solve
backtracking/power_sum.py:54
Functionsolve_maze
This method solves the "rat in maze" problem. Parameters : - maze: A two dimensional matrix of zeros and ones. - source_row:
backtracking/rat_in_maze.py:4
Functionspeed_of_sound_in_a_fluid
Calculates the speed of sound in a fluid from its density and bulk modulus Examples: Example 1 --> Water 20°C: bulk_modulus= 2.15MPa, de
physics/speed_of_sound.py:23
Functionspiral_traversal
>>> spiral_traversal([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7] Example: matrix = [[1, 2
matrix/spiral_print.py:82
Functionsplit
Will split the string up into all the values separated by the separator (defaults to spaces) >>> split("apple#banana#cherry#orange",sepa
strings/split.py:1
Functionsquare_root_iterative
Square root approximated using Newton's method. https://en.wikipedia.org/wiki/Newton%27s_method >>> all(abs(square_root_iterative(i) - m
maths/numerical_analysis/square_root.py:21
Functionsquareplus
Implements the SquarePlus activation function. Parameters: vector (np.ndarray): The input array for the SquarePlus activation.
neural_network/activation_functions/squareplus.py:12
Functionstable_matching
Finds the stable match in any bipartite graph, i.e a pairing where no 2 objects prefer each other over their partner. The function accepts t
graphs/gale_shapley_bigraph.py:4
Functionstalin_sort
Sorts a list using the Stalin sort algorithm. >>> stalin_sort([4, 3, 5, 2, 1, 7]) [4, 5, 7] >>> stalin_sort([1, 2, 3, 4]) [1, 2
sorts/stalin_sort.py:8
Functionstandardization
Return a standardized list of values. @params: data, a list of values to standardize @returns: a list of standardized values (rounded to
machine_learning/data_transformations.py:51
Methodstep_2
>>> def f(x, y): ... return x >>> AdamsBashforth(f, [0, 0.2], [0, 0], 0.2, 1).step_2() array([0. , 0. , 0.06, 0
maths/numerical_analysis/adams_bashforth.py:67
Methodstep_3
>>> def f(x, y): ... return x + y >>> y = AdamsBashforth(f, [0, 0.2, 0.4], [0, 0, 0.04], 0.2, 1).step_3() >>> flo
maths/numerical_analysis/adams_bashforth.py:100
Methodstep_4
>>> def f(x,y): ... return x + y >>> y = AdamsBashforth( ... f, [0, 0.2, 0.4, 0.6], [0, 0, 0.04, 0.128], 0.2,
maths/numerical_analysis/adams_bashforth.py:137
Methodstep_5
>>> def f(x,y): ... return x + y >>> y = AdamsBashforth( ... f, [0, 0.2, 0.4, 0.6, 0.8], [0, 0.02140, 0.02140
maths/numerical_analysis/adams_bashforth.py:181
Functionstrip
Remove leading and trailing characters (whitespace by default) from a string. Args: user_string (str): The input string to be stripp
strings/strip.py:1
Functionstrongly_connected_components
This function takes graph as a parameter and then returns the list of strongly connected components >>> strongly_connected_components(tes
graphs/strongly_connected_components.py:59
Functionsubtract
>>> subtract([[1,2],[3,4]],[[2,3],[4,5]]) [[-1, -1], [-1, -1]] >>> subtract([[1,2.5],[3,4]],[[2,3],[4,5.5]]) [[-1, -0.5], [-1, -1.5]]
matrix/matrix_operation.py:30
Functionsum_of_digits_compact
Find the sum of digits of a number >>> sum_of_digits_compact(12345) 15 >>> sum_of_digits_compact(123) 6 >>> sum_of_digits_com
maths/sum_of_digits.py:37
Functionsum_of_digits_recursion
Find the sum of digits of a number using recursion >>> sum_of_digits_recursion(12345) 15 >>> sum_of_digits_recursion(123) 6 >
maths/sum_of_digits.py:21
Functionsum_of_divisors
Calculate Sum of Divisors. >>> sum_of_divisors(100) 217 >>> sum_of_divisors(0) Traceback (most recent call last): ...
maths/basic_maths.py:66
Functionsum_of_geometric_progression
" Return the sum of n terms in a geometric progression. >>> sum_of_geometric_progression(1, 2, 10) 1023.0 >>> sum_of_geometric_pr
maths/sum_of_geometric_progression.py:1
Functionsumset
:param first set: a set of numbers :param second set: a set of numbers :return: the nth number in Sylvester's sequence >>> sumset({1
maths/sumset.py:11
Methodsupport
(self)
machine_learning/sequential_minimum_optimization.py:396
Functionswish
Parameters: vector (np.ndarray): A numpy array consisting of real values trainable_parameter: Use to implement various Swish Act
neural_network/activation_functions/swish.py:53
Functiontangent_hyperbolic
Implements the tanh function Parameters: vector: np.ndarray Returns: tanh (np.array): The input num
maths/tanh.py:16
Functiontemp_input_value
Temporary input values for tests >>> temp_input_value(option=True) 10 >>> temp_input_value(option=False) 1000 >>> temp_inp
other/guess_the_number_search.py:16
Functiontemperature_of_gas_system
>>> temperature_of_gas_system(2, 100, 5) 30.068090996146232 >>> temperature_of_gas_system(11, 5009, 1000) 54767.66101807144 >>> t
physics/ideal_gas_law.py:56
Functionterm_frequency
Return the number of times a term occurs within a given document. @params: term, the term to search a document for, and document,
machine_learning/word_frequency_functions.py:43
Functionterminal_velocity
>>> terminal_velocity(1, 25, 0.6, 0.77) 1.3031197996044768 >>> terminal_velocity(2, 100, 0.45, 0.23) 1.9467947148674276 >>> termi
physics/terminal_velocity.py:27
Functiontest1
()
matrix/sherman_morrison.py:245
Methodtest__add__matrix
test for Matrix + operator
linear_algebra/src/test_linear_algebra.py:186
Methodtest__mul__matrix
test for Matrix * operator
linear_algebra/src/test_linear_algebra.py:162
Methodtest__sub__matrix
test for Matrix - operator
linear_algebra/src/test_linear_algebra.py:194
Methodtest_add
test for + operator
linear_algebra/src/test_linear_algebra.py:61
Methodtest_add_and_remove_edges_repeatedly
(self)
graphs/graph_adjacency_matrix.py:487
Methodtest_add_and_remove_edges_repeatedly
(self)
graphs/graph_adjacency_list.py:475
Methodtest_add_and_remove_vertices_repeatedly
(self)
graphs/graph_adjacency_matrix.py:375
Methodtest_add_and_remove_vertices_repeatedly
(self)
graphs/graph_adjacency_list.py:363
Methodtest_add_edge
(self)
graphs/graph_adjacency_matrix.py:446
Methodtest_add_edge
(self)
graphs/graph_adjacency_list.py:434
Methodtest_add_edge_exception_check
(self)
graphs/graph_adjacency_matrix.py:550
Methodtest_add_edge_exception_check
(self)
graphs/graph_adjacency_list.py:538
Methodtest_add_vertex_exception_check
(self)
graphs/graph_adjacency_matrix.py:521
Methodtest_add_vertex_exception_check
(self)
graphs/graph_adjacency_list.py:509
Methodtest_add_vertices
(self)
graphs/graph_adjacency_matrix.py:327
Methodtest_add_vertices
(self)
graphs/graph_adjacency_list.py:315
Functiontest_addition
(mat1, mat2)
matrix/tests/test_matrix_operation.py:38
Methodtest_axpy
test for global function axpy() (operation)
linear_algebra/src/test_linear_algebra.py:103
Methodtest_base_case
test for the base case
knapsack/tests/test_knapsack.py:16
Functiontest_build_kdtree
Test that KD-Tree is built correctly. Cases: - Empty points list. - Positive depth value. - Negative depth value.
data_structures/kd_tree/tests/test_kdtree.py:26
Functiontest_burkes
(file_path: str = "digital_image_processing/image_data/lena_small.jpg")
digital_image_processing/test_digital_image_processing.py:86
Functiontest_canny
()
digital_image_processing/test_digital_image_processing.py:50
Methodtest_change_component
test for method change_component()
linear_algebra/src/test_linear_algebra.py:119
Methodtest_change_component_matrix
test for Matrix method change_component()
linear_algebra/src/test_linear_algebra.py:171
Functiontest_change_contrast
()
digital_image_processing/test_digital_image_processing.py:34
Functiontest_circular_linked_list
Test cases for the CircularLinkedList class. >>> test_circular_linked_list()
data_structures/linked_list/circular_linked_list.py:151
Methodtest_cofactor
test for Matrix method cofactor()
linear_algebra/src/test_linear_algebra.py:145
Functiontest_collinear_points
Test with all points on the same line.
geometry/tests/test_graham_scan.py:30
← previousnext →3,601–3,700 of 3,909, ranked by callers