Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to deprecated commands #396

Merged
merged 9 commits into from
Sep 21, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/create_pip_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: "3.12"
- name: Build package
run: make pip-package
- name: Publish a Python distribution to PyPI
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ Results will change as the underlying models improve. A fundamental reason for a


## Citing the Cost-of-Capital-Calculator Model
Cost-of-Capital-Calculator (Version 1.5.1)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator
Cost-of-Capital-Calculator (Version 1.5.2)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator
2 changes: 1 addition & 1 deletion ccc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from ccc.data import *
from ccc.calculator import *

__version__ = "1.5.1"
__version__ = "1.5.2"
19 changes: 11 additions & 8 deletions ccc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from ccc.constants import TAX_METHODS, RE_ASSETS, RE_INDUSTRIES
from ccc.utils import str_modified

pd.set_option("future.no_silent_downcasting", True)

ENFORCE_CHECKS = True


Expand Down Expand Up @@ -42,14 +40,19 @@ def update_depr_methods(df, p, dp):
deprec_df, how="left", left_on="bea_asset_code", right_on="BEA_code"
)
# add bonus depreciation to tax deprec parameters dataframe
# ** UPDATE THIS - maybe including bonus in new asset deprec JSON**
df["bonus"] = df["GDS_life"].apply(str_modified)
df["bonus"] = df["GDS_life"]
# update tax_deprec_rates based on user defined parameters
df.replace({"bonus": p.bonus_deprec}, inplace=True)
# make bonus float format
df["bonus"] = df["bonus"].astype(float)
# Compute b
df["b"] = df["method"]
df.replace({"b": TAX_METHODS}, regex=True, inplace=True)
# use b value of 1 if method is not in TAX_METHODS
# NOTE: not sure why the replae method doesn't work for this method
# Related: had to comment this out in TAX_METHODS
df.loc[df["b"] == "Income Forecast", "b"] = 1.0
# cast b as float
df["b"] = df["b"].astype(float)

df.loc[df["system"] == "ADS", "Y"] = df.loc[
df["system"] == "ADS", "ADS_life"
]
Expand Down Expand Up @@ -142,9 +145,9 @@ def econ(delta, bonus, r, pi):

def income_forecast(Y, delta, bonus, r):
r"""
Makes the calculation for the income forecast method.
Makes the calculation for the Income Forecast method.

The income forecast method involved deducting expenses in relation
The Income Forecast method involved deducting expenses in relation
to forecasted income over the next 10 years. CCC follows the CBO
methodology (CBO, 2018:
https://www.cbo.gov/system/files/2018-11/54648-Intangible_Assets.pdf)
Expand Down
4 changes: 0 additions & 4 deletions ccc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,14 +2000,10 @@ def asset_bubble(
}

equipment_df["short_category"] = equipment_df["minor_asset_group"]
# equipment_df['short_category'].replace(make_short,
# inplace=True)
equipment_df.replace(
{"short_category": make_short}, regex=True, inplace=True
)
structure_df["short_category"] = structure_df["minor_asset_group"]
# structure_df['short_category'].replace(make_short,
# inplace=True)
structure_df.replace(
{"short_category": make_short}, regex=True, inplace=True
)
Expand Down
2 changes: 1 addition & 1 deletion ccc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"SL": 1.0,
"Economic": 1.0,
"Expensing": 1.0,
"Income Forecast": 1.0,
# "Income Forecast": 1.0,
}

MINOR_ASSET_GROUPS = dict.fromkeys(
Expand Down
6 changes: 3 additions & 3 deletions ccc/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ def compute_default_params(self):
(str(i) if i != 27.5 else "27_5") for i in class_list
]
self.bonus_deprec = {}
for cl in class_list_str:
self.bonus_deprec[cl] = getattr(
for i, cl in enumerate(class_list_str):
self.bonus_deprec[class_list[i]] = getattr(
self, "BonusDeprec_{}yr".format(cl)
)[0]
# to handle land and inventories
# this is fixed later, but should work on this
self.bonus_deprec["100"] = 0.0
self.bonus_deprec[100] = 0.0

def default_parameters(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion ccc/tests/test_start_years.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def test_params_start_year(year, expected_values):
"""
p = Specification(year=year)
assert np.allclose(p.u["c"], expected_values[0])
assert np.allclose(p.bonus_deprec["3"], expected_values[1])
assert np.allclose(p.bonus_deprec[3], expected_values[1])
assert np.allclose(p.phi, expected_values[2])
23 changes: 5 additions & 18 deletions ccc/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
import importlib.resources as pkg_resources
from collections import OrderedDict
import warnings
import numbers
Expand Down Expand Up @@ -119,15 +119,9 @@ def read_egg_csv(fname, index_col=None):
Returns:
vdf (Pandas DataFrame): data from csv file
"""
# try:
path_in_egg = os.path.join(PACKAGE_NAME, fname)
try:
vdf = pd.read_csv(
pkg_resources.resource_stream(
pkg_resources.Requirement.parse(PYPI_PACKAGE_NAME), path_in_egg
),
index_col=index_col,
)
with pkg_resources.open_text(PACKAGE_NAME, fname) as file:
vdf = pd.read_csv(file, index_col=index_col)
except Exception:
raise ValueError("could not read {} data from egg".format(fname))
# cannot call read_egg_ function in unit tests
Expand All @@ -147,15 +141,8 @@ def read_egg_json(fname):

"""
try:
path_in_egg = os.path.join(PACKAGE_NAME, fname)
pdict = json.loads(
pkg_resources.resource_stream(
pkg_resources.Requirement.parse(PYPI_PACKAGE_NAME), path_in_egg
)
.read()
.decode("utf-8"),
object_pairs_hook=OrderedDict,
)
with pkg_resources.open_text(PACKAGE_NAME, fname) as file:
pdict = json.loads(file.read(), object_pairs_hook=OrderedDict)
except Exception:
raise ValueError("could not read {} data from egg".format(fname))
# cannot call read_egg_ function in unit tests
Expand Down
2 changes: 1 addition & 1 deletion docs/book/content/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Results will change as the underlying models improve. A fundamental reason for a


## Citing the Cost-of-Capital-Calculator Model
Cost-of-Capital-Calculator (Version 1.5.1)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator
Cost-of-Capital-Calculator (Version 1.5.2)[Source code], https://github.com/PSLmodels/Cost-of-Capital-Calculator
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
download_url="https://github.com/PSLmodels/Cost-of-Capital-Calculator",
long_description_content_type="text/markdown",
long_description=longdesc,
version="1.5.1",
version="1.5.2",
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
packages=["ccc"],
include_package_data=True,
Expand Down
Loading