Skip to content

Commit db87450

Browse files
Merge pull request #155 from alexanderthclark/codex/locate-modules-needing-code-linting
Remove trailing whitespace
2 parents 09b16f9 + 84e46f1 commit db87450

2 files changed

Lines changed: 35 additions & 35 deletions

File tree

freeride/curves.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def consumer_surplus(self, p, q=None):
302302
def total_revenue(self):
303303

304304
return Revenue.from_demand(self)
305-
305+
306306
def __repr__(self):
307307
"""Text representation for terminal/console."""
308308
if len(self.elements) == 1:
@@ -320,7 +320,7 @@ def __repr__(self):
320320
slope_part = "+Q"
321321
else:
322322
slope_part = f"{elem.slope:+g}Q"
323-
323+
324324
if elem.intercept == 0:
325325
# Remove leading + for cleaner display when no intercept
326326
return f"Demand: P = {slope_part.lstrip('+')}"
@@ -407,7 +407,7 @@ def q(self, p):
407407

408408
def producer_surplus(self, p, q=None):
409409
return -self.surplus(p, q)
410-
410+
411411
def __repr__(self):
412412
"""Text representation for terminal/console."""
413413
if len(self.elements) == 1:
@@ -424,7 +424,7 @@ def __repr__(self):
424424
slope_part = "-Q"
425425
else:
426426
slope_part = f"{elem.slope:+g}Q"
427-
427+
428428
if elem.intercept == 0:
429429
# Remove leading + for cleaner display when no intercept
430430
return f"Supply: P = {slope_part.lstrip('+')}"
@@ -508,7 +508,7 @@ def _check_slope(self):
508508
def __add__(self, other):
509509
elements = self.elements + other.elements
510510
return type(self)(elements=elements)
511-
511+
512512
def __repr__(self):
513513
"""Text representation for terminal/console."""
514514
if len(self.pieces) == 1:
@@ -517,17 +517,17 @@ def __repr__(self):
517517
if piece.slope == -1:
518518
slope_part = "-x"
519519
elif piece.slope == 1:
520-
slope_part = "+x"
520+
slope_part = "+x"
521521
else:
522522
slope_part = f"{piece.slope:+g}x"
523-
523+
524524
if piece.intercept == 0:
525525
return f"PPF: y = {slope_part.lstrip('+')}"
526526
else:
527527
return f"PPF: y = {piece.intercept:g}{slope_part}"
528528
else:
529529
return f"PPF: {len(self.pieces)}-piece frontier"
530-
530+
531531
def _repr_latex_(self):
532532
"""LaTeX representation for Jupyter notebooks."""
533533
if len(self.pieces) == 1:
@@ -547,7 +547,7 @@ def _repr_latex_(self):
547547
else:
548548
slope_str = f"{-piece.slope}x"
549549
expr = f"{piece.intercept} - {slope_str}"
550-
550+
551551
if x0 == 0 and np.isinf(x1):
552552
condition = f"x \\geq 0"
553553
elif x0 == 0:
@@ -556,9 +556,9 @@ def _repr_latex_(self):
556556
condition = f"x \\geq {x0}"
557557
else:
558558
condition = f"{x0} \\leq x \\leq {x1}"
559-
559+
560560
cases.append(f"{expr} & \\text{{if }} {condition}")
561-
561+
562562
cases_str = " \\\\".join(cases)
563563
return f"$y = \\begin{{cases}} {cases_str} \\end{{cases}}$"
564564

tests/test_repr_methods.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,119 +5,119 @@
55

