Skip to content

Commit

Permalink
refactor: bump up version / fix import modules / add test
Browse files Browse the repository at this point in the history
  • Loading branch information
philsv committed Jan 24, 2023
1 parent f49ef28 commit a97e545
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.pytest.ini_options]
pythonpath = [
".", "src", "tests", "src",
]
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import setuptools
from src.version import __version__

with open("README.md", "r") as ld:
long_description = ld.read()

setuptools.setup(
name="myeia",
version="0.2.0",
version=__version__,
url="https://github.com/philsv/myeia",
license="MIT",
author="philsv",
Expand Down
18 changes: 2 additions & 16 deletions src/myeia.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import pandas as pd
import requests
from dotenv import load_dotenv
from pandas.core.common import SettingWithCopyWarning

warnings.simplefilter(action="ignore", category=SettingWithCopyWarning)
warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)
load_dotenv()


Expand Down Expand Up @@ -37,9 +36,7 @@ def get_data(
"Accept": "*/*",
}

api_route = (
f"{route}/data/?api_key={self.token}&data[]=value&frequency={frequency}"
)
api_route = f"{route}/data/?api_key={self.token}&data[]=value&frequency={frequency}"

series = f"&facets[{facet}][]={series}"

Expand Down Expand Up @@ -73,15 +70,4 @@ def get_data(
df.rename(columns={df.columns[0]: "Date"}, inplace=True)
df["Date"] = pd.to_datetime(df["Date"])
df.set_index("Date", inplace=True)

return df


# if __name__ == "__main__":

# # Example
# eia = API()
# df = eia.get_data(
# route="steo", series="PAPR_OPEC", frequency="monthly", facet="seriesId"
# )
# print(df.head())
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0"
__version__ = "0.2.1"
9 changes: 9 additions & 0 deletions tests/test_myeia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pandas as pd

from src import myeia


def test_get_data():
eia = myeia.API()
df = eia.get_data(route="natural-gas/pri/fut", series="RNGC1", frequency="daily")
assert isinstance(df, pd.DataFrame)

0 comments on commit a97e545

Please sign in to comment.