-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into pre-commit-ci-update-config
- Loading branch information
Showing
24 changed files
with
634 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ CONTRIBUTING.md | |
LICENSE | ||
README.md | ||
.github/* | ||
.github | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from OpenSeries.dasar import bulat, akar, tan_hiperbolik, volume_kubus | ||
|
||
if __name__ == "__main__": | ||
list_dasar: list = [bulat, akar, tan_hiperbolik, volume_kubus] | ||
for tipe in range(len(list_dasar)): | ||
print(type(list_dasar[tipe])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import OpenSeries.util.error as error | ||
import numpy as np | ||
from typing import Union | ||
import math | ||
|
||
|
||
def bulat( | ||
angka: Union[int, float], cek: bool = False | ||
) -> Union[int, bool, error.ErrorTipeData]: | ||
""" | ||
membuat fungsi untuk membulatkan angka | ||
Parameter: | ||
angka (int atau float): angka yang akan dibulatkan | ||
Return: | ||
int: hasil angka yang sudah dibulatkan | ||
bool: jika di set true maka akan mengecek sebuah angka | ||
error.ErrorTipeData: error jika tipe data tidak sesuai | ||
""" | ||
if not isinstance(angka, (int, float)): | ||
return error.ErrorTipeData(["int", "float"]) | ||
if cek is True: | ||
return int(angka) if angka - int(angka) >= 0 else int(angka) - 1 | ||
else: | ||
return math.ceil(angka) | ||
|
||
|
||
def akar( | ||
value: Union[int, float], iterasi: int = 4 | ||
) -> Union[float, error.ErrorTipeData]: | ||
""" | ||
apromasi nilai akar pada angka | ||
Args: | ||
value (Union[int,float]): input nilai | ||
iterasi (Optional[int]): mengsetup iterasi apporamasi. Defaults to 4. | ||
Returns: | ||
float: output dari angka yang telah di prediksi | ||
error.ErrorTipeData: error jika data yang dimasukkan salah | ||
""" | ||
|
||
# ngecheck tipe data pada value | ||
if not isinstance(value, (int, float)): | ||
raise error.ErrorTipeData(["int", "float"]) | ||
# ngecheck tipe data pada iterasi | ||
if not isinstance(iterasi, int): | ||
raise error.ErrorTipeData(["int"]) | ||
result = value | ||
for _ in range(iterasi + 1): | ||
result = (result + (value / result)) / 2 | ||
return round(result, 2) | ||
|
||
|
||
def tan_hiperbolik(x: np.ndarray) -> Union[np.ndarray, error.ErrorTipeData]: | ||
""" | ||
fungsi tangen hiperbolik | ||
Parameter: | ||
x (np.ndarray): nilai input yang ingin dikalkulasikan | ||
Return: | ||
np.ndarray: hasil dari kalkulasi tangen hiperbolik | ||
error.ErrorTipeData: error jika tipe data yang diberikan salah | ||
""" | ||
if not isinstance(x, np.ndarray): | ||
return error.ErrorTipeData(["numpy.ndarray"]) | ||
return (2 / (1 + np.exp(-2 * x))) - 1 | ||
|
||
|
||
def volume_kubus( | ||
panjang_sisi: Union[float, int], | ||
) -> Union[float, int, error.ErrorTipeData, error.Error]: | ||
""" | ||
menghitung volume kubus | ||
Parameter: | ||
panjang_sisi (int atau float): sisi yang akan dihitung | ||
return: | ||
float atau int: hasil dari perhitungan | ||
ErrorTipeData: error jika diberikan tipe data yang salah | ||
Error: error jika nilai yang diberikan negatif | ||
""" | ||
if not isinstance(panjang_sisi, (float, int)): | ||
return error.ErrorTipeData(["float", "int"]) | ||
if panjang_sisi < 0: | ||
return error.Error("panjang_sisi hanya menerima nilai positif") | ||
return pow(panjang_sisi, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.