* makes LRUCache constructor concrete
* fixes bug in dq_removal in other/least_recently_used
+ deque.remove() operates by value not index
* [mypy] Annotates other/least_recently_used over generic type
+ clean-up: rename key_reference to match type.
* [mypy] updates example to demonstrate LRUCache with complex type
* Adds doctest to other/least_recently_used
* mypy.ini: Remove exclude = (other/least_recently_used.py)
* Various mypy configs
* Delete mypy.ini
* Add mypy to .pre-commit-config.yaml
* mypy --ignore-missing-imports --install-types --non-interactive .
* mypy v0.910
* Pillow=8.3.7
* Pillow==8.3.7
* Pillow==8.3.2
* Update .pre-commit-config.yaml
* Update requirements.txt
* Update pre-commit.yml
* --install-types # See mirrors-mypy README.md
Co-authored-by: Christian Clauss <cclauss@me.com>
* Adds repr and doctest of current behavior linkedlist in other/lru_cache
* Blocks removal of head or tail of double linked list
* clarifies add() logic for double linked list in other/lru_cache
* expands doctests to compare cache and lru cache
* [mypy] annotates vars for other/lru_cache
* [mypy] Annotates lru_cache decorator for other/lru_cache
* Higher order functions require a verbose Callable annotation
* [mypy] Makes LRU_Cache generic over key and value types for other/lru_cache
+ no reason to force int -> int
* [mypy] makes decorator a classmethod for access to class generic types
* breaks two long lines in doctest for other/lru_cache
* simplifies boundary test remove() for other/lru_cache
* [mypy] Annotates, adds doctests, and makes Generic other/lfu_cache
See also commits to other/lru_cache which guided these
* [mypy] annotates cls var in other/lfu_cache
* cleans up items from code review for lfu_cache and lru_cache
* [mypy] runs mypy on lfu_cache and lru_cache
+ As per usage examples, clause literals are a list of strings.
+ Note: symbols extracted from literals are expected to be exactly two characters.
+ self.literal boolean values are initialized to None, so must be optional
+ model values should be Booleans, but aren't guaranteed to be non-None
in the code.
+ uses newer '... | None' annotation for Optional values
+ clauses are passed to the Formula initializer as both lists and sets, they
are stored as lists. Returned clauses will always be lists.
+ use explicit tuple annotation from __future__ rather than using (..., ...)
in return signatures
+ mapping returned by dpll_algorithm is optional per the documentation.
* [mypy] Fixes typing errors in other/date_to_weekday
* [mypy] uses future annotation style for other/date_to_weekly
* date_to_weekday: new implementation replaces buggy original
* date_to_weekday: add examples from multiple of 100 years
* clean-up: runs `black` to fix formatting
* Delete date_to_weekday.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* scoring_algorithm: Moves doctest into function docstring so it will be run
* [mypy] annotates other/scoring_algorithm
* [mypy] renames temp var to unique value to work around mypy issue in other/scoring_algorithm
reusing loop variables with the same name and different types gives
this very confusing mypy error response.
pyright correctly infers the types without issue.
```
scoring_algorithm.py:58: error: Incompatible types in assignment
(expression has type "float", variable has type "List[float]")
scoring_algorithm.py:60: error: Unsupported operand types for -
("List[float]" and "float")
scoring_algorithm.py:65: error: Incompatible types in assignment
(expression has type "float", variable has type "List[float]")
scoring_algorithm.py:67: error: Unsupported operand types for -
("List[float]" and "float")
Found 4 errors in 1 file (checked 1 source file)
```
* scoring_algorithm: uses enumeration instead of manual indexing on loop var
* scoring_algorithm: sometimes we look before we leap.
* clean-up: runs `black` to fix formatting
* Approve functions used as default argumenets
* The default value for **seed** is the result of a function call
The default value for **seed** is the result of a function call which is not normally recommended and causes flake8-bugbear to raise a B008 error. However, in this case, it is accptable because `LinearCongruentialGenerator.__init__()` will only be called once per instance and it ensures that each instance will generate a unique sequence of numbers.
* The default value for **backend** is the result of a function call
The default value for **backend** is the result of a function call which is not normally recommended and causes flake8-bugbear to raise a B008 error. However, in this case, it is accptable because `Aer.get_backend()` is called when the function is definition and that same backend is then reused for function calls.
* Update linear_congruential_generator.py
* Update ripple_adder_classic.py
* Update ripple_adder_classic.py
* Update ripple_adder_classic.py
* Update ripple_adder_classic.py
* Update ripple_adder_classic.py
* add date_to_weekday finder method
* reformat date_to_weekday method
* remove time
* remove hardcode weekdays list
* fix return type error
* fixing fail issue
* Finding the test failing issue
* after testing the pre-commit in local environment
* Move files to cellular_automata
* Rename other/davis–putnam–logemann–loveland.py to backtracking/davis–putnam–logemann–loveland.py
* Rename other/markov_chain.py to graphs/markov_chain.py
* undid rename: need to fix mypy first
* Add graham scan algorithm
* Fix argument name p with point
* Add tests in inner function
* updating DIRECTORY.md
* Fix graham scan for isort --profile=black
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Create medianOf TwoArrays.py
This code finds the median of two arrays (which may or may not be sorted initially).
Example:
Enter elements of an array: 1 5 4 2
Enter elements of another array: 1 7 4 2 7
The median of two arrays is : 4
* Rename medianOf TwoArrays.py to median_of _two_arrays.py
* Rename median_of _two_arrays.py to median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Update median_of_two_arrays.py
* Added doomsday algorithm
* Adding unit-tests to doomsday algorithm
* running black on doomsday
* adding doctest and fixing a black issue [doomsday]
* Update doomsday.py
* fixing black issue [doomsday]
* Update other/doomsday.py
* Update doomsday.py
* adding more doctests (following review comment) [doomsday]
Co-authored-by: John Law <johnlaw.po@gmail.com>
* fix assignment of a variable to itself
* Fix unnecessary 'else' clause in loop
* formatting and redundant reasignment fix
* mark unreachable code with a TODO comment
* fix variable defined multiple times
* fix static method without static decorator
* revert unintended autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* revert autoformatting issue
* applied black autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* spelling corrections
* review
* improved documentation, removed redundant variables, added testing
* added type hint
* camel case to snake case
* spelling fix
* review
* python --> Python # it is a brand name, not a snake
* explicit cast to int
* spaces in int list
* "!= None" to "is not None"
* Update comb_sort.py
* various spelling corrections in documentation & several variables naming conventions fix
* + char in file name
* import dependency - bug fix
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Dijkstra's Bankers algorithm
@bluedistro, Your review please. A second shot at #1645
Implementation of the Dijkstra's Banker's algorithm with test examples and a comprehensible description.
* fixup! Format Python code with psf/black push
* Delete back_propagation_neural_network.py
* Create back_propagation_neural_network.py
* fixup! Format Python code with psf/black push
* new file *iterating_through_submasks* is added in dynamic_programming section
* no changes
* *iterating_through_submasks.py is added in dynamic_programming
* iterating_through_submasks is added with doctests
* iterating_through_submasks.py is added in dynamic_programming
* changes made in *iterating_through_submasks.py
* changes made in *iterating_through_submasks.py
* updated
* *other/integeration_by_simpson_approx.py added
* *other/integeration_by_simpson_approx.py Added for integeration
* Delete iterating_through_submasks.py
* Delete DIRECTORY.md
* Revert "updated"
This reverts commit 73456f85de.
* changes made *integeration_by_simpson_approx.py
* update2
Co-authored-by: Christian Clauss <cclauss@me.com>
* Simplified DES
* Add files via upload
Diffie Hellman algorithm to generate a secret key.
* Update sdes.py
* Format code with psf/black and add doctests
* Create autocomplete_using_trie.py
The program aims to design a trie implementation for autocomplete which is easy to understand and ready to run.
* Removed unused import
* Updated the list value
* Update autocomplete_using_trie.py
* Run the code through Black and add doctest
Both of the two files implemented sieve of eratosthenes.
However, there was a bug in other/finding_primes.py, and the time complexity was larger than the other.
Therefore, remove other/finding_primes.py and add doctest tomaths/sieve_of_eratosthenes.py.
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory
* Removed .vs/ folder per #893
* Rename matrix_multiplication_addition.py to matrix_operation.py
* Added main() function and simplified password generation.
* Modified password_generator.py file according to suggestions in #968
Since `j` is redefined before it is used, it makes more sense to declare it with the value `None` instead of `1`.
This fixes a [warning from lgtm](66c4afbd0f/files/other/primelib.py)
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence.
For more details visit
wikipedia/Fischer-Yates-Shuffle