Mengembangkan Paket Python
James Fulton
Climate informatics researcher
import numpy as np
help(np.sum)
...
sum(a, axis=None, dtype=None, out=None)
Sum of array elements over a given axis.
Parameters
----------
a : array_like
Elements to sum.
axis : None or int or tuple of ints, optional
Axis or axes along which a sum is performed.
The default, axis=None, will sum all of the
elements of the input array.
...
import numpy as np
help(np.array)
...
array(object, dtype=None, copy=True)
Create an array.
Parameters
----------
object : array_like
An array, any object exposing the array
interface ...
dtype : data-type, optional
The desired data-type for the array.
copy : bool, optional
If true (default), then the object is copied.
...
import numpy as np
x = np.array([1,2,3,4])
help(x.mean)
...
mean(...) method of numpy.ndarray instance
a.mean(axis=None, dtype=None, out=None)
Returns the average of the array elements
along given axis.
Refer to `numpy.mean` for full documentation.
...
def count_words(filepath, words_list):""" ... """
def count_words(filepath, words_list):"""Hitung total kemunculan kata-kata ini."""
def count_words(filepath, words_list):"""Hitung total kemunculan kata-kata ini. Perhitungan dilakukan pada berkas teks di lokasi yang diberikan. """
def count_words(filepath, words_list):"""Hitung total kemunculan kata-kata ini. Perhitungan dilakukan pada berkas teks di lokasi yang diberikan. [jelaskan apa itu filepath dan words_list] [apa yang dikembalikan] """
Gaya dokumentasi Google
"""Baris ringkasan.
Deskripsi fungsi yang lebih panjang.
Args:
arg1 (int): Deskripsi arg1
arg2 (str): Deskripsi arg2
Gaya NumPy
"""Baris ringkasan.
Deskripsi fungsi yang lebih panjang.
Parameters
----------
arg1 : int
Deskripsi arg1 ...
Returns
----------
numpy.ndarray
Gaya reStructured text
"""Baris ringkasan.
Deskripsi fungsi yang lebih panjang.
:param arg1: Deskripsi arg1
:type arg1: int
:param arg2: Deskripsi arg2
:type arg2: str
Gaya Epytext
"""Baris ringkasan.
Deskripsi fungsi yang lebih panjang.
@type arg1: int
@param arg1: Deskripsi arg1
@type arg2: str
@param arg2: Deskripsi arg2
Populer di paket Python ilmiah seperti
numpyscipypandassklearnmatplotlibdaskimport scipy
help(scipy.percentile)
percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear') Compute the q-th percentile of the data along the specified axis. Returns the q-th percentile(s) of the array elements.Parameters ----------a : array_likeInput array or object that can be converted to an array.
Tipe lain meliputi - int, float, bool, str, dict, numpy.array, dll.
import scipy
help(scipy.percentile)
percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear')
...
Parameters
----------
...
axis : {int, tuple of int, None}
...
interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
import scipy
help(scipy.percentile)
percentile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear')
...
Returns
-------
percentile : scalar or ndarray
If `q` is a single percentile and `axis=None`, then the result
is a scalar. If multiple percentiles are given, first axis of
the result corresponds to the percentiles...
...
Bagian lain
RaisesSee AlsoNotesReferencesExamplespyment dapat digunakan untuk membuat docstringpyment -w -o numpydoc textanalysis.py
def count_words(filepath, words_list):
# Open the text file
...
return n
-w - timpa berkas-o numpydoc - keluaran gaya NumPypyment -w -o numpydoc textanalysis.py
def count_words(filepath, words_list):
"""
Parameters
----------
filepath :
words_list :
Returns
-------
type
"""
pyment -w -o google textanalysis.py
def count_words(filepath, words_list):
"""Hitung total kemunculan kata-kata ini.
Perhitungan dilakukan pada berkas teks di lokasi yang diberikan.
Parameters
----------
filepath : str
Path ke berkas teks.
words_list : list of str
Hitung total kemunculan kata-kata ini.
Returns
-------
"""
pyment -w -o google textanalysis.py
def count_words(filepath, words_list):
"""Hitung total kemunculan kata-kata ini.
Perhitungan dilakukan pada berkas teks di lokasi yang diberikan.
Args:
filepath(str): Path ke berkas teks.
words_list(list of str): Hitung total kemunculan kata-kata ini.
Returns:
"""
mysklearn/__init__.py
"""
Regresi linear untuk Python
============================
mysklearn adalah paket lengkap untuk mengimplementasikan
regresi linear di Python.
"""
mysklearn/preprocessing/__init__.py
"""
Subpaket untuk operasi prapemrosesan standar.
"""
mysklearn/preprocessing/normalize.py
"""
Modul untuk menormalisasi data.
"""
Mengembangkan Paket Python