Skip to content

Commit bcdaed8

Browse files
Merge pull request #142 from alexanderthclark/e4wmul-codex/rank-modules-by-linting-needs
Fix lint in costs.py
2 parents 6bad803 + 9b0b651 commit bcdaed8

1 file changed

Lines changed: 61 additions & 23 deletions

File tree

freeride/costs.py

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class Cost(PolyBase):
1515
"""
1616
Polynomial cost curve.
1717
18-
This class represents a polynomial cost curve and extends the PolyBase class. It provides methods
19-
for calculating costs, finding the efficient scale, breakeven price, shutdown price, and plotting
20-
various cost-related curves.
18+
This class represents a polynomial cost curve and extends ``PolyBase``. It
19+
provides methods for calculating costs, finding the efficient scale,
20+
breakeven price, shutdown price, and plotting various cost-related curves.
2121
2222
Parameters
2323
----------
@@ -276,10 +276,12 @@ def breakeven_price(self):
276276

277277
def shutdown_price(self):
278278
"""
279-
Assume perfect competition and find the price at which total revenue equals total variable cost.
279+
Assume perfect competition and find the price at which total revenue
280+
equals total variable cost.
280281
281-
This method calculates the price at which a firm should shut down in the short run to minimize losses,
282-
assuming perfect competition. It finds the price at which total revenue (TR) equals total variable cost (TVC).
282+
This method calculates the price at which a firm should shut down in the
283+
short run to minimize losses, assuming perfect competition. It finds the
284+
price at which total revenue (TR) equals total variable cost (TVC).
283285
284286
Returns
285287
----------
@@ -300,12 +302,14 @@ def long_run_plot(self, ax = None):
300302
"""
301303
Plot the long-run average cost (LRAC) and marginal cost (MC) curves.
302304
303-
This method plots the long-run average cost (LRAC) curve and the marginal cost (MC) curve on the same graph.
304-
It also marks the efficient scale and the breakeven price.
305+
This method plots the long-run average cost (LRAC) curve and the
306+
marginal cost (MC) curve on the same graph. It also marks the efficient
307+
scale and the breakeven price.
305308
306309
Args
307310
----------
308-
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If not provided, the current axis is used.
311+
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If
312+
not provided, the current axis is used.
309313
310314
Returns
311315
----------
@@ -348,14 +352,18 @@ def cost_profit_plot(self, p, ax = None, items = ['tc', 'tr', 'profit']):
348352
"""
349353
Plot various cost and profit components at a given price.
350354
351-
This method plots the average total cost (ATC) and marginal cost (MC) curves, and it marks the given price and
352-
quantity on the graph. It can also shade areas to represent total cost (TC), total revenue (TR), and profit (π).
355+
This method plots the average total cost (ATC) and marginal cost (MC)
356+
curves, and it marks the given price and quantity on the graph. It can
357+
also shade areas to represent total cost (TC), total revenue (TR), and
358+
profit (π).
353359
354360
Args
355361
----------
356362
p (float): The price at which to evaluate the cost and profit components.
357-
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If not provided, the current axis is used.
358-
items (list of str, optional): A list of items to include in the plot. Options are 'tc', 'tr', and 'profit'.
363+
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If
364+
not provided, the current axis is used.
365+
items (list of str, optional): A list of items to include in the
366+
plot. Options are 'tc', 'tr', and 'profit'.
359367
360368
Returns
361369
----------
@@ -395,14 +403,38 @@ def cost_profit_plot(self, p, ax = None, items = ['tc', 'tr', 'profit']):
395403
col = 'green'
396404
else:
397405
col = 'red'
398-
ax.fill_between([0,q], atc_of_q, p, color = col, alpha = 0.3, label = r"$\pi$", hatch = "\\")
406+
ax.fill_between(
407+
[0, q],
408+
atc_of_q,
409+
p,
410+
color = col,
411+
alpha = 0.3,
412+
label = r"$\pi$",
413+
hatch = "\\",
414+
)
399415

400416
if 'tc' in items:
401417
# total cost
402-
ax.fill_between([0,q], 0, atc_of_q, facecolor = 'yellow', alpha = 0.1, label = 'TC', hatch = "/")
418+
ax.fill_between(
419+
[0, q],
420+
0,
421+
atc_of_q,
422+
facecolor = 'yellow',
423+
alpha = 0.1,
424+
label = 'TC',
425+
hatch = "/",
426+
)
403427

404428
if 'tr' in items:
405-
ax.fill_between([0,q], 0, p, facecolor = 'blue', alpha = 0.1, label = 'TR', hatch = '+')
429+
ax.fill_between(
430+
[0, q],
431+
0,
432+
p,
433+
facecolor = 'blue',
434+
alpha = 0.1,
435+
label = 'TR',
436+
hatch = '+',
437+
)
406438

407439
update_axes_limits(ax)
408440

@@ -412,17 +444,20 @@ class AverageCost:
412444
"""
413445
Class representing the average cost curve.
414446
415-
The average cost (AC) curve is derived from a given cost function's coefficients. It calculates the cost per unit
416-
of output (average cost) for different levels of output (quantity).
447+
The average cost (AC) curve is derived from a given cost function's
448+
coefficients. It calculates the cost per unit of output (average cost) for
449+
different levels of output (quantity).
417450
418451
Args
419452
----------
420453
coef (array-like): Coefficients of the underlying cost function polynomial.
421454
422455
Attributes
423456
----------
424-
poly_coef (array-like): Coefficients of the underlying cost function polynomial excluding the constant term.
425-
coef (array-like): Coefficients of the underlying cost function polynomial, including the constant term.
457+
poly_coef (array-like): Coefficients of the underlying cost function
458+
polynomial excluding the constant term.
459+
coef (array-like): Coefficients of the underlying cost function
460+
polynomial, including the constant term.
426461
427462
Example
428463
----------
@@ -465,7 +500,8 @@ def cost(self, q):
465500
"""
466501
Calculate the average cost at a given quantity.
467502
468-
This method is equivalent to calling the object as a function with the quantity as the argument.
503+
This method is equivalent to calling the object as a function with the
504+
quantity as the argument.
469505
470506
Args
471507
----------
@@ -486,11 +522,13 @@ def plot(self, ax = None, max_q = 10, label = None):
486522
"""
487523
Plot the average cost curve.
488524
489-
This method generates a plot of the average cost (AC) curve over a range of output levels (quantity).
525+
This method generates a plot of the average cost (AC) curve over a range
526+
of output levels (quantity).
490527
491528
Args
492529
----------
493-
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If not provided, the current axis is used.
530+
ax (matplotlib.pyplot.axis, optional): The axis on which to plot. If
531+
not provided, the current axis is used.
494532
max_q (float, optional): The maximum quantity to plot up to.
495533
label (str, optional): Label for the curve on the plot.
496534

0 commit comments

Comments
 (0)