Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #91

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ repos:

# ruff adalah salah satu linter dan formatter kode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.1
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
rev: v1.11.1
hooks:
- id: mypy
args:
Expand Down
2 changes: 2 additions & 0 deletions OpenSeries/bilangan_istimewa.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ def angka_segitiga(angka: int) -> Union[int, error.ErrorTipeData, error.Error]:
error.Error: jika angka negatif
error.ErrorTipeData: jika tipe data salah
"""
# jika tipe data dari angka tidak integer
if not isinstance(angka, int):
return error.ErrorTipeData(["int"])
# jika value dari angka diisi nilai negatif
if angka < 0:
return error.Error("angka tidak boleh negatif")
return angka * (angka + 1) // 2
2 changes: 2 additions & 0 deletions OpenSeries/matematika.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def permutasi(nilai: int, r: int) -> Union[int, float, error.ErrorTipeData]:
faktorial_nilai = faktorial(nilai)
faktorial_nilai_r = faktorial(nilai - r)

# mengecek tipe data dari nilai faktorial
if isinstance(faktorial_nilai, int) and isinstance(faktorial_nilai_r, int):
return faktorial_nilai / faktorial_nilai_r
else:
Expand All @@ -288,6 +289,7 @@ def kombinasi(nilai: int, r: int) -> Union[int, float, error.ErrorTipeData]:
faktorial_r = faktorial(r)
faktorial_nilai_r = faktorial(nilai - r)

# mengecek nilai dari faktorial nilai
if (
isinstance(faktorial_nilai, int)
and isinstance(faktorial_r, int)
Expand Down
5 changes: 5 additions & 0 deletions OpenSeries/statistika.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ def entropy(
error.ErrorTipeData: error jika tipe data salah
error.Error: jika nilai label yang diberikan kosong
"""
# jika tipe data dari label bukan list
if not isinstance(label, (list)):
return error.ErrorTipeData(["list"])
# jika nilai di dalam list kosong
if not label:
return error.Error("label tidak boleh kosong")
# jika nilai di dalam list itu tidak int
if not all(isinstance(cek_nilai, int) for cek_nilai in label):
return error.ErrorTipeData(["int"])
_, count = np.unique(label, return_counts=True)
Expand All @@ -66,8 +69,10 @@ def standar_deviasi(
error.ErrorTipeData: error jika tipe data salah
error.Error: jika vektor yang diberikan kosong
"""
# cek parameter vektor jika tidak bertipe data np.ndarray
if not isinstance(vektor, np.ndarray):
return error.ErrorTipeData(["numpy array"])
# cek jika nilai vektor adalah 0
if len(vektor) == 0:
return error.Error("vektor tidak boleh kosong")

Expand Down
7 changes: 1 addition & 6 deletions OpenSeries/util/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@
# dan dikarakterisasi dalam berbagai cara
BILANGAN_EULER: float = 2.718281828459045235360

# konstanta plank, yang dilambangankan dengan h, yang merupakan konstanta fisika
# fundamental yang menghubungkan energi foton dengan frekuensinya, nilainya disini
# adalah 6.6261 × 10⁻³⁴ (joule per detik)
KONSTANTA_PLANCK = 6.6261 * pow(10, -34)

# variable ini juga mewakili dari konstanta planck, tetapi dinyatan dalam satuan
# elektron volt per detik (eV/s) nilainya adalah 4.1357 × 10⁻¹⁵ eV s⁻¹
KONSTANTA_PLANCK = 4.1357 * pow(10, -15)
KONSTANTA_PLANCK: float = 4.1357 * pow(10, -15)

# default error dari warna menggunakan kode ANSI escape
# merah
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
if platform.system == "windows":
core_require.append("pywin32")


install_require = [x.strip() for x in core_require if "git+" not in x]

# setup nama project
Expand Down