開発者のための AI 支援コーディング
Francesca Donadoni
AI Curriculum Manager, DataCamp

def sales_trend(self):
...
if increasing > decreasing:
return "Increasing trend"
else:
return "Decreasing or stable trend"
def sales_trend(self):
"""Analyze sales data to determine the overall trend"""
[...]
ユーザープロンプト: 以下の内容を含む、この関数のdocstringを生成してください:
モデルの回答:
関数に使用できる完全なdocstringを示します:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
[...]
"""
関数に使用できる完全なdocstringを示します:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
Parameters
----------
self : object
An object that contains an attribute `daily_sales` (list of int or float),
which represents daily sales values in chronological order.
[...]
"""



SalesAnalyzerクラス向けのREADME.mdの下書きです:
SalesAnalyzer
SalesAnalyzerクラスは、日次売上データを分析し、売上トレンドが全体的に増加傾向にあるか、減少または横ばいかを検出する簡単な方法を提供します。このツールは、時系列での売上パフォーマンスの概要を素早く把握したい企業や個人に役立ちます。

(base) datacamp@test:~/datacamp/docstring-generation$ git diff
+
+ Raises:
+ ValueError: If daily_sales contains non-numeric values.
"""
- return sum(self.daily_sales)
+ if not all(isinstance(sale, (int, float)) for sale in self.daily_sales):
+ raise ValueError("All sales figures must be numeric.")
+ return sum(sale for sale in self.daily_sales)


開発者のための AI 支援コーディング