Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python versions #4490

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f108db7
add 3.10 tests, remove 3.6 + 3.7
LiamConnors Jan 22, 2024
4fc892e
check only for near equality
LiamConnors Jan 22, 2024
6391f3f
fix function call
LiamConnors Jan 22, 2024
b40f5e4
add py311 tests
LiamConnors Jan 22, 2024
d8bb3b2
add python 3.11 in workflows
LiamConnors Jan 22, 2024
ab92c7d
fix function call
LiamConnors Jan 22, 2024
2f6a186
update for python 3.11 and later
LiamConnors Jan 22, 2024
8185cc5
Update test_figure_factory.py
LiamConnors Jan 22, 2024
4f5006b
Update test_figure_factory.py
LiamConnors Jan 22, 2024
f86e0fb
add statsmodels version
LiamConnors Jan 22, 2024
fc42fda
add python 3.12 tests
LiamConnors Jan 22, 2024
bb73b70
Update test_figure_factory.py
LiamConnors Jan 22, 2024
f51c371
Update test_figure_factory.py
LiamConnors Jan 22, 2024
3a22960
only run polars/vaex tests on 3.11 or earlier
LiamConnors Jan 22, 2024
315ccd4
Update _county_choropleth.py
LiamConnors Jan 22, 2024
c2c9c7d
update
LiamConnors Jan 22, 2024
635e933
Update test_to_from_plotly_json.py
LiamConnors Jan 22, 2024
709fb99
update docs requirements
LiamConnors Jan 22, 2024
f3b427a
Update requirements.txt
LiamConnors Jan 22, 2024
a2236ee
Update requirements.txt
LiamConnors Jan 22, 2024
b4c3a70
update docs page to use same versions as docs
LiamConnors Jan 22, 2024
5725d6d
Update requirements.txt
LiamConnors Jan 22, 2024
1dfcb3e
Update requirements.txt
LiamConnors Jan 22, 2024
e0b22d8
Update ml-regression.md
LiamConnors Jan 22, 2024
37116fb
Update requirements.txt
LiamConnors Jan 22, 2024
aa5965d
Update setup.py
LiamConnors Jan 22, 2024
01b3da5
Update requirements.txt
LiamConnors Jan 22, 2024
5d9cc37
Update requirements.txt
LiamConnors Jan 22, 2024
623ea96
Update requirements.txt
LiamConnors Jan 22, 2024
4aa9fe2
Update requirements.txt
LiamConnors Jan 22, 2024
61a09b9
Update conda_build_config.yaml
LiamConnors Jan 22, 2024
5ae9da4
Update ml-pca.md
LiamConnors Jan 22, 2024
9dc9d5f
Update requirements.txt
LiamConnors Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 55 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ commands:
test_core:
parameters:
py:
default: "36"
default: "310"
type: string
steps:
- checkout
Expand All @@ -32,7 +32,7 @@ commands:
test_optional:
parameters:
py:
default: "36"
default: "310"
type: string
steps:
- checkout
Expand Down Expand Up @@ -95,7 +95,7 @@ commands:
test_orca:
parameters:
py:
default: "36"
default: "310"
type: string
steps:
- checkout
Expand Down Expand Up @@ -153,20 +153,6 @@ jobs:
black --check . --exclude venv

# Core
python_36_core:
docker:
- image: cimg/python:3.6-browsers
steps:
- test_core:
py: "36"

python_37_core:
docker:
- image: cimg/python:3.7-browsers
steps:
- test_core:
py: "37"

python_38_core:
docker:
- image: cimg/python:3.8-browsers
Expand All @@ -181,20 +167,28 @@ jobs:
- test_core:
py: "39"

# Optional
python_36_optional:
python_310_core:
docker:
- image: cimg/python:3.6-browsers
- image: cimg/python:3.10-browsers
steps:
- test_optional:
py: "36"
- test_core:
py: "310"

python_37_optional:
python_311_core:
docker:
- image: cimg/python:3.7-browsers
- image: cimg/python:3.11-browsers
steps:
- test_optional:
py: "37"
- test_core:
py: "311"

python_312_core:
docker:
- image: cimg/python:3.12-browsers
steps:
- test_core:
py: "312"

# Optional

python_38_optional:
docker:
Expand All @@ -210,6 +204,27 @@ jobs:
- test_optional:
py: "39"

python_310_optional:
docker:
- image: cimg/python:3.10-browsers
steps:
- test_optional:
py: "310"

python_311_optional:
docker:
- image: cimg/python:3.11-browsers
steps:
- test_optional:
py: "311"

python_312_optional:
docker:
- image: cimg/python:3.12-browsers
steps:
- test_optional:
py: "312"

# Pandas

python_39_pandas_2_optional:
Expand All @@ -228,7 +243,7 @@ jobs:
py: "38"

