Skip to content

Commit

Permalink
Updates requirements (#50)
Browse files Browse the repository at this point in the history
* installs data before running tests

* no install data before tests

* removes psycopg2 dependency

* updates statcast tests

* formatting
  • Loading branch information
bdilday authored Sep 4, 2020
1 parent 4a30113 commit 759eb6f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ install-dev:
pip install --quiet -r requirements-dev.txt

install: install-dev
pip install -e .
pip install .
6 changes: 4 additions & 2 deletions pybbda/data/sources/fangraphs/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ def _pool_park_factors_update(overwrite=False, season_root=None):
overwrite=overwrite,
)
else:
logger.info(f"handedness park factors not available for pre-2002 seasons. "
f"skipping {season}")
logger.info(
f"handedness park factors not available for pre-2002 seasons. "
f"skipping {season}"
)


def _pool_do_update(overwrite=False, season_stats=None):
Expand Down
10 changes: 0 additions & 10 deletions pybbda/data/sources/retrosheet/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import psycopg2
import pandas as pd
import logging
import glob
Expand Down Expand Up @@ -36,15 +35,6 @@ def __init__(self, data_root=None):
self._engine = None
self.chadwick = Chadwick()

def _connect_to_postgres(self, database="retrosheet"):
conn = psycopg2.connect(
database=database,
user=os.environ["PSQL_USER"],
password=os.environ["PSQL_PASS"],
port=os.environ["PSQL_PORT"],
)
return conn

def create_database(self):
if not os.path.exists(self.db_dir):
os.makedirs(self.db_dir, exist_ok=True)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ lxml~=4.5.0
numpy~=1.18.1
pandas~=1.0.4
requests~=2.22.0
psycopg2~=2.8.4
scipy~=1.4.1
sqlalchemy~=1.3.13
tqdm~=4.46.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def baseball_ref_data():
def test_war_bat(baseball_ref_data):
war_bat = baseball_ref_data.war_bat
assert war_bat.year_ID.min() == 1871
assert war_bat.year_ID.max() == 2019
assert war_bat.year_ID.max() == 2020


def test_war_pitch(baseball_ref_data):
war_pitch = baseball_ref_data.war_pitch
assert war_pitch.year_ID.min() == 1871
assert war_pitch.year_ID.max() == 2019
assert war_pitch.year_ID.max() == 2020


def test_missing_path(baseball_ref_data):
Expand Down
8 changes: 6 additions & 2 deletions tests/data/test_statcast/test_statcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ def test_statcast_validate_player_type(statcast_data):

def test_statcast_batter_data(statcast_data):
df = statcast_data.sc_2019_05_01
mean_ls = df.query('player_name == "Jose Abreu"').loc[:, "launch_speed"].mean()
assert mean_ls == pytest.approx(90.8, 0.01)
mean_ls = (
df.query('player_name == "Jose Abreu" and description != "foul"')
.loc[:, "launch_speed"]
.mean()
)
assert mean_ls == pytest.approx(102.05, 0.01)

0 comments on commit 759eb6f

Please sign in to comment.