|
| 1 | +""" |
| 2 | +Graph-specific logic |
| 3 | +""" |
| 4 | +from abc import ABC, abstractmethod |
| 5 | + |
| 6 | + |
| 7 | +GRAPH_TYPES = ( |
| 8 | + (0, 'Linear Demand and Supply'), |
| 9 | + (1, 'Input Markets'), |
| 10 | + (3, 'Cobb-Douglas Production Graph'), |
| 11 | + (5, 'Consumption-Leisure: Constraint'), |
| 12 | + (7, 'Consumption-Saving: Constraint'), |
| 13 | + (8, 'Linear Demand and Supply: 3 Functions'), |
| 14 | + |
| 15 | + # Area Under Curve graphs |
| 16 | + (9, 'Linear Demand and Supply: Areas'), |
| 17 | + (10, 'Input Markets: Areas'), |
| 18 | + |
| 19 | + (11, 'Consumption-Saving: Optimal Choice'), |
| 20 | + (15, 'Consumption-Leisure: Optimal Choice'), |
| 21 | + |
| 22 | + # Joint Graphs |
| 23 | + (12, 'Input-Output Illustrations'), |
| 24 | + (13, 'Linear Demand and Supply: 2 Diagrams'), |
| 25 | + (14, 'Input Markets: 2 Diagrams'), |
| 26 | + |
| 27 | + (16, 'Template Graph'), |
| 28 | + |
| 29 | + (17, 'Optimal Choice: Consumption with 2 Goods'), |
| 30 | + (18, 'Cost Functions'), |
| 31 | + (20, 'Price Elasticity of Demand and Revenue'), |
| 32 | + (21, 'Optimal Choice: Cost-Minimizing Production Inputs'), |
| 33 | + |
| 34 | + (22, 'Tax Rate and Revenue'), |
| 35 | + (23, 'Taxation in Linear Demand and Supply'), |
| 36 | + (24, 'Tax Supply and Demand vs. Tax Revenue'), |
| 37 | + |
| 38 | + (25, 'Linear Demand and Supply - Surplus Policies'), |
| 39 | + |
| 40 | + # Externalities |
| 41 | + (26, 'Negative Production Externality - Producer'), |
| 42 | + (27, 'Negative Production Externality - Industry'), |
| 43 | + (28, 'Positive Externality - Industry'), |
| 44 | +) |
| 45 | + |
| 46 | + |
| 47 | +class Graph(ABC): |
| 48 | + line_actions = [ |
| 49 | + 'up', |
| 50 | + 'down', |
| 51 | + 'slope up', |
| 52 | + 'slope down', |
| 53 | + ] |
| 54 | + variable_actions = [ |
| 55 | + 'up', |
| 56 | + 'down', |
| 57 | + '<exact value>', |
| 58 | + ] |
| 59 | + |
| 60 | + @classmethod |
| 61 | + def get_rule_options(cls) -> dict: |
| 62 | + return { |
| 63 | + 'line1': { |
| 64 | + 'name': 'Orange line', |
| 65 | + 'possible_values': cls.line_actions, |
| 66 | + }, |
| 67 | + |
| 68 | + 'line2': { |
| 69 | + 'name': 'Blue line', |
| 70 | + 'possible_values': cls.line_actions, |
| 71 | + }, |
| 72 | + |
| 73 | + 'line1 label': 'Orange line label', |
| 74 | + 'line2 label': 'Blue line label', |
| 75 | + 'intersectionLabel': 'Intersection label', |
| 76 | + 'intersectionHorizLineLabel': |
| 77 | + 'Orange-Blue intersection horizontal label', |
| 78 | + 'intersectionVertLineLabel': |
| 79 | + 'Orange-Blue intersection vertical label', |
| 80 | + 'x-axis label': 'X-axis label', |
| 81 | + 'y-axis label': 'Y-axis label', |
| 82 | + } |
| 83 | + |
| 84 | + |
| 85 | +class Graph0(Graph): |
| 86 | + name = GRAPH_TYPES[0][1] |
| 87 | + graph_type = 0 |
| 88 | + |
| 89 | + @classmethod |
| 90 | + def get_rule_options(cls) -> dict: |
| 91 | + return super().get_rule_options() |
| 92 | + |
| 93 | + |
| 94 | +class Graph1(Graph): |
| 95 | + name = GRAPH_TYPES[1][1] |
| 96 | + graph_type = 1 |
| 97 | + |
| 98 | + |
| 99 | +class Graph3(Graph): |
| 100 | + name = GRAPH_TYPES[2][1] |
| 101 | + graph_type = 3 |
| 102 | + |
| 103 | + |
| 104 | +class Graph5(Graph): |
| 105 | + name = GRAPH_TYPES[3][1] |
| 106 | + graph_type = 5 |
| 107 | + |
| 108 | + |
| 109 | +class Graph7(Graph): |
| 110 | + name = GRAPH_TYPES[4][1] |
| 111 | + graph_type = 7 |
0 commit comments