Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-branca for openSUSE:Factory checked in at 2022-09-23 14:15:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-branca (Old) and /work/SRC/openSUSE:Factory/.python-branca.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-branca" Fri Sep 23 14:15:32 2022 rev:6 rq:1005595 version:0.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-branca/python-branca.changes 2022-06-29 16:02:56.064748585 +0200 +++ /work/SRC/openSUSE:Factory/.python-branca.new.2275/python-branca.changes 2022-09-23 14:16:21.350139627 +0200 @@ -1,0 +2,18 @@ +Fri Sep 23 09:51:27 UTC 2022 - [email protected] + +- python-six is not required + +------------------------------------------------------------------- +Fri Sep 23 02:40:27 UTC 2022 - Yogalakshmi Arunachalam <[email protected]> + +- Update to version 0.5.0: + * Support for Pathlib when saving an `Element` (@wd60622 #103) + * Faster UUID generation for `Element` id (@bwest2397 #101) + * Store html content in `srcdoc` instead of `data-html` (@dstein64 #96) + * Add `max_labels` argument to color maps (@martinfleis #90) + * Pass caption when converting colormap to steps (@ndswaef #87) + +- Update to version 0.4.2 + * Fix special char encoding in notebooks, store as percent-encoded (@conengmo #76) + +------------------------------------------------------------------- Old: ---- branca-0.4.2.tar.gz New: ---- branca-0.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-branca.spec ++++++ --- /var/tmp/diff_new_pack.S2Z6EG/_old 2022-09-23 14:16:21.822140728 +0200 +++ /var/tmp/diff_new_pack.S2Z6EG/_new 2022-09-23 14:16:21.826140737 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-branca -Version: 0.4.2 +Version: 0.5.0 Release: 0 Summary: HTML+JS page generator License: MIT @@ -31,7 +31,6 @@ BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Jinja2 -Requires: python-six BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module Jinja2} @@ -39,7 +38,6 @@ BuildRequires: %{python_module nbconvert} BuildRequires: %{python_module pytest} BuildRequires: %{python_module selenium} -BuildRequires: %{python_module six} # /SECTION %python_subpackages ++++++ branca-0.4.2.tar.gz -> branca-0.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.appveyor.yml new/branca-0.5.0/.appveyor.yml --- old/branca-0.4.2/.appveyor.yml 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/.appveyor.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,37 +0,0 @@ -build: false - -environment: - PYTHON: "C:\\myminiconda3" - matrix: - - PY: 3.7 - - PY: 3.8 - -init: - - "ECHO %PYTHON_VERSION% %MINICONDA%" - -install: - # Add path, activate `conda` and update conda. - - set URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" - - curl -fsS -o miniconda3.exe %URL% - - start /wait "" miniconda3.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%PYTHON% - - - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - - call %PYTHON%\Scripts\activate - - - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - - conda update conda --quiet - - conda config --add channels conda-forge --force - - conda config --set channel_priority strict - - conda config --set safety_checks disabled - - # Create the test env. - - conda create --name TEST python=%PY% --file requirements.txt --file requirements-dev.txt - - activate TEST - - # Debug. - - conda info --all - - conda list - -test_script: - - pip install -e . --no-deps --force-reinstall - - pytest -n 2 -rxXs -m "not headless" tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.github/workflows/publish.yml new/branca-0.5.0/.github/workflows/publish.yml --- old/branca-0.4.2/.github/workflows/publish.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.5.0/.github/workflows/publish.yml 2022-04-17 17:55:02.000000000 +0200 @@ -0,0 +1,47 @@ +name: Publish to PyPI + +on: + release: + types: + - published + +jobs: + packages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Get tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + shell: bash + + - name: Install build tools + run: | + python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine pytest pandas pytz requests + + shell: bash + + - name: Build binary wheel + run: python -m build --sdist --wheel . --outdir dist + + - name: CheckFiles + run: | + ls dist + shell: bash + + - name: Test wheels + run: | + cd dist && python -m pip install erddapy*.whl + python -m twine check * + shell: bash + + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.github/workflows/test_code.yml new/branca-0.5.0/.github/workflows/test_code.yml --- old/branca-0.4.2/.github/workflows/test_code.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.5.0/.github/workflows/test_code.yml 2022-04-17 17:55:02.000000000 +0200 @@ -0,0 +1,39 @@ +name: Code Tests + +on: + pull_request: + push: + branches: [master] + +jobs: + run: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.6", "3.7", "3.8", "3.9"] + + steps: + - uses: actions/checkout@v2 + + - name: Setup Conda + uses: s-weigand/setup-conda@v1 + with: + update-conda: true + activate-conda: false + conda-channels: conda-forge + + - name: Python ${{ matrix.python-version }} + shell: bash -l {0} + run: | + conda create --name TEST python=${{ matrix.python-version }} pip --file requirements.txt --file requirements-dev.txt + source activate TEST + pip install -e . --no-deps --force-reinstall + conda info --all + conda list + + - name: Tests + shell: bash -l {0} + run: | + source activate TEST + pytest -vv -rxs tests -m "not headless" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.github/workflows/test_code_notebooks.yml new/branca-0.5.0/.github/workflows/test_code_notebooks.yml --- old/branca-0.4.2/.github/workflows/test_code_notebooks.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.5.0/.github/workflows/test_code_notebooks.yml 2022-04-17 17:55:02.000000000 +0200 @@ -0,0 +1,35 @@ +name: Notebook Tests + +on: + pull_request: + push: + branches: [master] + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Conda + uses: s-weigand/setup-conda@v1 + with: + update-conda: true + activate-conda: false + conda-channels: conda-forge + + - name: Python 3.9 + shell: bash -l {0} + run: | + conda create --name TEST python=3.9 pip --file requirements.txt --file requirements-dev.txt + source activate TEST + pip install -e . --no-deps --force-reinstall + conda info --all + conda list + + - name: Notebook tests + shell: bash -l {0} + run: | + source activate TEST + pytest --nbval-lax examples diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.github/workflows/test_selenium.yml new/branca-0.5.0/.github/workflows/test_selenium.yml --- old/branca-0.4.2/.github/workflows/test_selenium.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.5.0/.github/workflows/test_selenium.yml 2022-04-17 17:55:02.000000000 +0200 @@ -0,0 +1,35 @@ +name: Headless Tests + +on: + pull_request: + push: + branches: [master] + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Conda + uses: s-weigand/setup-conda@v1 + with: + update-conda: true + activate-conda: false + conda-channels: conda-forge + + - name: Python 3.9 + shell: bash -l {0} + run: | + conda create --name TEST python=3.9 pip --file requirements.txt --file requirements-dev.txt + source activate TEST + pip install -e . --no-deps --force-reinstall + conda info --all + conda list + + - name: Tests + shell: bash -l {0} + run: | + source activate TEST + pytest -vv -rxs tests -m "headless" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.github/workflows/test_tarball.yml new/branca-0.5.0/.github/workflows/test_tarball.yml --- old/branca-0.4.2/.github/workflows/test_tarball.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.5.0/.github/workflows/test_tarball.yml 2022-04-17 17:55:02.000000000 +0200 @@ -0,0 +1,37 @@ +name: Tarball Tests + +on: + pull_request: + push: + branches: [master] + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Conda + uses: s-weigand/setup-conda@v1 + with: + update-conda: true + activate-conda: false + conda-channels: conda-forge + + - name: Python 3 + shell: bash -l {0} + run: | + conda create --name TEST python=3 pip --file requirements.txt --file requirements-dev.txt + source activate TEST + pip install -e . --no-deps --force-reinstall + conda info --all + conda list + + - name: Tarball tests + shell: bash -l {0} + run: | + source activate TEST + pip wheel . -w dist --no-deps + check-manifest --verbose + twine check dist/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/.travis.yml new/branca-0.5.0/.travis.yml --- old/branca-0.4.2/.travis.yml 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/.travis.yml 2022-04-17 17:55:02.000000000 +0200 @@ -3,34 +3,16 @@ sudo: false env: - - MOZ_HEADLESS=1 - -addons: - apt: - packages: - # Without libgtk (as of 2019-11-6), firefox cannot run properly - - libgtk-3-0 - firefox: latest - -env: global: - secure: "JrdAJJKe+Y564LIiIaGPmw9X9utvj2lVI2MkVyZX6CQ7cJwqPUB+ukZpa6MnGUEJSoI6S7/5ZqX/cvciVAKpcYadi/snlDGq6q+lLnA+6rtB6ppy99Ib64aqm+VqDyohvvvrNtSxqhBY48DLG9UuQEcvviabpx9CG4s439/osspsA80SRXgDm/dELjU8vuIJvL1EFPeOu4a01sAHsqhknQw4F4YSWWjUr1oNjZIhSKroxCJV0o/0ok600SwTrQrbwJNO8QmEBOTw1JO1kaxDRlMAsJ5JTBaeGWdhqWQ3IRH/RogkU3ukOyyybbeoWU9ou5xG08P0r4CM3dGh44M8qrTOOCUSSNrFIG5OhAW6ZdkSR/2w76fNnW6y25jKUQ2444kd8n8+TObsp8aNl1FkCwou6/SpPluKvtaFA+I1zbk8roG58tW9anf6o9zCdIyYhSFysEoKNNihSC6xc4zHlJUHWr61f4zC0mU1Xf/djgpvj2YUQLsQ4++K6FNb6I/CN7LDl67kkOiyVCKv60J1mHVXAPJpj2Y9SxR87ob+GH+na8oFy5IMPMDoym2hPImtl2cjGvpP6RvE+gVE+mfvc4BizWfsR1zO49DUD15U1Y6jqhbcPMCgk5FoQ3ZKiH6LBeFbmV0qMjwSC6pZONgz8s/2nTUMV3VU+9SBiah51ho=" matrix: fast_finish: true include: - - name: "python-3.6" - env: PY=3.6 - - name: "python-3.7" - env: PY=3.7 - - name: "python-3.8" - env: PY=3.8 - name: coding_standards - env: PY=3.8 + env: PY=3 - name: docs - env: PY=3.8 - - name: "tarball" - env: PY=3.8 + env: PY=3 before_install: # Install miniconda and create TEST env. @@ -46,29 +28,11 @@ conda create --name TEST python=$PY --file requirements.txt --file requirements-dev.txt source activate TEST conda info --all - # Install firefox headless driver. - - | - wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz -O geckodriver.tar.gz - mkdir geckodriver - tar -xzf geckodriver.tar.gz -C geckodriver - export PATH=$PATH:$PWD/geckodriver install: - pip install -e . --no-deps --force-reinstall script: - - if [[ $TRAVIS_JOB_NAME == python-* ]]; then - cp -r tests/ examples/ /tmp ; - pushd /tmp && pytest -n 2 -rxs --cov=branca -vv tests && popd ; - fi - - - if [[ $TRAVIS_JOB_NAME == 'tarball' ]]; then - python setup.py --version ; - pip wheel . -w dist --no-deps ; - check-manifest --verbose ; - twine check dist/* ; - fi - - if [[ $TRAVIS_JOB_NAME == 'coding_standards' ]]; then pytest --flake8 -m flake8 ; fi @@ -85,17 +49,3 @@ doctr: require-master: true sync: False - -deploy: - skip_cleanup: true - provider: pypi - user: "__token__" - password: - secure: "ncVXDcUpadOXESusbUv/F5mhXqzjp0fFM+llYdBOWBGpipP2B1cU/cWRUU5fkhL1KZG/0DfVboJsRnNQCebZklJ0fczW2Z2QUzL8zCAK8KLOUqr0Nk8i8Oi5eC0h8Ew+HkDNORsZUCPCjKvqcFHRuSZnVYvEqqPPguSj1fwDdyBm9kW7lfZdPeR9mr79WJs+Miv5UKXGZcQAuzCU7g3AmaizRoUfhXnSgPXd9Yp2DY5nsBUZhmqFTj1xjQwLvqp5w/BiFZGkdqMuWVP9b/HbVJEeRxWgCaDPw+XLkQa+HdfUsDGBvPWaaQ+o6OwuADdCjIHLnVmfA2/E2FSU64IBaIZ1xOkHZpm74P8Y0NF5aRogyipkqhrm0WErRWFD4OYj8ud4y9AHLCAmyyLsKCka76NSxotbTd4W4Xu9MX7fkhGOVzhYXg1GNS6SDTIMn+bujFNg5fZrZUptn6FcNa8THkh7yKrduBv2kgbBcgx0/EodH4q2Ds7yfbFvPkQD+l0mBiOPXOXflcQDOiu0CZ70X2XmLe3v3zIEf51oigEtb/KRkf7B3r/Ab+ayNdS33xbHsE8JYE/6KKjGf+fEr0f4XiidadtCbUmNGCw8fgHo7dY4g7blYMPvab7z4zcHmqekzrSTTwxw2uRtmGLWWJupmOerasRIuLsKiJxnk9oiS+k=" - distributions: sdist bdist_wheel - upload_docs: no - on: - repo: python-visualization/branca - tags: true - all_branches: master - condition: '$TRAVIS_JOB_NAME == "tarball"' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/CHANGES.txt new/branca-0.5.0/CHANGES.txt --- old/branca-0.4.2/CHANGES.txt 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/CHANGES.txt 2022-04-17 17:55:02.000000000 +0200 @@ -1,3 +1,11 @@ +0.5.0 +~~~~~ +- Support for Pathlib when saving an `Element` (@wd60622 #103) +- Faster UUID generation for `Element` id (@bwest2397 #101) +- Store html content in `srcdoc` instead of `data-html` (@dstein64 #96) +- Add `max_labels` argument to color maps (@martinfleis #90) +- Pass caption when converting colormap to steps (@ndswaef #87) + 0.4.2 ~~~~~ - Fix special char encoding in notebooks, store as percent-encoded (@conengmo #76) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/branca/_version.py new/branca-0.5.0/branca/_version.py --- old/branca-0.4.2/branca/_version.py 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/branca/_version.py 2022-04-17 17:55:02.000000000 +0200 @@ -23,9 +23,9 @@ # setup.py/versioneer.py will grep for the variable names, so they must # each be defined on a line of their own. _version.py will just call # get_keywords(). - git_refnames = " (HEAD -> master, tag: v0.4.2)" - git_full = "ac45f1e1fa95d10a2409409cf3c697f700cad314" - git_date = "2020-11-08 11:27:38 +0100" + git_refnames = " (tag: v0.5.0)" + git_full = "83019bbf314edd7477ca63a156be806b22f45687" + git_date = "2022-04-17 17:55:02 +0200" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/branca/colormap.py new/branca-0.5.0/branca/colormap.py --- old/branca-0.4.2/branca/colormap.py 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/branca/colormap.py 2022-04-17 17:55:02.000000000 +0200 @@ -70,10 +70,12 @@ The right bound of the color scale. caption: str A caption to draw with the colormap. + max_labels : int, default 10 + Maximum number of legend tick labels """ _template = ENV.get_template('color_scale.js') - def __init__(self, vmin=0., vmax=1., caption=''): + def __init__(self, vmin=0., vmax=1., caption='', max_labels=10): super(ColorMap, self).__init__() self._name = 'ColorMap' @@ -81,13 +83,14 @@ self.vmax = vmax self.caption = caption self.index = [vmin, vmax] + self.max_labels = max_labels def render(self, **kwargs): """Renders the HTML representation of the element.""" self.color_domain = [self.vmin + (self.vmax-self.vmin) * k/499. for k in range(500)] self.color_range = [self.__call__(x) for x in self.color_domain] - self.tick_labels = legend_scaler(self.index) + self.tick_labels = legend_scaler(self.index, self.max_labels) super(ColorMap, self).render(**kwargs) @@ -180,11 +183,13 @@ Values lower than `vmin` will be bound directly to `colors[0]`. vmax : float, default 1. The maximal value for the colormap. - Values higher than `vmax` will be bound directly to `colors[-1]`.""" + Values higher than `vmax` will be bound directly to `colors[-1]`. + max_labels : int, default 10 + Maximum number of legend tick labels""" - def __init__(self, colors, index=None, vmin=0., vmax=1., caption=''): + def __init__(self, colors, index=None, vmin=0., vmax=1., caption='', max_labels=10): super(LinearColormap, self).__init__(vmin=vmin, vmax=vmax, - caption=caption) + caption=caption, max_labels=max_labels) n = len(colors) if n < 2: @@ -216,7 +221,7 @@ in range(4)) def to_step(self, n=None, index=None, data=None, method=None, - quantiles=None, round_method=None): + quantiles=None, round_method=None, max_labels=10): """Splits the LinearColormap into a StepColormap. Parameters @@ -243,6 +248,8 @@ * If 'log10', all values will be rounded to the nearest order-of-magnitude integer. For example, 2100 is rounded to 2000, 2790 to 3000. + max_labels : int, default 10 + Maximum number of legend tick labels Returns ------- @@ -322,9 +329,12 @@ index[i+1] * i/(n-1.)) for i in range(n)] - return StepColormap(colors, index=index, vmin=index[0], vmax=index[-1]) + caption = self.caption + + return StepColormap(colors, index=index, vmin=index[0], vmax=index[-1], caption=caption, + max_labels=max_labels) - def scale(self, vmin=0., vmax=1.): + def scale(self, vmin=0., vmax=1., max_labels=10): """Transforms the colorscale so that the minimal and maximal values fit the given parameters. """ @@ -334,6 +344,7 @@ vmin=vmin, vmax=vmax, caption=self.caption, + max_labels=max_labels ) @@ -362,11 +373,13 @@ vmax : float, default 1. The maximal value for the colormap. Values higher than `vmax` will be bound directly to `colors[-1]`. + max_labels : int, default 10 + Maximum number of legend tick labels """ - def __init__(self, colors, index=None, vmin=0., vmax=1., caption=''): + def __init__(self, colors, index=None, vmin=0., vmax=1., caption='', max_labels=10): super(StepColormap, self).__init__(vmin=vmin, vmax=vmax, - caption=caption) + caption=caption, max_labels=max_labels) n = len(colors) if n < 1: @@ -391,7 +404,7 @@ i = len([u for u in self.index if u < x]) # 0 < i < n. return tuple(self.colors[i-1]) - def to_linear(self, index=None): + def to_linear(self, index=None, max_labels=10): """ Transforms the StepColormap into a LinearColormap. @@ -401,6 +414,8 @@ The values corresponding to each color in the output colormap. It has to be sorted. If None, a regular grid between `vmin` and `vmax` is created. + max_labels : int, default 10 + Maximum number of legend tick labels """ if index is None: @@ -410,9 +425,9 @@ colors = [self.rgba_floats_tuple(x) for x in index] return LinearColormap(colors, index=index, - vmin=self.vmin, vmax=self.vmax) + vmin=self.vmin, vmax=self.vmax, max_labels=max_labels) - def scale(self, vmin=0., vmax=1.): + def scale(self, vmin=0., vmax=1., max_labels=10): """Transforms the colorscale so that the minimal and maximal values fit the given parameters. """ @@ -422,6 +437,7 @@ vmin=vmin, vmax=vmax, caption=self.caption, + max_labels=max_labels ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/branca/element.py new/branca-0.5.0/branca/element.py --- old/branca-0.4.2/branca/element.py 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/branca/element.py 2022-04-17 17:55:02.000000000 +0200 @@ -7,12 +7,14 @@ """ import base64 +from html import escape import json import warnings from collections import OrderedDict -import urllib.parse from urllib.request import urlopen -from uuid import uuid4 +from binascii import hexlify +from os import urandom +from pathlib import Path from jinja2 import Environment, PackageLoader, Template @@ -50,7 +52,7 @@ def __init__(self, template=None, template_name=None): self._name = 'Element' - self._id = uuid4().hex + self._id = hexlify(urandom(16)).decode() self._env = ENV self._children = OrderedDict() self._parent = None @@ -158,7 +160,7 @@ close_file : bool, default True Whether the file has to be closed after write. """ - if isinstance(outfile, str) or isinstance(outfile, bytes): + if isinstance(outfile, (str, bytes, Path)): fid = open(outfile, 'wb') else: fid = outfile @@ -320,43 +322,26 @@ return self._template.render(this=self, kwargs=kwargs) def _repr_html_(self, **kwargs): - """Displays the Figure in a Jupyter notebook. - - Percent-encoded HTML is stored in data-html attribute, which is used to populate - the iframe. This approach does not encounter the 2MB limit in Chrome for storing - the HTML in the src attribute with a data URI. The alternative of using a srcdoc - attribute is not supported in Microsoft Internet Explorer and Edge. - - """ - html = urllib.parse.quote(self.render(**kwargs)) - onload = ( - 'this.contentDocument.open();' - 'this.contentDocument.write(' - ' decodeURIComponent(this.getAttribute(\'data-html\'))' - ');' - 'this.contentDocument.close();' - ) - + """Displays the Figure in a Jupyter notebook.""" + html = escape(self.render(**kwargs)) if self.height is None: iframe = ( '<div style="width:{width};">' '<div style="position:relative;width:100%;height:0;padding-bottom:{ratio};">' # noqa '<span style="color:#565656">Make this Notebook Trusted to load map: File -> Trust Notebook</span>' # noqa - '<iframe src="about:blank" style="position:absolute;width:100%;height:100%;left:0;top:0;' # noqa + '<iframe srcdoc="{html}" style="position:absolute;width:100%;height:100%;left:0;top:0;' # noqa 'border:none !important;" ' - 'data-html={html} onload="{onload}" ' 'allowfullscreen webkitallowfullscreen mozallowfullscreen>' '</iframe>' '</div></div>' - ).format(html=html, onload=onload, width=self.width, ratio=self.ratio) + ).format(html=html, width=self.width, ratio=self.ratio) else: iframe = ( - '<iframe src="about:blank" width="{width}" height="{height}"' + '<iframe srcdoc="{html}" width="{width}" height="{height}"' 'style="border:none !important;" ' - 'data-html={html} onload="{onload}" ' '"allowfullscreen" "webkitallowfullscreen" "mozallowfullscreen">' '</iframe>' - ).format(html=html, onload=onload, width=self.width, height=self.height) + ).format(html=html, width=self.width, height=self.height) return iframe def add_subplot(self, x, y, n, margin=0.05): @@ -408,10 +393,10 @@ (suitable for embedding html-ready code) width : int or str, default '100%' The width of the output div element. - Ex: 120 , '120px', '80%' + Ex: 120 , '80%' height : int or str, default '100%' The height of the output div element. - Ex: 120 , '120px', '80%' + Ex: 120 , '80%' """ _template = Template( '<div id="{{this.get_name()}}" ' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/requirements-dev.txt new/branca-0.5.0/requirements-dev.txt --- old/branca-0.4.2/requirements-dev.txt 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/requirements-dev.txt 2022-04-17 17:55:02.000000000 +0200 @@ -8,6 +8,7 @@ isort jupyter nbsphinx +nbval pylint pytest pytest-cov diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/tests/test_colormap.py new/branca-0.5.0/tests/test_colormap.py --- old/branca-0.4.2/tests/test_colormap.py 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/tests/test_colormap.py 2022-04-17 17:55:02.000000000 +0200 @@ -4,6 +4,7 @@ ---------------------- """ import branca.colormap as cm +import pytest def test_simple_step(): @@ -55,3 +56,30 @@ cm.step.PuBu_06.to_linear() cm.step.YlGn_06.scale(3, 12) cm.step._repr_html_() + [email protected]("max_labels,expected", [ + (10, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]), + (5, [0.0, '', 2.0, '', 4.0, '', 6.0, '', 8.0, '']), + (3, [0.0, '', '', '', 4.0, '', '', '', 8.0, '', '', '']), +]) +def test_max_labels_linear(max_labels, expected): + colorbar = cm.LinearColormap(['red'] * 10, vmin=0, vmax=9, max_labels=max_labels) + try: + colorbar.render() + except AssertionError: # rendering outside parent Figure raises error + pass + assert colorbar.tick_labels == expected + + [email protected]("max_labels,expected", [ + (10, [0.0, '', 2.0, '', 4.0, '', 6.0, '', 8.0, '', 10.0, '']), + (5, [0.0, '', '', 3.0, '', '', 6.0, '', '', 9.0, '', '']), + (3, [0.0, '', '', '', 4.0, '', '', '', 8.0, '', '', '']), +]) +def test_max_labels_step(max_labels, expected): + colorbar = cm.StepColormap(['red', 'blue'] * 5, vmin=0, vmax=10, max_labels=max_labels) + try: + colorbar.render() + except AssertionError: # rendering outside parent Figure raises error + pass + assert colorbar.tick_labels == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.4.2/tests/test_notebooks.py new/branca-0.5.0/tests/test_notebooks.py --- old/branca-0.4.2/tests/test_notebooks.py 2020-11-08 11:27:38.000000000 +0100 +++ new/branca-0.5.0/tests/test_notebooks.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,44 +0,0 @@ -""" -Branca Notebooks Tests ----------------------- - -Here we try to execute all notebooks that are in `branca/examples`. -""" - -import os - -import nbconvert - -import branca.utilities - -rootpath = os.path.abspath(os.path.dirname(__file__)) - - -class NotebookTester(object): - def __init__(self, filename): - self.filename = filename - - def __call__(self, exporter=None, filename=None): - raw_nb = nbconvert.exporters.Exporter().from_filename(self.filename) - raw_nb[0].metadata.setdefault('kernelspec', {})['name'] = 'python' - exec_nb = nbconvert.preprocessors.ExecutePreprocessor().preprocess(*raw_nb) - - if exporter is not None: - out_nb = nbconvert.exporters.MarkdownExporter().from_notebook_node(*exec_nb) - if filename is None: - assert self.filename.endswith('.ipynb') - filename = self.filename[:-6] + exporter.file_extension - open(filename, 'w').write(out_nb[0].encode('utf-8')) - - -class TestNotebooks(object): - _filepath = rootpath.rstrip('/')+'/../examples/' - _nblist = [x for x in os.listdir(_filepath) if x.endswith('.ipynb')] - - -for fn in TestNotebooks._nblist: - setattr( - TestNotebooks, - 'test_'+branca.utilities._camelify(fn[:-6]), - NotebookTester(TestNotebooks._filepath+fn).__call__ - )
