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

Release 0.13.2 #344

Merged
merged 7 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ jobs:
test -f $CONDA_PREFIX/share/jupyter/labextensions/ipycanvas/package.json
test -d $CONDA_PREFIX/share/jupyter/labextensions/ipycanvas/static

- name: Validate the nbextension
run: jupyter nbextension list 2>&1 | grep "ipycanvas/extension"

- name: Validate the labextension
run: jupyter labextension list 2>&1 | grep ipycanvas

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update_galata_references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- name: Configure git to use https
run: git config --global hub.protocol https

- name: Install hub
run: sudo apt-get update && sudo apt-get install -y hub

- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.issue.number }}
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ $RECYCLE.BIN/

**/node_modules/
ipycanvas/nbextension/static/index.*
.yarn

# Coverage data
# -------------
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
html_theme = "pydata_sphinx_theme"
htmlhelp_basename = "ipycanvasdoc"

html_theme_options = dict(github_url="https://github.com/jupyter-widgets-contrib/ipycanvas")
html_theme_options = dict(
github_url="https://github.com/jupyter-widgets-contrib/ipycanvas"
)

html_static_path = ["_static"]

Expand Down
24 changes: 2 additions & 22 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,18 @@ Using conda

conda install -c conda-forge ipycanvas

JupyterLab extension
--------------------

If you have JupyterLab, you will also need to install the JupyterLab extension. In order to install the JupyterLab extension,
you will need ``npm`` to be installed. You can easily install ``npm`` with conda:

.. code:: bash

conda install -c conda-forge nodejs

Then you can install the JupyterLab extension:

.. code:: bash

jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas

Development installation
------------------------

For a development installation (requires npm):
For a development installation (requires npm and jupyterlab):

.. code:: bash

git clone https://github.com/jupyter-widgets-contrib/ipycanvas.git
cd ipycanvas
pip install -e .

# If you are developing on the classic Jupyter Notebook
jupyter nbextension install --py --symlink --sys-prefix ipycanvas
jupyter nbextension enable --py --sys-prefix ipycanvas

# If you are developing on JupyterLab
# Installing the JupyterLab extension
jupyter labextension develop . --overwrite
jlpm run build

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ channels:
- conda-forge
dependencies:
- jupyterlab=3
- ipycanvas=0.13.1
- ipycanvas=0.13.2
- ipyevents
- branca
48 changes: 28 additions & 20 deletions examples/py3d_engine/py3d_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,45 @@ def normalize(vec):
def project_vector(x, y, z, matrix):
vec = np.dot(matrix, pad_ones(x, y, z))

return vec[0]/vec[3], vec[1]/vec[3], vec[2]/vec[3]
return vec[0] / vec[3], vec[1] / vec[3], vec[2] / vec[3]


def get_look_at_matrix(eye, center, up):
n = normalize(eye - center)
u = normalize(np.cross(up, n))
v = np.cross(n, u)

matrix_r = [[u[0], u[1], u[2], 0],
[v[0], v[1], v[2], 0],
[n[0], n[1], n[2], 0],
[0, 0, 0, 1]]
matrix_r = [
[u[0], u[1], u[2], 0],
[v[0], v[1], v[2], 0],
[n[0], n[1], n[2], 0],
[0, 0, 0, 1],
]

matrix_t = [[1, 0, 0, -eye[0]],
[0, 1, 0, -eye[1]],
[0, 0, 1, -eye[2]],
[0, 0, 0, 1]]
matrix_t = [
[1, 0, 0, -eye[0]],
[0, 1, 0, -eye[1]],
[0, 0, 1, -eye[2]],
[0, 0, 0, 1],
]

return np.dot(matrix_r, matrix_t)


def get_perspective_matrix(fovy, aspect, near, far):
f = 1. / tan(fovy * pi / 360.)
f = 1.0 / tan(fovy * pi / 360.0)

return np.array([
[f/aspect, 0, 0, 0],
[ 0, f, 0, 0],
[ 0, 0, (near + far)/(near - far), 2 * near * far/(near - far)],
[ 0, 0, -1, 0]
])
return np.array(
[
[f / aspect, 0, 0, 0],
[0, f, 0, 0],
[0, 0, (near + far) / (near - far), 2 * near * far / (near - far)],
[0, 0, -1, 0],
]
)


class OrbitCamera():
class OrbitCamera:

def __init__(self, radius, center, aspect, near=0, far=8):
self.radius = radius
Expand All @@ -60,7 +66,7 @@ def update_position(self, elev, azim):
self.elev = elev
self.azim = azim

relev, razim = np.pi * self.elev/180, np.pi * self.azim/180
relev, razim = np.pi * self.elev / 180, np.pi * self.azim / 180

xp = self.center[0] + cos(razim) * cos(relev) * self.radius
yp = self.center[1] + sin(razim) * cos(relev) * self.radius
Expand All @@ -69,7 +75,7 @@ def update_position(self, elev, azim):
self.position = np.array((xp, yp, zp))
self.front = self.center - self.position

if abs(relev) > pi / 2.:
if abs(relev) > pi / 2.0:
self.up = np.array((0, 0, -1))
else:
self.up = np.array((0, 0, 1))
Expand All @@ -78,5 +84,7 @@ def update_position(self, elev, azim):

def update_matrix(self):
self.view_matrix = get_look_at_matrix(self.position, self.center, self.up)
self.projection_matrix = get_perspective_matrix(50, self.aspect, self.near, self.far)
self.projection_matrix = get_perspective_matrix(
50, self.aspect, self.near, self.far
)
self.matrix = np.dot(self.projection_matrix, self.view_matrix)
2 changes: 1 addition & 1 deletion ipycanvas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Copyright (c) Martin Renou.
# Distributed under the terms of the Modified BSD License.

__version__ = "0.13.1"
__version__ = "0.13.2"
1 change: 1 addition & 0 deletions ipycanvas/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Binary module."""

from io import BytesIO

from PIL import Image as PILImage
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipycanvas",
"version": "0.13.1",
"version": "0.13.2",
"description": "Interactive widgets library exposing the browser's Canvas API",
"keywords": [
"jupyter",
Expand Down Expand Up @@ -59,7 +59,7 @@
"roughjs": "^4.3.1"
},
"devDependencies": {
"@jupyterlab/builder": "^4",
"@jupyterlab/builder": "^3 || ^4",
"@types/node": "^10.11.6",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^4.8.1",
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"hatchling",
"jupyterlab==4.*",
"jupyterlab>=3,<5",
]
build-backend = "hatchling.build"

Expand All @@ -24,17 +24,18 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"ipywidgets>=7.6.0,<9",
"numpy",
"pillow>=6.0",
]
version = "0.13.1"
version = "0.13.2"

[project.license]
file = "LICENSE.txt"
Expand Down
10 changes: 5 additions & 5 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
},
"author": "ipycanvas",
"license": "Apache-2.0",
"dependencies": {
"@jupyterlab/galata": "^5.0.0",
"klaw-sync": "^6.0.0",
"rimraf": "^3.0.2"
},
"devDependencies": {
"@jupyterlab/galata": "^5.0.1",
"@playwright/test": "^1.32.0"
},
"dependencies": {
"@types/klaw-sync": "^6.0.1",
"klaw-sync": "^6.0.0"
}
}
3 changes: 1 addition & 2 deletions ui-tests/tests/ipycanvas.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { IJupyterLabPageFixture, test } from '@jupyterlab/galata';
import { expect } from '@playwright/test';
import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
import * as path from 'path';
const klaw = require('klaw-sync');

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading