Skip to content

Commit 6fbcef7

Browse files
committed
moved to uv from conda
1 parent 03a3f9d commit 6fbcef7

13 files changed

Lines changed: 4607 additions & 121 deletions

File tree

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
validate:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up uv
20+
uses: astral-sh/setup-uv@v7
21+
with:
22+
python-version: "3.12"
23+
enable-cache: true
24+
25+
- name: Install dependencies
26+
run: uv sync --extra notebooks --group docs --frozen
27+
28+
- name: Build package
29+
run: uv build
30+
31+
- name: Smoke test package imports
32+
run: |
33+
uv run python - <<'PY'
34+
import tsa_course.lecture1
35+
import tsa_course.lecture2
36+
import tsa_course.lecture8
37+
import tsa_course.lecture11
38+
PY
39+
40+
- name: Build Jupyter Book
41+
run: uv run --extra notebooks --group docs jupyter-book build . --builder html

.github/workflows/deploy-book.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,38 @@ concurrency:
1616
jobs:
1717
deploy:
1818
runs-on: ubuntu-latest
19-
defaults:
20-
run:
21-
shell: bash -el {0}
2219
steps:
2320
- name: Checkout repository
2421
uses: actions/checkout@v4
2522

26-
- name: Set up Conda environment
27-
uses: conda-incubator/setup-miniconda@v3
23+
- name: Set up uv
24+
uses: astral-sh/setup-uv@v7
2825
with:
29-
activate-environment: pytsa
30-
environment-file: env.yml
31-
auto-activate-base: false
26+
python-version: "3.12"
27+
enable-cache: true
3228

33-
- name: Install build tools
34-
run: |
35-
python -m pip install --upgrade pip
36-
pip install "jupyter-book<2" ghp-import
29+
- name: Install dependencies
30+
run: uv sync --extra notebooks --group docs --group deploy --frozen
31+
32+
- name: Build package
33+
run: uv build
3734

38-
- name: Show tool versions
35+
- name: Smoke test package imports
3936
run: |
40-
jupyter-book --version
41-
ghp-import --version
37+
uv run python - <<'PY'
38+
import tsa_course.lecture1
39+
import tsa_course.lecture2
40+
import tsa_course.lecture8
41+
import tsa_course.lecture11
42+
PY
4243
4344
- name: Build Jupyter Book
44-
run: jupyter-book build . --builder html
45+
run: uv run --extra notebooks --group docs jupyter-book build . --builder html
4546

4647
- name: Verify build output
4748
run: |
4849
test -d _build/html
4950
ls -la _build/html | head -n 20
5051
5152
- name: Deploy to GitHub Pages
52-
run: ghp-import -n -p -f _build/html
53+
run: uv run --group deploy ghp-import -n -p -f _build/html

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

README.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,48 @@ You can view and execute the notebooks by clicking on the buttons below.
158158

159159
To run the notebooks locally the recommended steps are the following:
160160

161-
1. Download and install [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html).
161+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/).
162162

