Compare commits
1
Commits
main
..
5cb64ccd9d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cb64ccd9d |
+1
-3
@@ -136,7 +136,5 @@ dmypy.json
|
|||||||
.pytype/
|
.pytype/
|
||||||
|
|
||||||
# Cython debug symbols
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
# linux
|
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
repos:
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
||||||
rev: v3.2.0
|
|
||||||
hooks:
|
|
||||||
- id: trailing-whitespace
|
|
||||||
- id: end-of-file-fixer
|
|
||||||
- id: check-yaml
|
|
||||||
- id: check-added-large-files
|
|
||||||
|
|
||||||
- repo: https://github.com/ambv/black
|
|
||||||
rev: 21.7b0
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
args: [--line-length=79]
|
|
||||||
language_version: python3.8
|
|
||||||
|
|
||||||
- repo: https://github.com/pycqa/flake8
|
|
||||||
rev: 3.7.9
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
||||||
rev: v0.910
|
|
||||||
hooks:
|
|
||||||
- id: mypy
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
Copyright © 2021 Shivan Sivakumaran
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Learning Python
|
|
||||||
|
|
||||||
By Shivan Sivakumaran. Started 18th Setempber 2021.
|
|
||||||
|
|
||||||
In an effort to solidify my knowledge in Python as well as help others I have decided to create a collection of my Python 'learnings'.
|
|
||||||
|
|
||||||
## Introduction to Pytest
|
|
||||||
|
|
||||||
18th September 2021
|
|
||||||
|
|
||||||
Pytest is a great tool that allows us to write automated test for our code. This ensures our code is both robust and professional.
|
|
||||||
|
|
||||||
[Check it out!](https://git.chch.tech/Shivan/learning_python/src/branch/main/intro_pytest)
|
|
||||||
|
|
||||||
## Zero to Hundred in Python
|
|
||||||
|
|
||||||
26th September 2021
|
|
||||||
|
|
||||||
Programming is a powerful tool and Python is an easy way to get started.
|
|
||||||
|
|
||||||
[Check it out!](https://git.chch.tech/Shivan/learning_python/src/branch/main/zero_2_hundred)
|
|
||||||
|
|
||||||
## What's next?
|
|
||||||
- Classes
|
|
||||||
- Django intro
|
|
||||||
- Setting up postgres
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[[source]]
|
|
||||||
url = "https://pypi.org/simple"
|
|
||||||
verify_ssl = true
|
|
||||||
name = "pypi"
|
|
||||||
|
|
||||||
[packages]
|
|
||||||
|
|
||||||
[dev-packages]
|
|
||||||
pytest = "*"
|
|
||||||
|
|
||||||
[requires]
|
|
||||||
python_version = "3.8"
|
|
||||||
Generated
-84
@@ -1,84 +0,0 @@
|
|||||||
{
|
|
||||||
"_meta": {
|
|
||||||
"hash": {
|
|
||||||
"sha256": "44ccf4c66d663506b934edaa5a4873daba29d125557d68c7840956adb918c913"
|
|
||||||
},
|
|
||||||
"pipfile-spec": 6,
|
|
||||||
"requires": {
|
|
||||||
"python_version": "3.8"
|
|
||||||
},
|
|
||||||
"sources": [
|
|
||||||
{
|
|
||||||
"name": "pypi",
|
|
||||||
"url": "https://pypi.org/simple",
|
|
||||||
"verify_ssl": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"default": {},
|
|
||||||
"develop": {
|
|
||||||
"attrs": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1",
|
|
||||||
"sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
|
||||||
"version": "==21.2.0"
|
|
||||||
},
|
|
||||||
"iniconfig": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3",
|
|
||||||
"sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"
|
|
||||||
],
|
|
||||||
"version": "==1.1.1"
|
|
||||||
},
|
|
||||||
"packaging": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7",
|
|
||||||
"sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '3.6'",
|
|
||||||
"version": "==21.0"
|
|
||||||
},
|
|
||||||
"pluggy": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159",
|
|
||||||
"sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '3.6'",
|
|
||||||
"version": "==1.0.0"
|
|
||||||
},
|
|
||||||
"py": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3",
|
|
||||||
"sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
|
||||||
"version": "==1.10.0"
|
|
||||||
},
|
|
||||||
"pyparsing": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
|
|
||||||
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
|
||||||
"version": "==2.4.7"
|
|
||||||
},
|
|
||||||
"pytest": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89",
|
|
||||||
"sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==6.2.5"
|
|
||||||
},
|
|
||||||
"toml": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
|
|
||||||
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
|
||||||
"version": "==0.10.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Introduction to Pytest
|
|
||||||
|
|
||||||
By Shivan Sivakumaran. 18th September 2021
|
|
||||||
|
|
||||||
## An overview
|
|
||||||
|
|
||||||
[Pytest is a python package](https://docs.pytest.org/en/6.2.x) where we write automated tests for our coded project. The reason we write tests for our code is to ensure the code runs the way we want. Writing automated tests can also make the process of testing our code easier, faster and more consistent.
|
|
||||||
|
|
||||||
We can develop tests first, in the case of test-driven development, and then build our code while using these automated tests to ensure we are heading in the correct direction.
|
|
||||||
|
|
||||||
We can also use the tests to ensure the changes we make to the code don't cause untended errors later in the pathway of our development.
|
|
||||||
|
|
||||||
Most modern packages come with automated testing code, so it is a great way to make your code look professional.
|
|
||||||
|
|
||||||
## Further resources
|
|
||||||
|
|
||||||
- [Blog post](https://shivansivakumaran.com/coding/introduction-to-pytest/)
|
|
||||||
- [Video](https://www.youtube.com/watch?v=FNCVFNDVCCI)
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# function.py
|
|
||||||
|
|
||||||
|
|
||||||
class Maths:
|
|
||||||
"""
|
|
||||||
A Maths class
|
|
||||||
n (int) - starting interger value
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, n: int):
|
|
||||||
self.n = n
|
|
||||||
|
|
||||||
def add(self, x: int) -> int:
|
|
||||||
self.n += x
|
|
||||||
return self.n
|
|
||||||
|
|
||||||
def subtract(self, x: int) -> int:
|
|
||||||
self.n -= x
|
|
||||||
return self.n
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f"n is {self.n}"
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# test_function.py
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from function import Maths
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def maths():
|
|
||||||
return Maths(10)
|
|
||||||
|
|
||||||
|
|
||||||
def test_exists(maths):
|
|
||||||
"""
|
|
||||||
Checks if objects are created
|
|
||||||
"""
|
|
||||||
assert isinstance(maths, Maths)
|
|
||||||
|
|
||||||
|
|
||||||
def test_add(maths):
|
|
||||||
"""
|
|
||||||
Addition method
|
|
||||||
"""
|
|
||||||
assert maths.add(10) == 20
|
|
||||||
|
|
||||||
|
|
||||||
def test_subtract(maths):
|
|
||||||
"""
|
|
||||||
Subtraction method
|
|
||||||
"""
|
|
||||||
assert maths.subtract(5) == 5
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[[source]]
|
|
||||||
url = "https://pypi.org/simple"
|
|
||||||
verify_ssl = true
|
|
||||||
name = "pypi"
|
|
||||||
|
|
||||||
[packages]
|
|
||||||
pandas = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
|
||||||
|
|
||||||
[requires]
|
|
||||||
python_version = "3.8"
|
|
||||||
Generated
-107
@@ -1,107 +0,0 @@
|
|||||||
{
|
|
||||||
"_meta": {
|
|
||||||
"hash": {
|
|
||||||
"sha256": "44a2006c840cfcfa4b8855e84f23bc17646a2b9634c870d36836c27d43571d6c"
|
|
||||||
},
|
|
||||||
"pipfile-spec": 6,
|
|
||||||
"requires": {
|
|
||||||
"python_version": "3.8"
|
|
||||||
},
|
|
||||||
"sources": [
|
|
||||||
{
|
|
||||||
"name": "pypi",
|
|
||||||
"url": "https://pypi.org/simple",
|
|
||||||
"verify_ssl": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"default": {
|
|
||||||
"numpy": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:09858463db6dd9f78b2a1a05c93f3b33d4f65975771e90d2cf7aadb7c2f66edf",
|
|
||||||
"sha256:209666ce9d4a817e8a4597cd475b71b4878a85fa4b8db41d79fdb4fdee01dde2",
|
|
||||||
"sha256:298156f4d3d46815eaf0fcf0a03f9625fc7631692bd1ad851517ab93c3168fc6",
|
|
||||||
"sha256:30fc68307c0155d2a75ad19844224be0f2c6f06572d958db4e2053f816b859ad",
|
|
||||||
"sha256:423216d8afc5923b15df86037c6053bf030d15cc9e3224206ef868c2d63dd6dc",
|
|
||||||
"sha256:426a00b68b0d21f2deb2ace3c6d677e611ad5a612d2c76494e24a562a930c254",
|
|
||||||
"sha256:466e682264b14982012887e90346d33435c984b7fead7b85e634903795c8fdb0",
|
|
||||||
"sha256:51a7b9db0a2941434cd930dacaafe0fc9da8f3d6157f9d12f761bbde93f46218",
|
|
||||||
"sha256:52a664323273c08f3b473548bf87c8145b7513afd63e4ebba8496ecd3853df13",
|
|
||||||
"sha256:550564024dc5ceee9421a86fc0fb378aa9d222d4d0f858f6669eff7410c89bef",
|
|
||||||
"sha256:5de64950137f3a50b76ce93556db392e8f1f954c2d8207f78a92d1f79aa9f737",
|
|
||||||
"sha256:640c1ccfd56724f2955c237b6ccce2e5b8607c3bc1cc51d3933b8c48d1da3723",
|
|
||||||
"sha256:7fdc7689daf3b845934d67cb221ba8d250fdca20ac0334fea32f7091b93f00d3",
|
|
||||||
"sha256:805459ad8baaf815883d0d6f86e45b3b0b67d823a8f3fa39b1ed9c45eaf5edf1",
|
|
||||||
"sha256:92a0ab128b07799dd5b9077a9af075a63467d03ebac6f8a93e6440abfea4120d",
|
|
||||||
"sha256:9f2dc79c093f6c5113718d3d90c283f11463d77daa4e83aeeac088ec6a0bda52",
|
|
||||||
"sha256:a5109345f5ce7ddb3840f5970de71c34a0ff7fceb133c9441283bb8250f532a3",
|
|
||||||
"sha256:a55e4d81c4260386f71d22294795c87609164e22b28ba0d435850fbdf82fc0c5",
|
|
||||||
"sha256:a9da45b748caad72ea4a4ed57e9cd382089f33c5ec330a804eb420a496fa760f",
|
|
||||||
"sha256:b160b9a99ecc6559d9e6d461b95c8eec21461b332f80267ad2c10394b9503496",
|
|
||||||
"sha256:b342064e647d099ca765f19672696ad50c953cac95b566af1492fd142283580f",
|
|
||||||
"sha256:b5e8590b9245803c849e09bae070a8e1ff444f45e3f0bed558dd722119eea724",
|
|
||||||
"sha256:bf75d5825ef47aa51d669b03ce635ecb84d69311e05eccea083f31c7570c9931",
|
|
||||||
"sha256:c01b59b33c7c3ba90744f2c695be571a3bd40ab2ba7f3d169ffa6db3cfba614f",
|
|
||||||
"sha256:d96a6a7d74af56feb11e9a443150216578ea07b7450f7c05df40eec90af7f4a7",
|
|
||||||
"sha256:dd0e3651d210068d13e18503d75aaa45656eef51ef0b261f891788589db2cc38",
|
|
||||||
"sha256:e167b9805de54367dcb2043519382be541117503ce99e3291cc9b41ca0a83557",
|
|
||||||
"sha256:e42029e184008a5fd3d819323345e25e2337b0ac7f5c135b7623308530209d57",
|
|
||||||
"sha256:f545c082eeb09ae678dd451a1b1dbf17babd8a0d7adea02897a76e639afca310",
|
|
||||||
"sha256:fde50062d67d805bc96f1a9ecc0d37bfc2a8f02b937d2c50824d186aa91f2419"
|
|
||||||
],
|
|
||||||
"markers": "python_version < '3.11' and python_version >= '3.7'",
|
|
||||||
"version": "==1.21.2"
|
|
||||||
},
|
|
||||||
"pandas": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:272c8cb14aa9793eada6b1ebe81994616e647b5892a370c7135efb2924b701df",
|
|
||||||
"sha256:3334a5a9eeaca953b9db1b2b165dcdc5180b5011f3bec3a57a3580c9c22eae68",
|
|
||||||
"sha256:37d63e78e87eb3791da7be4100a65da0383670c2b59e493d9e73098d7a879226",
|
|
||||||
"sha256:3f5020613c1d8e304840c34aeb171377dc755521bf5e69804991030c2a48aec3",
|
|
||||||
"sha256:45649503e167d45360aa7c52f18d1591a6d5c70d2f3a26bc90a3297a30ce9a66",
|
|
||||||
"sha256:49fd2889d8116d7acef0709e4c82b8560a8b22b0f77471391d12c27596e90267",
|
|
||||||
"sha256:4def2ef2fb7fcd62f2aa51bacb817ee9029e5c8efe42fe527ba21f6a3ddf1a9f",
|
|
||||||
"sha256:53e2fb11f86f6253bb1df26e3aeab3bf2e000aaa32a953ec394571bec5dc6fd6",
|
|
||||||
"sha256:629138b7cf81a2e55aa29ce7b04c1cece20485271d1f6c469c6a0c03857db6a4",
|
|
||||||
"sha256:68408a39a54ebadb9014ee5a4fae27b2fe524317bc80adf56c9ac59e8f8ea431",
|
|
||||||
"sha256:7326b37de08d42dd3fff5b7ef7691d0fd0bf2428f4ba5a2bdc3b3247e9a52e4c",
|
|
||||||
"sha256:7557b39c8e86eb0543a17a002ac1ea0f38911c3c17095bc9350d0a65b32d801c",
|
|
||||||
"sha256:86b16b1b920c4cb27fdd65a2c20258bcd9c794be491290660722bb0ea765054d",
|
|
||||||
"sha256:a800df4e101b721e94d04c355e611863cc31887f24c0b019572e26518cbbcab6",
|
|
||||||
"sha256:a9f1b54d7efc9df05320b14a48fb18686f781aa66cc7b47bb62fabfc67a0985c",
|
|
||||||
"sha256:c399200631db9bd9335d013ec7fce4edb98651035c249d532945c78ad453f23a",
|
|
||||||
"sha256:e574c2637c9d27f322e911650b36e858c885702c5996eda8a5a60e35e6648cf2",
|
|
||||||
"sha256:e9bc59855598cb57f68fdabd4897d3ed2bc3a3b3bef7b868a0153c4cd03f3207",
|
|
||||||
"sha256:ebbed7312547a924df0cbe133ff1250eeb94cdff3c09a794dc991c5621c8c735",
|
|
||||||
"sha256:ed2f29b4da6f6ae7c68f4b3708d9d9e59fa89b2f9e87c2b64ce055cbd39f729e",
|
|
||||||
"sha256:f7d84f321674c2f0f31887ee6d5755c54ca1ea5e144d6d54b3bbf566dd9ea0cc"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==1.3.3"
|
|
||||||
},
|
|
||||||
"python-dateutil": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
|
||||||
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
|
||||||
"version": "==2.8.2"
|
|
||||||
},
|
|
||||||
"pytz": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da",
|
|
||||||
"sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"
|
|
||||||
],
|
|
||||||
"version": "==2021.1"
|
|
||||||
},
|
|
||||||
"six": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
|
|
||||||
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
|
||||||
"version": "==1.16.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"develop": {}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Zero to Hundred in Python
|
|
||||||
|
|
||||||
By Shivan Sivakumaran. 26th September 2021
|
|
||||||
|
|
||||||
## An overview
|
|
||||||
|
|
||||||
Programming is a powerful tool. Python is a general purpose programming language that makes it easy to start the journey of learning how to code.
|
|
||||||
|
|
||||||
Here is a quick demo from zero to hundred.
|
|
||||||
|
|
||||||
## Further resources
|
|
||||||
|
|
||||||
- [Blog post](https://shivansivakumaran.com/coding/zero-to-hundred-python/)
|
|
||||||
- [Video](https://youtu.be/txAbHRz4orA)
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user