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

(api) Use of None in QgsMeshRendererScalarSettings raises Python issues #51033

Closed
2 tasks
rduivenvoorde opened this issue Nov 28, 2022 · 2 comments · Fixed by #55999
Closed
2 tasks

(api) Use of None in QgsMeshRendererScalarSettings raises Python issues #51033

rduivenvoorde opened this issue Nov 28, 2022 · 2 comments · Fixed by #55999
Labels
API API improvement only, no visible user interface changes Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats)

Comments

@rduivenvoorde
Copy link
Contributor

What is the bug or the crash?

Playing with PyQGIS and Mesh layers, I hit the following:

According to:

https://qgis.org/pyqgis/master/core/QgsMeshRendererScalarSettings.html#qgis.core.QgsMeshRendererScalarSettings.DataResamplingMethod

You can set the DataResamplingMethod of QgsMeshRendererScalarSettings to None (0) or NeighbourAverage (1)

But while in a python console or pyqgis you can use QgsMeshRendererScalarSettings.NeighbourAverage (shows 1)

Both a script or the python console will give you an error if you try: QgsMeshRendererScalarSettings.None

Probably because None is a reserved keyword in Python?

Note that the following (for a Mesh layer which has None as resampling) works (it just returns 0)

iface.mapCanvas().currentLayer().rendererSettings().scalarSettings(iface.mapCanvas().currentLayer().rendererSettings().activeScalarDatasetGroup()).dataResamplingMethod()

So as a work around you can off course use .setDataResamplingMethod(0)

But I think it would be better to not use None as name of a constant?

Or am I missing a possibility?

https://github.com/qgis/QGIS/blob/master/src/core/mesh/qgsmeshrenderersettings.h#L111

Would that be an api break to change this? Or is there some other way (maybe in the sip steps?)

@PeterPetrik what do you think?

Steps to reproduce the issue

See above

Versions

master

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@rduivenvoorde rduivenvoorde added API API improvement only, no visible user interface changes Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats) labels Nov 28, 2022
@uclaros
Copy link
Contributor

uclaros commented Nov 28, 2022

As this is experimental API, I believe we could rename the enum value to NoResampling

@rduivenvoorde
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API improvement only, no visible user interface changes Bug Either a bug report, or a bug fix. Let's hope for the latter! Mesh Related to general mesh layer handling (not specific data formats)
Projects
None yet
2 participants