66
class TestReprMethods(unittest.TestCase):
77
"""Test __repr__ methods for Demand, Supply, and PPF classes."""
8-
8+
99
def test_demand_repr_simple(self):
1010
"""Test basic demand curve representations."""
1111
# Standard demand: P = 10 - Q
1212
d1 = Demand(10, -1)
1313
self.assertEqual(repr(d1), "Demand: P = 10-Q")
14-
14+
1515
# Demand with different slope: P = 20 - 2Q
1616
d2 = Demand(20, -2)
1717
self.assertEqual(repr(d2), "Demand: P = 20-2Q")
18-
18+
1919
# Demand with fractional slope: P = 15 - 0.5Q
2020
d3 = Demand(15, -0.5)
2121
self.assertEqual(repr(d3), "Demand: P = 15-0.5Q")
22-
22+
2323
# Demand with small intercept: P = 0.5 - Q
2424
d4 = Demand(0.5, -1)
2525
self.assertEqual(repr(d4), "Demand: P = 0.5-Q")
26-
26+
2727
def test_demand_repr_special_cases(self):
2828
"""Test special cases for demand representations."""
2929
# Perfectly elastic demand (horizontal)
3030
d1 = Demand(5, 0)
3131
self.assertEqual(repr(d1), "Demand: P = 5")
32-
32+
3333
# Piecewise demand
3434
d_piece1 = Demand(20, -1)
3535
d_piece2 = Demand(10, -0.5)
3636
d_piecewise = d_piece1 + d_piece2
3737
self.assertEqual(repr(d_piecewise), "Demand: 2-piece piecewise function")
38-
38+
3939
def test_supply_repr_simple(self):
4040
"""Test basic supply curve representations."""
4141
# Standard supply: P = 2 + Q
4242
s1 = Supply(2, 1)
4343
self.assertEqual(repr(s1), "Supply: P = 2+Q")
44-
44+
4545
# Supply with different slope: P = 5 + 2Q
4646
s2 = Supply(5, 2)
4747
self.assertEqual(repr(s2), "Supply: P = 5+2Q")
48-
48+
4949
# Supply with fractional slope: P = 1 + 0.5Q
5050
s3 = Supply(1, 0.5)
5151
self.assertEqual(repr(s3), "Supply: P = 1+0.5Q")
52-
52+
5353
# Supply through origin: P = Q
5454
s4 = Supply(0, 1)
5555
self.assertEqual(repr(s4), "Supply: P = Q")
56-
56+
5757
# Supply with negative intercept: P = -2 + 3Q
5858
s5 = Supply(-2, 3)
5959
self.assertEqual(repr(s5), "Supply: P = -2+3Q")
60-
60+
6161
def test_supply_repr_special_cases(self):
6262
"""Test special cases for supply representations."""
6363
# Perfectly elastic supply (horizontal)
6464
s1 = Supply(3, 0)
6565
self.assertEqual(repr(s1), "Supply: P = 3")
66-
66+
6767
# Piecewise supply
6868
s_piece1 = Supply(0, 1)
6969
s_piece2 = Supply(10, 2)
7070
s_piecewise = s_piece1 + s_piece2
7171
self.assertEqual(repr(s_piecewise), "Supply: 2-piece piecewise function")
72-
72+
7373
def test_ppf_repr_simple(self):
7474
"""Test basic PPF representations."""
7575
# Standard PPF: y = 10 - x
7676
ppf1 = PPF(10, -1)
7777
self.assertEqual(repr(ppf1), "PPF: y = 10-x")
78-
78+
7979
# PPF with different slope: y = 20 - 2x
8080
ppf2 = PPF(20, -2)
8181
self.assertEqual(repr(ppf2), "PPF: y = 20-2x")
82-
82+
8383
# PPF through origin: y = -x
8484
ppf3 = PPF(0, -1)
8585
self.assertEqual(repr(ppf3), "PPF: y = -x")
86-
86+
8787
# PPF with fractional slope: y = 15 - 0.5x
8888
ppf4 = PPF(15, -0.5)
8989
self.assertEqual(repr(ppf4), "PPF: y = 15-0.5x")
90-
90+
9191
def test_ppf_repr_piecewise(self):
9292
"""Test piecewise PPF representation."""
9393
# Create two PPF segments
9494
ppf1 = PPF(10, -2)
9595
ppf2 = PPF(20, -1)
9696
ppf_combined = ppf1 + ppf2
9797
self.assertEqual(repr(ppf_combined), "PPF: 2-piece frontier")
98-
98+
9999
def test_number_formatting(self):
100100
"""Test that numbers are formatted cleanly without unnecessary decimals."""
101101
# Integer values should not show .0
102102
d1 = Demand(10.0, -1.0)
103103
self.assertEqual(repr(d1), "Demand: P = 10-Q")
104-
104+
105105
s1 = Supply(5.0, 2.0)
106106
self.assertEqual(repr(s1), "Supply: P = 5+2Q")
107-
107+
108108
# But fractional values should be preserved
109109
d2 = Demand(10.5, -1.5)
110110
self.assertEqual(repr(d2), "Demand: P = 10.5-1.5Q")
111-
111+
112112
s2 = Supply(2.5, 0.75)
113113
self.assertEqual(repr(s2), "Supply: P = 2.5+0.75Q")
114-
114+
115115
def test_sign_handling(self):
116116
"""Test that signs are handled correctly in all cases."""
117117
# Very small numbers should use g formatting
118118
d1 = Demand(10, -0.0001)
119119
self.assertEqual(repr(d1), "Demand: P = 10-0.0001Q")
120-
120+
121121
# Very large numbers
122122
s1 = Supply(1000000, 1000)
123123
self.assertEqual(repr(s1), "Supply: P = 1e+06+1000Q")

0 commit comments

Comments
 (0)