Skip to content

Commit

Permalink
update code with lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud committed Sep 5, 2023
1 parent 08d69f1 commit f8b4f0e
Show file tree
Hide file tree
Showing 34 changed files with 953 additions and 1,653 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ updates:
schedule:
interval: "weekly"
version: "~major.minor"

# - package-ecosystem: "gitsubmodule" # See documentation for possible values
# directory: "/" # Location of package manifests
# schedule:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.9"]
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest, macos-latest, windows-latest]

# The setup-miniconda action needs this to activate miniconda
defaults:
Expand All @@ -42,7 +42,7 @@ jobs:

- name: Install OpenCL (pocl)
if: matrix.platform != 'windows-latest'
run: conda install -y pocl
run: conda install -y pocl

- name: Install OpenCL (oclgrind)
if: matrix.platform == 'windows-latest'
Expand All @@ -62,5 +62,3 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./coverage.xml
fail_ci_if_error: true # optional (default = false)


10 changes: 5 additions & 5 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: generat build folder
run: |
run: |
python -m pip install --upgrade pip
pip install sphinx nbsphinx sphinx_rtd_theme sphinx-autodoc-typehints sphinx_copybutton
pip install sphinx nbsphinx sphinx_rtd_theme sphinx-autodoc-typehints sphinx_copybutton
cd docs
make clean && make html
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__/
# Mac OS X
.DS_Store

# IDE
# IDE
.vscode

# Distribution / packaging
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)

string(TOLOWER ${PROJECT_NAME} PY_PACKAGE_NAME)
set(CY_PACKAGE_NAME _${PY_PACKAGE_NAME})

