Skip to content

Commit

Permalink
Add deprecations and api changes notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Jan 31, 2024
1 parent 92db65a commit 3f93aec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
15 changes: 15 additions & 0 deletions additional_notes/0.4.19/api changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

[#6102](https://github.com/napari/napari/pull/6102) added the ability to set
linear colormaps from black to a named color by using `colormap="color-name"`
syntax. It turns out that "orange" is both the name of a
white-to-orange colormap in VisPy, and one of the color names in the color
dictionary, therefore implicitly a *black-to-orange* colormap! We decided to use
the new, color-name behavior in this update. So if you are wondering why your
`imshow(data, colormap='orange')` calls look different — this is why.

In [#6178](https://github.com/napari/napari/pull/6178), the "action" type of
events emitted when editing Shapes or Points was changed to be more granular.
The types are no longer "add", "remove", and "change", but "adding", "added",
"removing", "removed", "changing", and "changed". This gives listeners more
control over when to take action in response to an event.

21 changes: 21 additions & 0 deletions additional_notes/0.4.19/deprecations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[#6542](https://github.com/napari/napari/pull/6542) made a number of
deprecations to the Labels API to simplify it. Rather than having color-related
properties strewn all over the layer, color control is moved strictly to the
layer's `colormap`. Here is the full list of deprecated attributes and their
replacements:

- num_colors: `layer.num_colors` becomes `len(layer.colormap)`.
`layer.num_colors = n` becomes `layer.colormap = label_colormap(n)`.
- `napari.utils.colormaps.LabelColormap` is deprecated and has been renamed to
`napari.utils.colormaps.CyclicLabelColormap`.
- color: `layer.color` becomes `layer.colormap.color_dict`.
`layer.color = color_dict` becomes
`layer.colormap = DirectLabelColormap(color_dict)`.
- _background_label: `layer._background_label` is now at
`layer.colormap.background_value`.
- color_mode: `layer.color_mode` is set by setting the colormap using the
corresponding colormap type (`CyclicLabelColormap` or `DirectLabelColormap`;
these classes can be imported from `napari.utils.colormaps`.).
- `seed`: was only used for shifting labels around in [0, 1]. It is
superseded by `layer.new_colormap()` which was implemented in
[#6460](https://github.com/napari/napari/pull/6460).
7 changes: 2 additions & 5 deletions additional_notes/0.4.19/highlights.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ available, see the
RGB hex color prefixed with `#`, as in
`napari.imshow(data, colormap=`#88ff1a`)`.

(Amusing side note/API break: it turns out that "orange" is both the name of a
white-to-orange colormap in VisPy, and one of the color names in the color
dictionary, which then produces a *black-to-orange* colormap! We decided to use
the new, color-name behavior in this update. So if you are wondering why your
`imshow(data, colormap='orange')` calls look different — this is why.)
(For an amusing side note, though, check out the [API Changes](#api-changes)
note related to this PR. 😅)

### Some technical stuff

Expand Down

0 comments on commit 3f93aec

Please sign in to comment.