163-
2. Download the [env.yml](https://github.com/FilippoMB/python-time-series-handbook/blob/main/env.yml) file.
163+
2. Clone the repository:
164164

165-
3. Open the shell and navigate to the location with the `yml` file you just downloaded.
166-
- If you are on Windows, open the Miniconda shell.
167-
168-
4. Install the environment with
169-
```{bash}
170-
> conda env create -f env.yml
165+
```bash
166+
git clone https://github.com/FilippoMB/python-time-series-handbook.git
167+
cd python-time-series-handbook
171168
```
172169

173-
5. Activate your environment:
174-
```{bash}
175-
> conda activate pytsa
170+
3. Create the environment and install all dependencies:
171+
172+
```bash
173+
uv sync --extra notebooks
176174
```
177175

178-
6. Go to the folder with the notebooks
176+
4. Launch Jupyter Lab:
179177

180-
7. Launch Jupyter Lab with the command
181-
```{bash}
182-
> jupyter lab
178+
```bash
179+
uv run jupyter lab
183180
```
184181

182+
## 🛠 Build the book locally
183+
184+
To build the Jupyter Book locally, install the notebook dependencies together with the docs tooling:
185+
186+
```bash
187+
uv sync --extra notebooks --group docs
188+
uv run --extra notebooks --group docs jupyter-book build . --builder html
189+
```
190+
191+
The build output will be written to `_build/html`.
192+
193+
## 📦 Build the package
194+
195+
To build the Python package artifacts:
196+
197+
```bash
198+
uv build
199+
```
200+
201+
This produces a wheel and a source distribution in `dist/`.
202+
185203
## 🎥 Notebook format and slides
186204

187205
The notebooks are structured as a sequence of slides to be presented using [RISE](https://rise.readthedocs.io/en/latest/).
@@ -203,12 +221,12 @@ See the [RISE documentation](https://rise.readthedocs.io/en/latest/) for more in
203221

204222
If you are using this material in your courses or in your research, please consider citing it as follows:
205223

206-
````bibtex
224+
```bibtex
207225
@misc{bianchi2024tsbook,
208226
author = {Filippo Maria Bianchi},
209227
title = {Time Series Analysis with Python},
210228
year = {2024},
211229
howpublished = {Online},
212230
url = {https://github.com/FilippoMB/python-time-series-handbook}
213231
}
214-
````
232+
```

_config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ html:
2525
use_repository_button: true
2626
favicon : "logo.png"
2727

28+
exclude_patterns:
29+
- _build
30+
- README.md
31+
- .venv
32+
- .venv/**
33+
- build
34+
- build/**
35+
- dist
36+
- dist/**
37+
- .DS_Store
38+
- Thumbs.db
39+
2840
parse:
2941
myst_enable_extensions:
3042
# Defaults here: https://jupyterbook.org/en/stable/customize/config.html

env.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

notebooks/00/intro.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Time series analysis is a crucial discipline in data science, offering insights
1111
:width: 500px
1212
:align: center
1313
```
14+
1415
The course is designed to combine high-level theoretical knowledge with practical programming skills. Each chapter introduces key concepts of time series analysis, followed by hands-on coding sections. This structure allows you to immediately apply the theoretical concepts you learn, seeing first-hand how these translate into functional tools in data analytics. Through this process, you will gain both the knowledge to understand complex time series data and the skills to analyze and predict it effectively.
1516
To reinforce learning and encourage active engagement, each chapter concludes with exercises. These are designed to test your understanding and help you apply the lessons in practical contexts.
1617

1718
Whether you are new to time series analysis or looking to refine your expertise, this course offers a broad exploration of the field, with Python as your toolkit. I hope that you will find this material both educational and entertaining, brining you a step closer to mastering time series analysis.
1819

19-
2020
## 📖 Chapters
2121

2222
The course is organized into the following chapters.
@@ -34,7 +34,6 @@ For this reason, the text in the notebooks is organized with bullet points.
3434

3535
These notebooks are currently adopted in [STA-2003 Tidsrekker](https://sa.uit.no/utdanning/emner/emne?p_document_id=822793) at UiT the Arctic University of Tromsø and [062785 - Time Series Analysis](https://www11.ceda.polimi.it/schedaincarico/schedaincarico/controller/scheda_pubblica/SchedaPublic.do?&evn_default=evento&c_classe=843368&lang=IT&__pj0=0&__pj1=2ad8b3dba5bb35c2b94e513147e1e84e) at Polytechnic of Milan.
3636

37-
3837
## 🚀 Getting started with coding
3938

4039
You can read from here all the content of the course. However, to get your hands-on experience with coding you want to run the code snippets or the whole notebooks that you can download on <a href="https://github.com/FilippoMB/python-time-series-handbook" target="_blank">
@@ -43,30 +42,26 @@ You can read from here all the content of the course. However, to get your hands
4342

4443
To run the code and the notebooks the recommended steps are the following:
4544

46-
1. Download and install [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html).
47-
48-
2. Download the [env.yml](https://github.com/FilippoMB/python-time-series-handbook/blob/main/env.yml) file.
45+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/).
4946

50-
3. Open the shell and navigate to the location with the yml file you just downloaded.
51-
- If you are on Windows, open the Miniconda shell.
47+
2. Clone the repository:
5248

53-
4. Install the environment with
54-
```
55-
> conda env create -f env.yml
49+
```bash
50+
git clone https://github.com/FilippoMB/python-time-series-handbook.git
51+
cd python-time-series-handbook
5652
```
5753

58-
5. Activate your environment:
59-
```
60-
> conda activate pytsa
54+
3. Create the environment and install all dependencies:
55+
56+
```bash
57+
uv sync --extra notebooks
6158
```
6259

63-
6. Go to the folder with the notebooks
60+
4. Launch Jupyter Lab:
6461

65-
7. Launch Jupyter Lab with the command
62+
```bash
63+
uv run jupyter lab
6664
```
67-
> jupyter lab
68-
```
69-
7065

7166
## ⚒ Roadmap
7267

@@ -81,29 +76,29 @@ If there is a specific topic you feel is missing or passages that you feel are n
8176

8277
For the moment, I intentionally decided to leave more advanced deep learning techniques aside. There are a couple of reasons for this choice. Firstly, advanced deep learning methods rely heavily on specific knowledge and tools that are generally covered in specialized deep learning courses. This focus does not align with the introductory nature of this course, which is aimed at covering the fundamentals of time series analysis.
8378

84-
Secondly, while deep learning opens up exciting avenues for new applications—such as NLP and analysis of video and spatio-temporal data—it primarily enhances capabilities in handling diverse data types and scaling to large datasets. However, for the core objectives of this course, which are to understand and manipulate time series data effectively, the advantages of moving from the basic neural networks introduced here to more complex deep learning models do not significantly alter the fundamental approach.
85-
79+
Secondly, while deep learning opens up exciting avenues for new applications—such as NLP and analysis of video and spatio-temporal data—it primarily enhances capabilities in handling diverse data types and scaling to large datasets. However, for the core objectives of this course, which are to understand and manipulate time series data effectively, the advantages of moving from the basic neural networks introduced here to more complex deep learning models do not significantly alter the fundamental approach.
8680

8781
## 🤝 Contributing
8882

89-
Time series analysis with Python is designed with accessibility in mind. The material is completely open-sourced and uses only free software, based in Python.
83+
Time series analysis with Python is designed with accessibility in mind. The material is completely open-sourced and uses only free software, based in Python.
9084
You can contribute both by adding new material, fixing typos, and suggesting edits. To do that,
9185
<a class="github-button" href="https://github.com/FilippoMB/python-time-series-handbook/fork" data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-repo-forked" aria-label="Fork FilippoMB/python-time-series-handbook on GitHub">Fork</a> the Github repository and submit a pull request.
9286

87+
If you want to build the Jupyter Book itself or package the `tsa-course` library, the repository README contains the additional contributor commands.
88+
9389
Finally, if you liked this content, please share it with others who might find it useful and give it a
9490
<a class="github-button" href="https://github.com/FilippoMB/python-time-series-handbook" data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-star" aria-label="Star FilippoMB/python-time-series-handbook on GitHub">Star</a> on GitHub.
9591

96-
9792
## 📝 Citation
9893

9994
If you are using this material in your courses or in your research, please consider citing it as follows:
10095

101-
````bibtex
96+
```bibtex
10297
@misc{bianchi2024tsbook,
10398
author = {Filippo Maria Bianchi},
10499
title = {Time Series Analysis with Python},
105100
year = {2024},
106101
howpublished = {Online},
107102
url = {https://github.com/FilippoMB/python-time-series-handbook}
108103
}
109-
````
104+
```

notebooks/05/arma_arima_sarima.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@
858858
"outputs": [],
859859
"source": [
860860
"# Generate synthetic time series data\n",
861-
"dates = pd.date_range(start='2010-01-01', periods=60, freq='M') # Monthly data for 5 years\n",
861+
"dates = pd.date_range(start='2010-01-01', periods=60, freq='ME') # Monthly data for 5 years\n",
862862
"seas = 12 # change this and see how the plots change\n",
863863
"data = (np.sin(np.arange(60)*2*np.pi/seas) + \n",
864864
" np.random.normal(loc=0, scale=0.2, size=60)) # Seasonal data with noise\n",

notebooks/06/unit-root-hurst.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
"- When an AR(1) process has a unit root (i.e., $\\phi = 1$), it implies that the series is non-stationary as it becomes a random walk: $Y(t) = Y(t-1) + \\epsilon_t$ \n",
359359
"- The value of the series will be highly dependent on its previous values (the shocks to the series have a permanent effect).\n",
360360
"\n",
361-
"```{info}\n",
361+
"```{note}\n",
362362
"The term \"unit root\" describes a specific condition in the autoregressive representation of a time series, indicating that the series is **non-stationary**.\n",
363363
"```"
364364
]
@@ -806,17 +806,17 @@
806806
"metadata": {},
807807
"outputs": [],
808808
"source": [
809-
"def get_data(tickerSymbol, period, start, end):\n",
809+
"def get_data(tickerSymbol, start, end):\n",
810810
"\n",
811811
" # Get data on the ticker\n",
812812
" tickerData = yf.Ticker(tickerSymbol)\n",
813813
"\n",
814814
" # Get the historical prices for this ticker\n",
815-
" tickerDf = tickerData.history(period=period, start=start, end=end)\n",
815+
" tickerDf = tickerData.history(start=start, end=end)\n",
816816
" \n",
817817
" return tickerDf\n",
818818
" \n",
819-
"data = get_data('GOOG', period='1d', start='2004-09-01', end='2020-08-31')"
819+
"data = get_data('GOOG', start='2004-09-01', end='2020-08-31')"
820820
]
821821
},
822822
{
@@ -1485,7 +1485,7 @@
14851485
"outputs": [],
14861486
"source": [
14871487
"# Step 1: Get the \"training\" data (e.g., 2020-2022)\n",
1488-
"data2 = get_data('GOOG', period='1d', start='2019-12-31', end='2022-12-31')"
1488+
"data2 = get_data('GOOG', start='2019-12-31', end='2022-12-31')"
14891489
]
14901490
},
14911491
{
@@ -1500,7 +1500,7 @@
15001500
"outputs": [],
15011501
"source": [
15021502
"# Get \"test\" data, for comparison (e.g., 2023)\n",
1503-
"data3 = get_data('GOOG', period='1d', start='2022-12-31', end='2023-12-31')\n",
1503+
"data3 = get_data('GOOG', start='2022-12-31', end='2023-12-31')\n",
15041504
"test_days = len(data3)"
15051505
]
15061506
},

notebooks/07/kalman-filter.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@
12471247
"# generate noisy measurements\n",
12481248
"Zx = np.zeros(n_measurements)\n",
12491249
"for t in range(0, n_measurements):\n",
1250-
" Zx[t]= Xt[t] + np.random.normal(0, np.sqrt(R), 1)"
1250+
" Zx[t]= Xt[t] + np.random.normal(0, np.sqrt(R))"
12511251
]
12521252
},
12531253
{

0 commit comments

Comments
 (0)