Expand Down Expand Up @@ -34,7 +34,7 @@ option(BUILD_TESTING OFF)
option(BUILD_BENCHMARK OFF)
option(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(
CLIc
CLIc
GIT_REPOSITORY ${CLIC_REPO_URL}
GIT_TAG ${CLIC_REPO_TAG}
)
Expand Down
32 changes: 16 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
Copyright 2020 Stéphane Rigaud, Robert Haase,
Institut Pasteur Paris, Max Planck Institute for Molecular Cell Biology and Genetics Dresden

Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ include wrapper/tier3_.cpp
include wrapper/tier4_.cpp
include wrapper/tier5_.cpp
include wrapper/types_.cpp
exclude MANIFEST.in
exclude MANIFEST.in
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ output_image = cle.pull(labeled)
imsave("result.tif", output_image)
```

## __Example gallery__
## __Example gallery__

<table border="0">

Expand Down Expand Up @@ -133,8 +133,8 @@ More usage and example can be found as notebooks in the [demos](./user_docs) fol

# __Contributing and Feedback__

clEsperanto is developed in the open because we believe in the [open source community].
Feel free to drop feedback as [github issue] or via [image.sc forum].
clEsperanto is developed in the open because we believe in the [open source community].
Feel free to drop feedback as [github issue] or via [image.sc forum].
Contribution are also very welcome. Please read our [community guidelines] before you start and get in touch with us so that we can help you get started.
If you liked our work, star the repository, share it with your friends, and use it to make cool stuff!

Expand Down
10 changes: 5 additions & 5 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package:
name: {{ name|lower }}
version: {{ version }}

source:
# fn: {{ name }}-{{ version }}.tar.gz
# url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
Expand All @@ -28,14 +28,14 @@ requirements:
- scikit-build-core
- pybind11
- cmake
- khronos-opencl-icd-loader # [win or osx]
- khronos-opencl-icd-loader # [win or osx]
- ocl-icd # [linux]
run:
- python
- numpy
- toolz
- matplotlib
- khronos-opencl-icd-loader # [win or osx]
- khronos-opencl-icd-loader # [win or osx]
- ocl-icd # [linux]

test:
Expand All @@ -54,9 +54,9 @@ about:
dev_url: https://github.com/clEsperanto/pyclesperanto/
license: BSD-3-Clause
license_file: LICENSE
summary: GPU-accelerated Image Processing library using OpenCL
summary: GPU-accelerated Image Processing library using OpenCL
description: |
pyclesperanto is the python package of clEsperanto - a multi-language framework for GPU-accelerated image processing.
pyclesperanto is the python package of clEsperanto - a multi-language framework for GPU-accelerated image processing.
clEsperanto uses OpenCL kernels from CLIJ. This package relies on the CLIc back-end for processing.
extra:
recipe-maintainers:
Expand Down
2 changes: 1 addition & 1 deletion demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ conda install scikit-image jupyterlab

# Warning

These demos are not meant to be used for benchmarking. They are meant to be easy to understand and to get you started. Several costly operations are done on purpose to make the code easier to understand. If you want to use pyclesperanto in production, please read the documentation and don't hesitate to get in touch with us to get help with optimizing your code.
These demos are not meant to be used for benchmarking. They are meant to be easy to understand and to get you started. Several costly operations are done on purpose to make the code easier to understand. If you want to use pyclesperanto in production, please read the documentation and don't hesitate to get in touch with us to get help with optimizing your code.
2 changes: 1 addition & 1 deletion docs/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyClesperanto
=======

**pyClesperanto** is a Python library for image processing with GPU-acceleration.
**pyClesperanto** is a Python library for image processing with GPU-acceleration.
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Filters
.. automodule:: pyclesperanto._tier1
:members:
:undoc-members:
:imported-members:
:imported-members:
:exclude-members: Image, Device, _Array, plugin_function

.. automodule:: pyclesperanto._tier2
Expand Down
31 changes: 16 additions & 15 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,38 @@

import os
import sys
sys.path.insert(0, os.path.abspath('../../'))

sys.path.insert(0, os.path.abspath("../../"))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'pyclesperanto'
copyright = '2023, Stephane Rigaud'
author = 'Stephane Rigaud'
release = '0.6.5'
project = "pyclesperanto"
copyright = "2023, Stephane Rigaud"
author = "Stephane Rigaud"
release = "0.6.5"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration


extensions = [
'sphinx.ext.autodoc', # Parses (sub)modules
'sphinx.ext.napoleon', # Parses Numpy docstrings
'sphinx.ext.mathjax', # Print mathematical expressions
'nbsphinx', # link notebooks
'sphinx.ext.autosummary', # Make module lists in table
"sphinx.ext.autodoc", # Parses (sub)modules
"sphinx.ext.napoleon", # Parses Numpy docstrings
"sphinx.ext.mathjax", # Print mathematical expressions
"nbsphinx", # link notebooks
"sphinx.ext.autosummary", # Make module lists in table
]

templates_path = ['_templates']
exclude_patterns = ['build', '_build', 'Thumbs.db', '.DS_Store']
templates_path = ["_templates"]
exclude_patterns = ["build", "_build", "Thumbs.db", ".DS_Store"]

autodoc_mock_imports = ["pyclesperanto._pyclesperanto", "toolz", "matplotlib", "numpy"]
add_module_names = False
modindex_common_prefix = ['pyclesperanto.']
modindex_common_prefix = ["pyclesperanto."]

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme' # 'alabaster'
html_static_path = ['_static']
html_theme = "sphinx_rtd_theme" # 'alabaster'
html_static_path = ["_static"]
3 changes: 0 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ You will find here a first draft of the API for reference and documentation purp
usage
api
genindex



10 changes: 5 additions & 5 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ or via conda:
It is advised to install pyClesperanto in a virtual environment. For example, you can create a new environment with conda:

.. code-block:: bash
conda create --name myenv python='3.10' -c conda-forge
conda activate myenv
From source
====================

Alternatively, you can also install the latest version from GitHub and build it from source on your system.
Alternatively, you can also install the latest version from GitHub and build it from source on your system.
First start by cloning the repository:

.. code-block:: bash
Expand All @@ -55,11 +55,11 @@ and install the package from the source:
pip install .
.. note::
The ``-e`` flag is not supported yet.

The ``-e`` flag is not supported yet.

.. note::

You can add the flag ``-vvv`` to enables verbose output of the build process.

pyClesperanto should now be installed in your virtual environment along with all its dependencies.
pyClesperanto should now be installed in your virtual environment along with all its dependencies.
10 changes: 5 additions & 5 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pyClesperanto is a GPU-accelerated image processing library for Python. The firs
.. warning::

If an error is thrown at this stage, it is likely that the OpenCL driver is not installed or that you do not have a OpenCL compatible device.
If an error is thrown at this stage, it is likely that the OpenCL driver is not installed or that you do not have a OpenCL compatible device.
Please, check the installation of your OpenCL and driver.

By default, the first device found will be automatically selected. You can know which device you currently working on, and you can select another one:
Expand All @@ -22,7 +22,7 @@ By default, the first device found will be automatically selected. You can know
cle.select_device("GTX")
The device selection is done by name. You can pass a substring of the device name, and the first device that matches will be selected.
The device selection is done by name. You can pass a substring of the device name, and the first device that matches will be selected.

Memory transfer
================
Expand Down Expand Up @@ -61,7 +61,7 @@ The ``push`` will create a memory space on the GPU like ``create`` but will also
# push arr to the GPU
gpu_image = cle.push(arr)
The data pushed will keep the same data type as the array. Hence, if you push a ``uint8`` array, the data will be stored as ``uint8`` on the GPU.
The data pushed will keep the same data type as the array. Hence, if you push a ``uint8`` array, the data will be stored as ``uint8`` on the GPU.
The array will then use 24 times less memory than if it was stored as ``float32``. This is a good practice to keep in mind when working with GPUs as their
memory is limited.

Expand All @@ -75,9 +75,9 @@ Finally, the ``pull`` function will transfer the data from the GPU back to the h
# pull gpu_image to the host
arr = cle.pull(gpu_image)
The data type of the array will be the same as the data type of the image on the GPU.
The data type of the array will be the same as the data type of the image on the GPU.

.. note::
.. note::

Some operation done on the GPU image may change the data type if needed. For example, the ``gaussian_blur`` will return a ``float32`` image even if the input image is ``uint8``.

Expand Down
2 changes: 0 additions & 2 deletions pyclesperanto/_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ def _repr_html_(self):

# In case the image is 2D, 3D and larger than 100 pixels, turn on fancy view
if len(self.shape) in (2, 3) and size_in_pixels >= 100:
import matplotlib.pyplot as plt

imshow(self, labels=labels, continue_drawing=True, colorbar=not labels)
image = self._png_to_html(self._plt_to_png())
else:
Expand Down
Loading

0 comments on commit f8b4f0e

Please sign in to comment.