MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

Functionpressure_and_volume_to_temperature
Convert pressure and volume to temperature. Ideal gas laws are used. Temperature is taken in kelvin. Volume is taken in litres.
conversions/molecular_chemistry.py:66
Functionpressure_conversion
Conversion between pressure units. >>> pressure_conversion(4, "atm", "pascal") 405300 >>> pressure_conversion(1, "pascal", "psi")
conversions/pressure_conversions.py:42
Functionpressure_of_gas_system
>>> pressure_of_gas_system(2, 100, 5) 332.57848 >>> pressure_of_gas_system(0.5, 273, 0.004) 283731.01575 >>> pressure_of_gas_syst
physics/ideal_gas_law.py:24
Functionpretty_print
Print a complete diamond pattern with '*' characters. Args: n (int): Size of the pattern. Examples: >>> pretty_p
other/magicdiamondpattern.py:55
Functionprim
(g, s)
graphs/basic_graphs.py:284
Functionprim
Prim's Algorithm. Runtime: O(mn) with `m` edges and `n` vertices Return: List with the edges of a Minimum Spanning Tree
graphs/prim.py:56
Functionprim_heap
Prim's Algorithm with min heap. Runtime: O((m + n)log n) with `m` edges and `n` vertices Yield: Edges of a Minimum Spanning
graphs/prim.py:86
Functionprims_algo
>>> graph = GraphUndirectedWeighted() >>> graph.add_edge("a", "b", 3) >>> graph.add_edge("b", "c", 10) >>> graph.add_edge("c", "d",
graphs/minimum_spanning_tree_prims2.py:220
Functionprint_matrix
(matrix: list)
divide_and_conquer/strassen_matrix_multiplication.py:70
Functionprint_pascal_triangle
Print Pascal's triangle for different number of rows >>> print_pascal_triangle(5) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
matrix/pascal_triangle.py:11
Methodprint_queue
(self)
data_structures/binary_tree/avl_tree.py:37
Functionprint_words
Prints all the words in a Trie :param node: root node of Trie :param word: Word variable should be empty at start :return: None
data_structures/trie/trie.py:78
Functionprocentual_proximity
| `weights` - ``int`` list | possible values - ``0`` / ``1`` * ``0`` if lower values have higher weight in the data set * ``
other/scoring_algorithm.py:97
Methodprocess
Calculate :math:`y[n]` >>> filt = IIRFilter(2) >>> filt.process(0) 0.0
audio_filters/iir_filter.py:75
Functionproduct_sum_array
Calculates the product sum of an array. Args: array (List[Union[int, List]]): The array of integers and nested lists. Returns:
data_structures/arrays/product_sum.py:67
Methodprofile_picture_url
(self)
web_programming/instagram_crawler.py:98
Functionproper_fractions
this algorithm returns a list of proper fractions, in the range between 0 and 1, which can be formed with the given denominator https://e
maths/numerical_analysis/proper_fractions.py:4
Methodpush
>>> stack = LinkedStack() >>> stack.push("Python") >>> stack.push("Java") >>> stack.push("C") >>> str(st
data_structures/stacks/stack_with_singly_linked_list.py:94
Methodput
>>> queue = LinkedQueue() >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from
data_structures/queues/linked_queue.py:95
Methodput
Put `item` into the Queue >>> queue = QueueByTwoStacks() >>> queue.put(10) >>> queue.put(20) >>> len(queue)
data_structures/queues/queue_by_two_stacks.py:59
Methodput
Put `item` to the Queue >>> queue = QueueByList() >>> queue.put(10) >>> queue.put(20) >>> len(queue) 2
data_structures/queues/queue_by_list.py:58
Functionpytests
()
data_structures/linked_list/skip_list.py:408
Functionpytests
()
data_structures/binary_tree/red_black_tree.py:688
Functionpytests
()
data_structures/trie/radix_tree.py:211
Functionpytests
()
data_structures/trie/trie.py:115
Functionqr_householder
Return a QR-decomposition of the matrix A using Householder reflection. The QR-decomposition decomposes the matrix A of shape (m, n) into an
maths/qr_decomposition.py:4
Functionquantile
Returns the index'th smallest element in interval [start, end] in the list index is 0-indexed >>> root = build_tree(test_array) >>>
data_structures/binary_tree/wavelet_tree.py:121
Methodquery
Answer the query of maximum range [l, r) in O(lg^2 N) Parameters: left: left index of query range (inclusive)
data_structures/binary_tree/maximum_fenwick_tree.py:87
Functionquestion_function
The generating function u as specified in the question. >>> question_function(0) 1 >>> question_function(1) 1 >>> question_fu
project_euler/problem_101/sol1.py:164
Functionquick_select
Two way partition the data into smaller and greater lists, in relationship to the pivot :param arr: The data to be searched (a list)
searches/median_of_medians.py:61
Functionquick_sort
>>> for data in ([2, 1, 0], [2.2, 1.1, 0], "quick_sort"): ... quick_sort(data) == sorted(data) True True True
sorts/recursive_quick_sort.py:1
Functionquick_sort_lomuto_partition
A pure Python implementation of quick sort algorithm(in-place) with Lomuto partition scheme: https://en.wikipedia.org/wiki/Quicksort#Lomu
sorts/quick_sort_3_partition.py:44
Functionquote_of_the_day
()
web_programming/fetch_quotes.py:23
Functionradix_sort
Examples: >>> radix_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> radix_sort(list(range(15))) == sorted(range(15)) True >>> radi
sorts/radix_sort.py:12
Functionrainfall_intensity
Calculate the intensity of a rainfall event for a given duration and return period. It's based on the Sherman intensity-duration-frequency cu
physics/rainfall_intensity.py:17
Functionramer_douglas_peucker
Simplify a polyline using the Ramer-Douglas-Peucker algorithm. Given a sequence of 2-D points and a maximum allowable deviation *epsilon* (>=
geometry/ramer_douglas_peucker.py:79
Functionrandom_graph
Generate a random graph @input: vertices_number (number of vertices), probability (probability that a generic edge (u,v) exists),
graphs/random_graph_generator.py:12
Functionrandom_matrix
returns a random matrix WxH with integer components between 'a' and 'b'
linear_algebra/src/lib.py:435
Functionrandom_vector
input: size (N) of the vector. random range (a,b) output: returns a random vector of size N, with random integer compo
linear_algebra/src/lib.py:231
Functionrange_counting
Returns the number of elements in range [start_num, end_num] in interval [start, end] in the list >>> root = build_tree(test_array)
data_structures/binary_tree/wavelet_tree.py:161
Functionrank
Returns the number of occurrences of num in interval [start, end] in the list >>> root = build_tree(test_array) >>> rank(root, 6, 3, 13)
data_structures/binary_tree/wavelet_tree.py:100
Functionrank_of_matrix
Finds the rank of a matrix. Args: `matrix`: The matrix as a list of lists. Returns: The rank of the matrix. Exampl
linear_algebra/src/rank_of_matrix.py:8
Methodrank_query
Find the largest index with prefix(i) <= value in O(lg N) NOTE: Requires that all values are non-negative! Parameters:
data_structures/binary_tree/fenwick_tree.py:198
Functionrankine_to_celsius
Convert a given value from Rankine to Celsius and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_sc
conversions/temperature_conversions.py:242
Functionrankine_to_fahrenheit
Convert a given value from Rankine to Fahrenheit and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Rankine
conversions/temperature_conversions.py:266
Functionrankine_to_kelvin
Convert a given value from Rankine to Kelvin and round it to 2 decimal places. Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_sca
conversions/temperature_conversions.py:286
Methodratio
Return the value-to-weight ratio for the item. Returns: float: The value-to-weight ratio for the item. Examples
greedy_methods/fractional_cover_problem.py:13
Methodrbndvi
self.red-self.blue NDVI https://www.indexdatabase.de/db/i-single.php?id=187 :return: index
digital_image_processing/index_calculation.py:271
Functionreactive_power
Calculate reactive power from apparent power and power factor. Examples: >>> reactive_power(100, 0.9) 43.58898943540673 >>> reac
electronics/real_and_reactive_power.py:25
Functionread_data_sets
( train_dir, fake_data=False, one_hot=False, dtype=dtypes.float32, reshape=True, valid
neural_network/input_data.py:270
Methodread_model
(cls, model_path)
neural_network/convolution_neural_network.py:79
Functionreal_power
Calculate real power from apparent power and power factor. Examples: >>> real_power(100, 0.9) 90.0 >>> real_power(0, 0.8) 0.
electronics/real_and_reactive_power.py:4
Functionreaumur_to_celsius
Convert a given value from reaumur to celsius and round it to 2 decimal places. Reference:- http://www.csgnetwork.com/temp2conv.html >>>
conversions/temperature_conversions.py:344
Functionreaumur_to_fahrenheit
Convert a given value from reaumur to fahrenheit and round it to 2 decimal places. Reference:- http://www.csgnetwork.com/temp2conv.html
conversions/temperature_conversions.py:325
Functionreaumur_to_kelvin
Convert a given value from reaumur to Kelvin and round it to 2 decimal places. Reference:- http://www.csgnetwork.com/temp2conv.html >>>
conversions/temperature_conversions.py:306
Functionreaumur_to_rankine
Convert a given value from reaumur to rankine and round it to 2 decimal places. Reference:- http://www.csgnetwork.com/temp2conv.html >>>
conversions/temperature_conversions.py:363
Functionrec_linear_search
A pure Python implementation of a recursive linear search algorithm :param sequence: a collection with comparable items (as sorted items not
searches/linear_search.py:36
Functionreceptor_converter
>>> receptor_converter(4, "1111010010111111") (['1', '0', '1', '0', '1', '0', '1', '1', '1', '1', '1', '1'], True)
hashes/hamming_code.py:147
Functionrectangular_to_polar
https://en.wikipedia.org/wiki/Polar_coordinate_system >>> rectangular_to_polar(5,-5) (7.07, -45.0) >>> rectangular_to_polar(-1,1)
conversions/rectangular_to_polar.py:4
Functionrecursive_imply_list
Recursively calculates the implication of a list. Strictly the implication is applied consecutively left to right: ( (a -> b) -> c ) -> d
boolean_algebra/imply_gate.py:36
Functionrecursive_match
r""" Recursive matching algorithm. | Time complexity: O(2^(\|text\| + \|pattern\|)) | Space complexity: Recursion depth is O(\|text\| + \
dynamic_programming/regex_match.py:13
Methodred_edge_ndvi
Normalized Difference self.rededge/self.red https://www.indexdatabase.de/db/i-single.php?id=235 :return: index
digital_image_processing/index_calculation.py:235
Methodreduce
(self)
maths/dual_number_automatic_differentiation.py:23
Methodremove
(self)
data_structures/linked_list/__init__.py:77
Methodremove
(self, value: int)
data_structures/binary_tree/binary_search_tree.py:280
Functionremove_digit
returns the biggest possible result that can be achieved by removing one digit from the given number >>> remove_digit(152) 52
maths/remove_digit.py:1
Functionremove_duplicates
Remove duplicates from sentence >>> remove_duplicates("Python is great and Java is also great") 'Java Python also and great is' >>> r
strings/remove_duplicate.py:1
Methodremove_first
removal from the front >>> d = LinkedDeque() >>> d.is_empty() True >>> d.remove_first() Traceback (most recent
data_structures/linked_list/deque_doubly.py:105
Methodremove_last
removal in the end >>> d = LinkedDeque() >>> d.is_empty() True >>> d.remove_last() Traceback (most recent call
data_structures/linked_list/deque_doubly.py:125
Methodremove_pair
(self, u, v)
graphs/directed_and_undirected_weighted_graph.py:29
Methodremove_pair
(self, u, v)
graphs/directed_and_undirected_weighted_graph.py:290
Functionreport_generator
Generate a clustering report given these two arguments: predicted - dataframe with predicted cluster column fill_missing_report -
machine_learning/k_means_clust.py:218
Functionresistor_parallel
Req = 1/ (1/R1 + 1/R2 + ... + 1/Rn) >>> resistor_parallel([3.21389, 2, 3]) 0.8737571620498019 >>> resistor_parallel([3.21389, 2, -3]
electronics/resistor_equivalence.py:6
Functionresistor_series
Req = R1 + R2 + ... + Rn Calculate the equivalent resistance for any number of resistors in parallel. >>> resistor_series([3.21389, 2,
electronics/resistor_equivalence.py:31
Functionresonant_frequency
This function can calculate the resonant frequency of LC circuit, for the given value of inductance and capacitnace. Examples are given
electronics/resonant_frequency.py:16
Functionreverse_bit
Take in a 32 bit integer, reverse its bits, return a 32 bit integer result >>> reverse_bit(25) 2550136832 >>> reverse_bit(37) 27
bit_manipulation/reverse_bits.py:31
Functionreverse_words
Reverse the order of words in a given string. Extra whitespace between words is ignored. >>> reverse_words("I love Python") 'Python love
strings/reverse_words.py:1
Functionreynolds_number
>>> reynolds_number(900, 2.5, 0.05, 0.4) 281.25 >>> reynolds_number(450, 3.86, 0.078, 0.23) 589.0695652173912 >>> reynolds_number
physics/reynolds_number.py:33
Functionrgb_to_cmyk
Simple RGB to CMYK conversion. Returns percentages of CMYK paint. https://www.programmingalgorithms.com/algorithm/rgb-to-cmyk/ Note:
conversions/rgb_cmyk_conversion.py:1
Functionrgb_to_hsv
Conversion from the RGB-representation to the HSV-representation. The tested values are the reverse values from the hsv_to_rgb-doctests.
conversions/rgb_hsv_conversion.py:84
Methodri
Normalized Difference self.red/self.green self.redness Index https://www.indexdatabase.de/db/i-single.php?id=74 :return: inde
digital_image_processing/index_calculation.py:485
Functionrmse
Examples(rounded for precision): >>> actual = [1,2,3];predict = [1,4,3] >>> float(np.around(rmse(predict,actual),decimals = 2)) 1.15
machine_learning/scoring_functions.py:62
Functionrmsle
Examples(rounded for precision): >>> float(np.around(rmsle(predict=[10, 2, 30], actual=[10, 10, 30]), decimals=2)) 0.75 >>> float(rm
machine_learning/scoring_functions.py:84
Functionroman_to_int
LeetCode No. 13 Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to
conversions/roman_numerals.py:18
Functionroot_mean_square_error
Simple implementation of Root Mean Squared Error for two N dimensional numpy arrays. Examples: >>> root_mean_square_error(np.array([1
computer_vision/haralick_descriptors.py:10
Methodrotate
Rotate the items of the Queue `rotation` times >>> queue = QueueByList([10, 20, 30, 40]) >>> queue Queue((10, 20, 30, 40))
data_structures/queues/queue_by_list.py:98
Functionrsafactor
This function returns the factors of N, where p*q=N Return: [p, q] We call N the RSA modulus, e the encryption exponent, and d the
ciphers/rsa_factorization.py:19
Functionrun_length_decode
Performs Run Length Decoding >>> run_length_decode([('A', 4), ('B', 3), ('C', 2), ('D', 1), ('A', 2)]) 'AAAABBBCCDAA' >>> run_length_
data_compression/run_length_encoding.py:29
Functionrun_length_encode
Performs Run Length Encoding >>> run_length_encode("AAAABBBCCDAA") [('A', 4), ('B', 3), ('C', 2), ('D', 1), ('A', 2)] >>> run_length_
data_compression/run_length_encoding.py:4
Methodrun_simplex
Operate on tableau until objective function cannot be improved further. # Standard linear program: Max: x1 + x2 ST:
linear_programming/simplex.py:210
Functionrunge_kutta
Calculate the numeric solution at each step to the ODE f(x, y) using RK4 https://en.wikipedia.org/wiki/Runge-Kutta_methods Arguments:
maths/numerical_analysis/runge_kutta.py:4
Functionrunge_kutta_fehlberg_45
Solve an Ordinary Differential Equations using Runge-Kutta-Fehlberg Method (rkf45) of order 5. https://en.wikipedia.org/wiki/Runge%E2%80
maths/numerical_analysis/runge_kutta_fehlberg_45.py:10
Functionrunge_kutta_gills
Solve an Ordinary Differential Equations using Runge-Kutta-Gills Method of order 4. args: func: An ordinary differential equation (ODE)
maths/numerical_analysis/runge_kutta_gills.py:14
Methods
Saturation https://www.indexdatabase.de/db/i-single.php?id=77 :return: index
digital_image_processing/index_calculation.py:493
Methodsave_model
(self, save_path)
neural_network/convolution_neural_network.py:55
Functionscaled_exponential_linear_unit
Applies the Scaled Exponential Linear Unit function to each element of the vector. Parameters : vector : np.ndarray alpha : f
neural_network/activation_functions/scaled_exponential_linear_unit.py:18
Functionsdbm
Function implements sdbm hash, easy to use, great for bits scrambling. iterates over each character in the given string and applies function
hashes/sdbm.py:22
Methodsearch
(self)
graphs/bidirectional_breadth_first_search.py:130
Methodsearch
(self)
graphs/bidirectional_a_star.py:189
Methodsearch_in
>>> A = Automaton(["what", "hat", "ver", "er"]) >>> A.search_in("whatever, err ... , wherever") {'what': [0], 'hat': [1], 've
strings/aho_corasick.py:67
← previousnext →3,501–3,600 of 3,909, ranked by callers