* pre-commit: Upgrade psf/black for stable style 2023
Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310
> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…
Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.
I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Reduce the complexity of other/graham_scan.py
* Lower the --max-complexity threshold in the file .flake8
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix tests
* Update other/graham_scan.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graham_scan.py
* Update other/graham_scan.py
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Condense `password` related files in one
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update other/password.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* dynamic_programming
* test: Make test input `str`
* requirements.txt: Remove cython>=0.29.28 # For statsmodels on Python 3.11
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Move pascals triange to maths/
* Update xgboost_classifier.py
* statsmodels is now compatible with Python 3.11
* statsmodels is now compatible with Python 3.11
* cython>=0.29.28
* cython>=0.29.28 # For statsmodels on Python 3.11
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added pascals_triangle.py program to maths directory
* Deleted 'pascals_triangle.py' because of duplication. Added a optimized function to generate pascal's triangle to 'pascal_triangle.py' program. Added some aadditional doctests to the existing function. Added some type check functionality to the existing function.
* Modified type check hints in 'generate_pascal_triangle_optimized' function'
q
* Modified 'pascal_triangle' prgram
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update pascal_triangle.py
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added a Pascal triangle implementation to the other folder
* Added Pascal triangle implementation to the other folder.
* Added Pascal triangle implementation to the other folder.
* Added Pascal triangle implementation to the other folder.
* Implemented a Pascal triangle generator.
* Reversed Changes to DIRECTORY.md
* Reversed changed to .md files
* Update other/pascal_triangle.py
Removed personal info
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
* Update pascal_triangle.py
Expanded the description of the algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Printed output in triangular form
* Update CONTRIBUTING.md
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Adding a Quine in Python.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Update password_generator.py
1. Use secrets module instead of random for passwords as it gives a secure source of randomness
2. Add type annotations for functions
3. Replace ctbi (variable for the characters to be included) with a more meaningful and short name
4. Use integer division instead of obtaining the integer part of a division computing a floating point
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Update maximum_subarray.py
1. Rectify documentation to indicate the correct output: function doesn't return the subarray, but rather returns a sum.
2. Make the function more Pythonic and optimal.
3. Make function annotation generic i.e. can accept any sequence.
4. Raise value error when the input sequence is empty.
* Update maximum_subarray.py
1. Use the conventions as mentioned in pep-0257.
2. Use negative infinity as the initial value for the current maximum and the answer.
* Update maximum_subarray.py
Avoid type conflict by returning the answer cast to an integer.
* Update other/maximum_subarray.py
Co-authored-by: Andrey <Cjkjvfnby@gmail.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update maximum_subarray.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update maximum_subarray.py
Remove typecast to int for the final answer
Co-authored-by: Andrey <Cjkjvfnby@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* MAINT: Used f-string method
Updated the code with f-string methods wherever required for a better and cleaner understanding of the code.
* Updated files with f-string method
* Update rsa_key_generator.py
* Update rsa_key_generator.py
* Update elgamal_key_generator.py
* Update lru_cache.py
I don't think this change is efficient but it might tackle the error as the error was due to using long character lines.
* Update lru_cache.py
* Update lru_cache.py
Co-authored-by: cyai <seriesscar@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* 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>