Kodowanie wspomagane przez AI dla programistów
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"""
[...]
Prompt użytkownika: Wygeneruj docstring dla tej funkcji, który zawiera:
Odpowiedź modelu:
Oto kompletny docstring, którego możesz użyć dla swojej funkcji:
def sales_trend(self):
"""
Analyze the sales data to determine whether there is an increasing trend
or a decreasing/stable trend over time.
[...]
"""
Oto kompletny docstring, którego możesz użyć dla swojej funkcji:
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.
[...]
"""



Oto dopracowany szkic pliku README.md dla Twojej klasy SalesAnalyzer:
SalesAnalyzer
Klasa SalesAnalyzer umożliwia prostą analizę dziennych danych sprzedażowych i wykrywanie, czy trend sprzedaży jest ogólnie rosnący, czy malejący/stabilny. Narzędzie to może być przydatne dla firm lub osób, które chcą uzyskać szybki, ogólny przegląd wyników sprzedaży w czasie.

(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)


Kodowanie wspomagane przez AI dla programistów