Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/update_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import tomllib
import os
import tomllib


def main():
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install:
pip install huggingface_hub

format:
ruff check . --fix
ruff format .

test:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/add-ruff-linting.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added ruff linting (ruff check) to Makefile format target with E, F, and I rule sets.
2 changes: 1 addition & 1 deletion docs/book/programs/contrib/ubi-center/carbon-tax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,8 @@
}
],
"source": [
"import plotly.express as px\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"\n",
"df = pd.DataFrame(\n",
" {\n",
Expand Down
1 change: 1 addition & 0 deletions docs/book/programs/gov/dcms/bbc/tv-licence.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
],
"source": [
"import pandas as pd\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"system = CountryTaxBenefitSystem()\n",
Expand Down
3 changes: 2 additions & 1 deletion docs/book/programs/gov/hmrc/child-benefit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@
}
],
"source": [
"from policyengine_uk import CountryTaxBenefitSystem\n",
"import pandas as pd\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"parameters = CountryTaxBenefitSystem().parameters\n",
"data = {\n",
" \"Date\": [],\n",
Expand Down
7 changes: 3 additions & 4 deletions docs/book/programs/gov/hmrc/fuel-duty.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@
}
],
"source": [
"from policyengine_uk import CountryTaxBenefitSystem\n",
"import plotly.express as px\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"system = CountryTaxBenefitSystem()\n",
"hmrc = system.parameters.gov.hmrc\n",
Expand Down Expand Up @@ -1053,8 +1054,6 @@
}
],
"source": [
"import plotly.express as px\n",
"\n",
"px.line(\n",
" df,\n",
" x=\"Date of change\",\n",
Expand Down
8 changes: 4 additions & 4 deletions docs/book/programs/gov/hmrc/income-tax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
],
"source": [
"import pandas as pd\n",
"\n",
"from policyengine_uk import Simulation\n",
"\n",
"\n",
Expand Down Expand Up @@ -515,9 +516,10 @@
}
],
"source": [
"from policyengine_uk.system import system\n",
"import pandas as pd\n",
"\n",
"from policyengine_uk.system import system\n",
"\n",
"default = system.parameters.gov.hmrc.income_tax.allowances.annual_allowance.default\n",
"minimum = system.parameters.gov.hmrc.income_tax.allowances.annual_allowance.minimum\n",
"reduction_rate = (\n",
Expand Down Expand Up @@ -5635,8 +5637,6 @@
}
],
"source": [
"from policyengine_uk import Simulation\n",
"\n",
"simulation = Simulation(\n",
" situation=dict(\n",
" people=dict(\n",
Expand All @@ -5658,8 +5658,8 @@
" ),\n",
")\n",
"\n",
"import plotly.express as px\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"from policyengine_core.charts import format_fig\n",
"\n",
"df = pd.DataFrame(\n",
Expand Down
5 changes: 2 additions & 3 deletions docs/book/programs/gov/hmrc/national-insurance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@
"source": [
"# @title\n",
"import pandas as pd\n",
"from tabulate import tabulate\n",
"\n",
"\n",
"data = {\n",
" \"Class\": [\"Class 1\", \"Class 2\", \"Class 4\"],\n",
Expand Down Expand Up @@ -1433,11 +1431,12 @@
}
],
"source": [
"from policyengine_uk.system import system\n",
"import plotly.express as px\n",
"from policyengine_core.charts import format_fig\n",
"from policyengine_core.parameters import Parameter\n",
"\n",
"from policyengine_uk.system import system\n",
"\n",
"ni = system.parameters.gov.hmrc.national_insurance\n",
"\n",
"threshold_parameters = [\n",
Expand Down
3 changes: 2 additions & 1 deletion docs/book/programs/gov/hmrc/stamp-duty.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7298,9 +7298,10 @@
}
],
"source": [
"from policyengine_uk.system import system\n",
"from policyengine_core.charts import format_fig\n",
"\n",
"from policyengine_uk.system import system\n",
"\n",
"sdlt = system.parameters.gov.hmrc.stamp_duty.statistics\n",
"stats = {\"Year\": [], \"Revenue (£m)\": [], \"Type\": []}\n",
"# residential corporate\n",
Expand Down
5 changes: 3 additions & 2 deletions docs/book/programs/gov/ofgem/energy-price-guarantee.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,10 @@
}
],
"source": [
"from policyengine_uk import CountryTaxBenefitSystem\n",
"import plotly.express as px\n",
"import pandas as pd\n",
"import plotly.express as px\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"system = CountryTaxBenefitSystem()\n",
"ofgem = system.parameters.gov.ofgem\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@
"import pandas as pd\n",
"import plotly.express as px\n",
"from policyengine_core.charts import format_fig\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"system = CountryTaxBenefitSystem()\n",
Expand Down
1 change: 1 addition & 0 deletions docs/book/programs/gov/wra/land-transaction-tax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@
"import pandas as pd\n",
"import plotly.express as px\n",
"from policyengine_core.charts import format_fig\n",
"\n",
"from policyengine_uk import CountryTaxBenefitSystem\n",
"\n",
"system = CountryTaxBenefitSystem()\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/book/validation/student-loan-repayments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"metadata": {},
"outputs": [],
"source": [
"from policyengine_uk import Microsimulation\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"from policyengine_uk import Microsimulation\n",
"\n",
"sim = Microsimulation()\n",
"year = 2025"
Expand Down
4 changes: 2 additions & 2 deletions docs/book/validation/validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1891,10 +1891,10 @@
" ]\n",
"\n",
"\n",
"from policyengine_core.parameters import get_parameter\n",
"from policyengine_uk.data.datasets.frs.calibration.loss import (\n",
" calibration_parameters,\n",
")\n",
"from policyengine_core.parameters import get_parameter\n",
"\n",
"\n",
"def official_estimate(parameter: str):\n",
Expand Down Expand Up @@ -2008,7 +2008,7 @@
" )\n",
"\n",
"import plotly.express as px\n",
"from policyengine_core.charts import format_fig, BLUE_COLOUR_SCALE, GRAY\n",
"from policyengine_core.charts import BLUE_COLOUR_SCALE, GRAY, format_fig\n",
"\n",
"fig = (\n",
" px.bar(\n",
Expand Down
3 changes: 2 additions & 1 deletion policyengine_uk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

from policyengine_uk import entities
from policyengine_uk.system import (
COUNTRY_DIR,
CountryTaxBenefitSystem,
Microsimulation,
Simulation,
COUNTRY_DIR,
parameters,
variables,
)

from .model_api import *

REPO = Path(__file__).parent
1 change: 1 addition & 0 deletions policyengine_uk/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
UKMultiYearDataset,
UKSingleYearDataset,
)

from .filter_dataset import filter_dataset
6 changes: 4 additions & 2 deletions policyengine_uk/data/dataset_schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import pandas as pd
import numpy as np
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd

if TYPE_CHECKING:
from policyengine_uk import Microsimulation

from pathlib import Path

import h5py


Expand Down
10 changes: 5 additions & 5 deletions policyengine_uk/data/economic_assumptions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from policyengine_uk.data import UKMultiYearDataset, UKSingleYearDataset
import logging
from pathlib import Path

import numpy as np
import yaml
from policyengine_core.parameters import ParameterNode
from pathlib import Path
import numpy as np
import logging

from policyengine_uk.data import UKMultiYearDataset, UKSingleYearDataset

# Base year for the FRS dataset - used to calculate age offsets
_FRS_BASE_YEAR = 2023 # FRS 2023-24 represents calendar year 2024
Expand Down Expand Up @@ -55,7 +56,6 @@ def apply_uprating(
dataset: UKMultiYearDataset,
tax_benefit_system_parameters: ParameterNode = None,
):
from policyengine_uk.system import system

# Apply uprating to the dataset.
dataset = dataset.copy()
Expand Down
1 change: 0 additions & 1 deletion policyengine_uk/data/filter_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def filter_dataset(
sim: "Microsimulation", household_id: int, year: int = 2026
) -> "UKSingleYearDataset":
from policyengine_uk import Microsimulation
from policyengine_uk.data import UKSingleYearDataset

"""
Expand Down
15 changes: 7 additions & 8 deletions policyengine_uk/dynamics/labour_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
Reference: https://obr.uk/docs/dlm_uploads/NICS-Cut-Impact-on-Labour-Supply-Note.pdf
"""

from typing import Optional

import numpy as np
import pandas as pd
from policyengine_uk import Simulation
from microdf import MicroDataFrame
from pydantic import BaseModel
from typing import Optional

from policyengine_uk import Simulation

from .progression import (
calculate_derivative_change,
calculate_relative_income_change,
calculate_labour_substitution_elasticities,
calculate_labour_net_income_elasticities,
calculate_employment_income_change,
)
from .participation import (
apply_participation_responses,
calculate_labour_net_income_elasticities,
calculate_labour_substitution_elasticities,
calculate_relative_income_change,
)


Expand Down
2 changes: 1 addition & 1 deletion policyengine_uk/dynamics/participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import numpy as np
import pandas as pd

from policyengine_uk import Simulation
import warnings


def calculate_participation_elasticities(
Expand Down
1 change: 1 addition & 0 deletions policyengine_uk/dynamics/progression.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy as np
import pandas as pd

from policyengine_uk import Simulation


Expand Down
4 changes: 1 addition & 3 deletions policyengine_uk/model_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from policyengine_core.model_api import *

from policyengine_uk.entities import *
from policyengine_core import periods
from microdf import MicroSeries, MicroDataFrame
from policyengine_uk.utils.scenario import Scenario

GBP = "currency-GBP"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from policyengine_core.parameters import (
ParameterNode,
Parameter,
ParameterNode,
)

YEARS = list(range(2020, 2035))
Expand Down
3 changes: 2 additions & 1 deletion policyengine_uk/parameters/gov/dwp/LHA/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pandas as pd
from pathlib import Path

import pandas as pd

lha_list_of_rents = pd.read_csv(Path(__file__).parent / "lha_list_of_rents.csv.gz")
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from policyengine_core.parameters import (
ParameterNode,
Parameter,
get_parameter,
ParameterNode,
)

YEARS = list(range(2022, 2035))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from policyengine_core.parameters import (
ParameterNode,
Parameter,
get_parameter,
ParameterNode,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import argparse
import re
from datetime import date
from calendar import isleap
from datetime import date
from pathlib import Path

import yaml
Expand Down
3 changes: 2 additions & 1 deletion policyengine_uk/reforms/cps/marriage_tax_reforms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

from policyengine_uk.model_api import *
from typing import Union, Optional


def create_expanded_ma_reform(
Expand Down
Loading
Loading