Skip to content

Commit

Permalink
Code and environment cleanup, cached data loading and dynamic geojson…
Browse files Browse the repository at this point in the history
… parsing
  • Loading branch information
bainmatt committed Dec 9, 2024
1 parent 7ab05df commit 168a7ac
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 302 deletions.
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ ignore =
; line break after binary operator
W504
exclude =
src/archive/*
; src/analysis.py
src/archive/*
8 changes: 1 addition & 7 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ warn_unused_configs = True
disallow_any_generics = True
warn_return_any = True
warn_unreachable = True
; Pydantic integration
; https://docs.pydantic.dev/latest/integrations/mypy/
; plugins =
; pydantic.mypy

; Do not type-check the specified subpkgs/modules
; Inline silencing of specific errors:
; https://mypy.readthedocs.io/en/stable/error_codes.html

; Exclude specific files or directories
exclude = (?x)(
; analysis.py
; | archive/.*
archive/.*
; | colors.py
)
7 changes: 0 additions & 7 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ website:
search: false
navbar:
title: false
# background: "#eee"
left:
- href: notebooks/report.ipynb
text: "Report"
# - href: notebooks/sql_qs.ipynb
# text: "SQL exercises"
page-footer:
center:
- href: https://bainmatt.github.io/
Expand All @@ -29,7 +26,3 @@ website:
format:
html:
theme: ember
# css: styles.css
# theme:
# light: flatly
# dark: darkly
57 changes: 12 additions & 45 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
# (2.0) $ conda activate {name}
#
# This env was pointed to, created and activated on, an external drive by:
#
#
# (0.0) $ conda config --append envs_dirs /Volumes/Samsung_T5/conda-environments
# (1.0) $ conda env create --prefix /Volumes/Samsung_T5/conda-environments/streamlit-geomaps --file environment.yml
# (2.1) $ conda deactivate
# (2.2) $ conda activate /Volumes/Samsung_T5/conda-environments/streamlit-geomaps
# (2.3) <setting the vscode interpreter to that of the same environment>
# (3.0) <setting '.env' `PYTHONPATH` variable to .:/Volumes/Samsung_T5/conda-environments/streamlit-geomaps/lib/python3.11/site-packages
#
#
# To check that the environment has been successfully activated (has *):
#
# (0.0) $ conda info --envs
#
#
# (0.1) $ conda config --show envs_dirs
# (0.2) $ conda info --envs
#

name: streamlit-geomaps
prefix: /Volumes/Samsung_T5/conda-environments/streamlit-geomaps
Expand All @@ -29,59 +30,25 @@ dependencies:
- pip>=19.0
- jupyter
- pandas
- numpy
- requests
- python-dotenv
# - gdown

# Dataviz
- matplotlib
- seaborn
- plotly
- geopandas
- geopy
# - geopy
- geojson
- seaborn

# Stats
# - scikit-learn
# - scipy
# - statsmodels
# - arviz

# ETL
- requests
- gdown
# - pydantic
# - bs4
# - mysql

# Ensures pycurl and wptools are installed correctly
# - openssl
# - pycurl

# Secure API key retrieval
- python-dotenv
- scipy

- pip:
# Stats
# - bambi

# Tables
# - great-tables
# - polars
# - pyarrow
# - tabulate

# Dashboards
- streamlit

# EDA
# - holidays

# SQL
# - mysql
# - mysqlclient
# - mysql-connector-python
# - PyMySQL
# - jsonschema

# Typing / testing / linting
# run `mypy --install-types` to install missing stubs. Pandas given below.
- mypy
Expand Down
16 changes: 2 additions & 14 deletions notebooks/report.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"#| code-fold: true\n",
"\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from IPython.display import display as display3\n",
"\n",
"from src.paths import get_path_to\n",
Expand All @@ -81,24 +80,18 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| include: false\n",
"\n",
"customize_plots()\n",
"%config InlineBackend.figure_format = 'svg'\n",
"# plt.style.use(\"_matplotlibrc\")\n",
"\n",
"import plotly.io as pio\n",
"pio.renderers.default = \"notebook\"\n",
"# pio.renderers.default = \"plotly_mimetype+notebook_connected\"\n",
"\n",
"# pd.set_option('display.expand_frame_repr', False)\n",
"# pd.set_option('display.max_columns', 8, 'display.max_colwidth', 30)\n",
"# pd.reset_option('display.max_columns')\n",
"# pd.reset_option('display.max_colwidth')"
"# pio.renderers.default = \"plotly_mimetype+notebook_connected\""
]
},
{
Expand All @@ -120,11 +113,6 @@
"#| code-summary: Load\n",
"\n",
"if 'data' not in locals():\n",
" # data = pd.read_csv(\n",
" # get_path_to(\"data\", \"raw\", \"\"),\n",
" # encoding='ISO-8859-1',\n",
" # low_memory=False\n",
" # )\n",
" pass\n",
"else:\n",
" print(\"data loaded.\")"
Expand Down
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[pytest]
pythonpath = src
; minversion = "6.0"
; addopts = -q
addopts = -ra -vv --ignore=src/app.py --ignore-glob=*/archive/*
testpaths =
tests
Expand Down
22 changes: 8 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
jupyter>=1.1.1
requests>=2.32.3
python-dotenv>=1.0.1
pandas>=2.2.3

numpy>=1.24.2
scipy>=1.9.3
pandas>=2.0.0

matplotlib>=3.6.2
seaborn>=0.12.1
matplotlib>=3.9.3
plotly>=5.24.1
geopandas>=0.12.1
geopy>=2.4.1
geopandas>=1.0.1
# geopy>=2.4.1
geojson>=3.1.0
seaborn>=0.13.2
streamlit>=1.40.2
gdown>=5.2.0

# great-tables>=0.11.1
# polars>=0.14.28
# pyarrow>=17.0.0
scipy>=1.14.1
# gdown>=5.2.0

mypy>=1.13.0
typing_extensions>=4.12.2
pandas-stubs>=2.2.3.241126
types-requests>=2.32.0.20241016
pytest>=8.3.4
coverage>=7.6.8
coverage>=7.6.9
flake8>=7.1.1
12 changes: 0 additions & 12 deletions src/analysis.py

This file was deleted.

Loading

0 comments on commit 168a7ac

Please sign in to comment.