Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Nov 7, 2024
2 parents f4d9686 + 9df9757 commit bc3c026
Show file tree
Hide file tree
Showing 49 changed files with 1,409 additions and 549 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build wheels
run: pipx run cibuildwheel==2.20.0
run: pipx run cibuildwheel==2.21.2

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.20.0
uses: pypa/cibuildwheel@v2.21.2

- uses: actions/upload-artifact@v4
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# Inspired from https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions

name: Python package
name: Build, install and test

on:
push:
branches: [ "master" ]
branches: [ "master", "develop" ]
pull_request:
branches: [ "master" ]
branches: [ "master", "develop" ]

jobs:
build:
Expand All @@ -21,12 +21,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11", "3.12"]
python-version: ["3.9", "3.13"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog #

## Version 2.7.0 ##

Supported versions of Python have been updated (drop support for Python 3.8, add support for Python 3.13):

* PlotPy < 2.7.0: Python 3.8, 3.9, 3.10, 3.11 and 3.12
* PlotPy >= 2.7.0: Python 3.9, 3.10, 3.11, 3.12 and 3.13

Other dependencies have been updated:

* Updated versions to those available at the time of the release of the oldest supported Python version (3.9)
* Exception: Cython 3.0 is required for Python 3.13

💥 New features / Enhancements:

* Added `AnnotatedPolygon` annotation to items
* Added `make.annotated_polygon` function to `plotpy.builder` module
* Customization of annotation information:
* Added `info_callback` argument to all annotation class constructors
* Added `set_info_callback` method to all annotation classes
* The `info_callback` is a function that takes the annotation object and returns a string with the information to display
* Default `info_callback` is redirected to the `get_infos` method of the annotation object (this makes the feature backward compatible)

🛠️ Bug fixes:

* Fixed `pydicom` support: use `dcmread` instead of `read_file` to read DICOM files

## Version 2.6.3 ##

🧯 In this release, test coverage is 79%.
Expand Down
5 changes: 3 additions & 2 deletions doc/dev/platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ The following sections describe the reference platforms for the project.

.. note::

The officially supported Python versions are 3.8, 3.9 and 3.10.
However, the project should work on any earlier Python 3 version.
The officially supported Python versions are 3.9, 3.10, 3.11, 3.12 and 3.13.

The officially supported Qt binding is PyQt5. However, efforts have been
made and will continue to be made to support PyQt6 and PySide6 as well.

The project is currently tested on the following platforms:

* Microsoft Windows 10 (64-bit)
* Microsoft Windows 11 (64-bit)
* CentOS Stream 8.8 (64-bit)
* Ubuntu 22.04 LTS (64-bit)

However, it should work on any other platform supported by its dependencies.

Expand Down
2 changes: 1 addition & 1 deletion doc/features/items/builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ used to simplify the creation of plot items.
:members:

.. autoclass:: plotpy.builder.PlotBuilder
:members: widget,dialog,window,gridparam,grid,mcurve,pcurve,curve,merror,perror,error,histogram,phistogram,range,vcursor,hcursor,xcursor,marker,image,maskedimage,maskedxyimage,rgbimage,quadgrid,pcolor,trimage,xyimage,imagefilter,contours,histogram2D,rectangle,ellipse,polygon,circle,segment,svg,annotated_point,annotated_rectangle,annotated_ellipse,annotated_circle,annotated_segment,label,legend,info_label,range_info_label,computation,computations,computation2d,computations2d
:members: widget,dialog,window,gridparam,grid,mcurve,pcurve,curve,merror,perror,error,histogram,phistogram,range,vcursor,hcursor,xcursor,marker,image,maskedimage,maskedxyimage,rgbimage,quadgrid,pcolor,trimage,xyimage,imagefilter,contours,histogram2D,rectangle,ellipse,polygon,circle,segment,svg,annotated_point,annotated_rectangle,annotated_ellipse,annotated_circle,annotated_segment,annotated_polygon,label,legend,info_label,range_info_label,computation,computations,computation2d,computations2d
1 change: 1 addition & 0 deletions doc/features/items/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The following annotation items are available:
* :py:class:`.AnnotatedObliqueRectangle`
* :py:class:`.AnnotatedEllipse`
* :py:class:`.AnnotatedCircle`
* :py:class:`.AnnotatedPolygon`

Labels
^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions doc/features/items/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Annotations
:members:
.. autoclass:: plotpy.items.AnnotatedCircle
:members:
.. autoclass:: plotpy.items.AnnotatedPolygon
:members:

Labels
^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion doc/features/tools/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Shape tools

.. autoclass:: plotpy.tools.MultiLineTool
:members:
.. autoclass:: plotpy.tools.FreeFormTool
.. autoclass:: plotpy.tools.PolygonTool
:members:
.. autoclass:: plotpy.tools.LabelTool
:members:
Expand All @@ -84,6 +84,8 @@ Shape tools
:members:
.. autoclass:: plotpy.tools.AnnotatedSegmentTool
:members:
.. autoclass:: plotpy.tools.AnnotatedPolygonTool
:members:
.. autoclass:: plotpy.tools.HRangeTool
:members:

Expand Down
2 changes: 1 addition & 1 deletion doc/intro/motivation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ From a developer point of view, PlotPy V2 is a major overhaul of PlotPy V1:
all over the codebase

.. note::
PlotPy V2 is fully typed using Python 3.8+ type annotations.
PlotPy V2 is fully typed using Python type annotations.
This means that you can use your IDE to get autocompletion and type checking
(e.g. with VSCode, Visual Studio, etc.).
This is a major improvement when you write code using PlotPy V2:
Expand Down
14 changes: 7 additions & 7 deletions doc/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ The :mod:`plotpy` package requires the following Python modules:
- Version
- Summary
* - Python
- >=3.8, <4
- >=3.9, <4
- Python programming language
* - guidata
- >=3.4
- >=3.7
- Automatic GUI generation for easy dataset editing and display
* - PythonQwt
- >=0.12.1
- >=0.14
- Qt plotting widgets for Python
* - NumPy
- >=1.17
- Fundamental package for array computing in Python
* - SciPy
- >=1.3
- >=1.5
- Fundamental algorithms for scientific computing in Python
* - scikit-image
- >= 0.18
- Image processing in Python
* - Pillow
-
- Python Imaging Library (Fork)
Expand Down
2 changes: 1 addition & 1 deletion doc/update_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@

if __name__ == "__main__":
print("Updating requirements.rst file...", end=" ")
gen_module_req_rst(plotpy, ["Python>=3.8", "PyQt5>=5.11"])
gen_module_req_rst(plotpy, ["Python>=3.9", "PyQt5>=5.11"])
print("done.")
2 changes: 1 addition & 1 deletion plotpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.. _GitHub: https://github.com/PierreRaybaut/plotpy
"""

__version__ = "2.6.3"
__version__ = "2.7.0"
__VERSION__ = tuple([int(number) for number in __version__.split(".")])

# --- Important note: DATAPATH and LOCALEPATH are used by guidata.configtools
Expand Down
82 changes: 61 additions & 21 deletions plotpy/builder/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
AnnotatedCircle,
AnnotatedEllipse,
AnnotatedPoint,
AnnotatedPolygon,
AnnotatedRectangle,
AnnotatedSegment,
)
Expand Down Expand Up @@ -126,10 +127,7 @@ def annotated_point(
def __annotated_shape(
self,
shapeclass,
x0,
y0,
x1,
y1,
points,
title,
subtitle,
show_label,
Expand All @@ -153,7 +151,10 @@ def __annotated_shape(
readonly=readonly,
private=private,
)
shape = shapeclass(x0, y0, x1, y1, param)
if isinstance(points, np.ndarray):
shape = shapeclass(points, annotationparam=param)
else:
shape = shapeclass(*points, annotationparam=param)
shape.set_style("plot", "shape/drag")
return shape

Expand Down Expand Up @@ -195,12 +196,10 @@ def annotated_rectangle(
Returns:
:py:class:`.AnnotatedRectangle` object
"""
points = x0, y0, x1, y1
return self.__annotated_shape(
AnnotatedRectangle,
x0,
y0,
x1,
y1,
points,
title,
subtitle,
show_label,
Expand Down Expand Up @@ -259,12 +258,10 @@ def annotated_ellipse(
Returns:
:py:class:`.AnnotatedEllipse` object
"""
points = x0, y0, x1, y1
item = self.__annotated_shape(
AnnotatedEllipse,
x0,
y0,
x1,
y1,
points,
title,
subtitle,
show_label,
Expand Down Expand Up @@ -318,12 +315,10 @@ def annotated_circle(
Returns:
:py:class:`.AnnotatedCircle` object
"""
points = x0, y0, x1, y1
return self.__annotated_shape(
AnnotatedCircle,
x0,
y0,
x1,
y1,
points,
title,
subtitle,
show_label,
Expand Down Expand Up @@ -374,12 +369,57 @@ def annotated_segment(
Returns:
:py:class:`.AnnotatedSegment` object
"""
points = x0, y0, x1, y1
return self.__annotated_shape(
AnnotatedSegment,
x0,
y0,
x1,
y1,
points,
title,
subtitle,
show_label,
show_computations,
show_subtitle,
format,
uncertainty,
transform_matrix,
readonly,
private,
)

def annotated_polygon(
self,
points: np.ndarray,
title: str | None = None,
subtitle: str | None = None,
show_label: bool | None = None,
show_computations: bool | None = None,
show_subtitle: bool | None = None,
format: str | None = None,
uncertainty: float | None = None,
transform_matrix: np.ndarray | None = None,
readonly: bool | None = None,
private: bool | None = None,
) -> AnnotatedPolygon:
"""Make an annotated polygon `plot item`
Args:
points: polygon points
title: label name. Default is None
subtitle: label subtitle. Default is None
show_label: show label. Default is None
show_computations: show computations. Default is None
show_subtitle: show subtitle. Default is None
format: string formatting. Default is None
uncertainty: measurement relative uncertainty. Default is None
transform_matrix: transform matrix. Default is None
readonly: readonly. Default is None
private: private. Default is None
Returns:
:py:class:`.AnnotatedPolygon` object
"""
return self.__annotated_shape(
AnnotatedPolygon,
points,
title,
subtitle,
show_label,
Expand Down
4 changes: 2 additions & 2 deletions plotpy/builder/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def image(
if isinstance(filename, str) and filename.lower().endswith(".dcm"):
# pylint: disable=import-outside-toplevel
# pylint: disable=import-error
from pydicom import dicomio # type:ignore
from pydicom import dcmread # type:ignore

template = dicomio.read_file(filename, stop_before_pixels=True, force=True)
template = dcmread(filename, stop_before_pixels=True, force=True)
ipp = getattr(template, "ImagePositionPatient", ["0", "0", "0"])
pxs = getattr(template, "PixelSpacing", ["1", "1"])
ipx, ipy = float(ipp[0]), float(ipp[1])
Expand Down
3 changes: 2 additions & 1 deletion plotpy/builder/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def svg(
assert shape in ("circle", "rectangle", "square")
assert isinstance(fname_or_data, (str, bytes))
if isinstance(fname_or_data, str):
data = open(fname_or_data, "rb").read()
with open(fname_or_data, "rb") as file:
data = file.read()
else:
data = fname_or_data
shapeklass = {
Expand Down
File renamed without changes
Loading

0 comments on commit bc3c026

Please sign in to comment.