mirror of
https://github.com/PR0M3TH3AN/python_charts.git
synced 2026-10-28 17:30:41 +00:00
Merge pull request #32 from PR0M3TH3AN/codex/update-makefile-targets
Update Makefile and fix distutils dependency
This commit is contained in:
2 files changed
+48
-4
No files matched your search
@@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
# Install dependencies & fetch data
|
# Install dependencies & fetch data
|
||||||
install:
|
install:
|
||||||
./startup.sh
|
./startup.sh lagged_oil_unrate
|
||||||
|
|
||||||
# Download FRED data (if needed)
|
# Download FRED data (if needed)
|
||||||
data:
|
data:
|
||||||
./startup.sh scripts/refresh_data.py
|
./startup.sh refresh_data
|
||||||
|
|
||||||
# Default 18-month lag plot
|
# Default 18-month lag plot
|
||||||
plot:
|
plot:
|
||||||
./startup.sh
|
./startup.sh lagged_oil_unrate
|
||||||
|
|
||||||
# Custom plot of arbitrary series
|
# Custom plot of arbitrary series
|
||||||
# Usage: make plot-custom ARGS="--series UNRATE CPIAUCSL --start 2000-01-01"
|
# Usage: make plot-custom ARGS="--series UNRATE CPIAUCSL --start 2000-01-01"
|
||||||
plot-custom:
|
plot-custom:
|
||||||
./startup.sh python scripts/custom_chart.py $(ARGS)
|
./startup.sh custom_chart $(ARGS)
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -20,6 +20,50 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# pandas_datareader < 0.11 requires distutils, which was removed in Python 3.12
|
||||||
|
try: # pragma: no cover - prefer stdlib when available
|
||||||
|
from distutils.version import LooseVersion # type: ignore
|
||||||
|
except ModuleNotFoundError: # pragma: no cover - Python >=3.12
|
||||||
|
from packaging.version import Version
|
||||||
|
import types, sys
|
||||||
|
|
||||||
|
class LooseVersion:
|
||||||
|
def __init__(self, v: str | int) -> None:
|
||||||
|
self.vstring = str(v)
|
||||||
|
self.version = Version(self.vstring)
|
||||||
|
|
||||||
|
def __repr__(self) -> str: # pragma: no cover - debug helper
|
||||||
|
return f"LooseVersion('{self.vstring}')"
|
||||||
|
|
||||||
|
def __lt__(self, other: "LooseVersion") -> bool:
|
||||||
|
return self.version < other.version
|
||||||
|
|
||||||
|
def __le__(self, other: "LooseVersion") -> bool:
|
||||||
|
return self.version <= other.version
|
||||||
|
|
||||||
|
def __eq__(self, other: object) -> bool:
|
||||||
|
if not isinstance(other, LooseVersion):
|
||||||
|
return NotImplemented
|
||||||
|
return self.version == other.version
|
||||||
|
|
||||||
|
def __ne__(self, other: object) -> bool: # pragma: no cover - unused
|
||||||
|
if not isinstance(other, LooseVersion):
|
||||||
|
return NotImplemented
|
||||||
|
return self.version != other.version
|
||||||
|
|
||||||
|
def __gt__(self, other: "LooseVersion") -> bool:
|
||||||
|
return self.version > other.version
|
||||||
|
|
||||||
|
def __ge__(self, other: "LooseVersion") -> bool:
|
||||||
|
return self.version >= other.version
|
||||||
|
|
||||||
|
version_module = types.ModuleType("version")
|
||||||
|
version_module.LooseVersion = LooseVersion
|
||||||
|
distutils_module = types.ModuleType("distutils")
|
||||||
|
distutils_module.version = version_module
|
||||||
|
sys.modules.setdefault("distutils", distutils_module)
|
||||||
|
sys.modules.setdefault("distutils.version", version_module)
|
||||||
|
|
||||||
from pandas_datareader.data import DataReader
|
from pandas_datareader.data import DataReader
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user