# Percy
python_37_percy:
python_39_percy:
docker:
- image: cimg/python:3.9-browsers
environment:
Expand Down Expand Up @@ -277,9 +292,9 @@ jobs:
rm test/percy/*.html

# Chart studio
python_37_chart_studio:
python_38_chart_studio:
docker:
- image: cimg/python:3.7
- image: cimg/python:3.8
resource_class: large

steps:
Expand All @@ -291,7 +306,7 @@ jobs:
python -m venv venv
. venv/bin/activate
pip install --upgrade pip wheel
pip install -r ./test_requirements/requirements_37.txt
pip install -r ./test_requirements/requirements_38.txt
- run:
name: Tests
command: |
Expand All @@ -302,7 +317,7 @@ jobs:

plotlyjs_dev_build:
docker:
- image: cimg/python:3.7-node
- image: cimg/python:3.8-node
environment:
LANG: en_US.UTF-8
resource_class: large
Expand All @@ -316,7 +331,7 @@ jobs:
python -m venv venv
. venv/bin/activate
pip install --upgrade pip wheel
pip install -r ./test_requirements/requirements_37_core.txt black inflect
pip install -r ./test_requirements/requirements_38_core.txt black inflect
pip install jupyterlab~=3.0
- run:
name: Update jupyterlab-plotly version
Expand Down Expand Up @@ -433,7 +448,7 @@ jobs:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, for example, `3.6.1-browsers`
- image: cimg/python:3.7-browsers
- image: cimg/python:3.9-browsers

steps:
- add_ssh_keys:
Expand Down Expand Up @@ -570,15 +585,17 @@ workflows:

build:
jobs:
- python_36_core
- python_37_core
- python_38_core
- python_39_core
- python_36_optional
- python_37_optional
- python_310_core
- python_311_core
- python_312_core
- python_38_optional
- python_39_optional
- python_310_optional
- python_311_optional
- python_312_optional
- python_39_pandas_2_optional
- python_38_orca
- python_37_percy
- python_39_percy
- build-doc
4 changes: 2 additions & 2 deletions binder/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ jupytext
plotly==5.18.0
jupyter
notebook
pandas==1.0.3
statsmodels==0.11.1
pandas==1.1.3
statsmodels==0.12.1
scipy
patsy==0.5.1
numpy
Expand Down
6 changes: 3 additions & 3 deletions doc/python/county-choropleth.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Run the following commands to install the correct versions of the following modu

```python
!pip install plotly-geo==1.0.0
!pip install geopandas==0.3.0
!pip install pyshp==1.2.10
!pip install shapely==1.6.3
!pip install geopandas==0.8.1
!pip install pyshp==2.1.2
!pip install shapely==1.7.1
```

If you are using Windows, follow this post to properly install geopandas and dependencies: http://geoffboeing.com/2014/09/using-geopandas-windows/. If you are using Anaconda, do not use PIP to install the packages above. Instead use conda to install them:
Expand Down
23 changes: 14 additions & 9 deletions doc/python/ml-pca.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.1
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.8
version: 3.10.11
plotly:
description: Visualize Principle Component Analysis (PCA) of your high-dimensional
data in Python with Plotly.
Expand Down Expand Up @@ -105,17 +105,18 @@ fig.show()

When you will have too many features to visualize, you might be interested in only visualizing the most relevant components. Those components often capture a majority of the [explained variance](https://en.wikipedia.org/wiki/Explained_variation), which is a good way to tell if those components are sufficient for modelling this dataset.

In the example below, our dataset contains 10 features, but we only select the first 4 components, since they explain over 99% of the total variance.
In the example below, our dataset contains 8 features, but we only select the first 2 components.

```python
import pandas as pd
import plotly.express as px
from sklearn.decomposition import PCA
from sklearn.datasets import load_boston
from sklearn.datasets import fetch_california_housing

boston = load_boston()
df = pd.DataFrame(boston.data, columns=boston.feature_names)
n_components = 4
housing = fetch_california_housing(as_frame=True)
df = housing.data

n_components = 2

pca = PCA(n_components=n_components)
components = pca.fit_transform(df)
Expand All @@ -127,7 +128,7 @@ labels['color'] = 'Median Price'

fig = px.scatter_matrix(
components,
color=boston.target,
color=housing.target,
dimensions=range(n_components),
labels=labels,
title=f'Total Explained Variance: {total_var:.2f}%',
Expand All @@ -136,6 +137,10 @@ fig.update_traces(diagonal_visible=False)
fig.show()
```

```python
df
```

## PCA analysis in Dash

[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash`, click "Download" to get the code and run `python app.py`.
Expand Down
15 changes: 10 additions & 5 deletions doc/python/ml-regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.1
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.8
version: 3.10.0
plotly:
description: Visualize regression in scikit-learn with Plotly.
display_as: ai_ml
Expand Down Expand Up @@ -412,6 +412,7 @@ import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from sklearn.linear_model import LassoCV
from sklearn.preprocessing import StandardScaler

N_FOLD = 6

Expand All @@ -421,9 +422,13 @@ X = df.drop(columns=['lifeExp', 'iso_num'])
X = pd.get_dummies(X, columns=['country', 'continent', 'iso_alpha'])
y = df['lifeExp']

# Normalize the data
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# Train model to predict life expectancy
model = LassoCV(cv=N_FOLD, normalize=True)
model.fit(X, y)
model = LassoCV(cv=N_FOLD)
model.fit(X_scaled, y)
mean_alphas = model.mse_path_.mean(axis=-1)

fig = go.Figure([
Expand Down
10 changes: 5 additions & 5 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ ipywidgets==7.7.2
jupyter-client<7
jupyter
notebook
pandas==1.0.3
statsmodels==0.11.1
scipy==1.3.1
pandas==1.2.0
statsmodels==0.12.1
scipy==1.5.4
patsy==0.5.1
numpy==1.19.5
plotly-geo
Expand All @@ -16,7 +16,7 @@ pyshp==2.1.2
shapely==1.7.1
psutil
requests
networkx
networkx==2.6.3
squarify
scikit-image==0.18.1
scikit-learn
Expand All @@ -25,7 +25,7 @@ sphinx_bootstrap_theme
recommonmark
pathlib
python-frontmatter
datashader
datashader==0.14.4
pyarrow
cufflinks==0.17.3
kaleido
Expand Down
Loading