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

[Bug] NumPy Linear algebra Singular algebra error when manually moving the 3D view #4901

Open
echoix opened this issue Jan 1, 2025 · 0 comments
Labels
bug Something isn't working GUI wxGUI related

Comments

@echoix
Copy link
Member

echoix commented Jan 1, 2025

Describe the bug

I don't know exactly which of the two buttons I clicked triggered an error, but I stumbled upon a singular matrix error that was unhandled, when manually moving the 3D view map.

To reproduce

  1. Enable 3d view
  2. Add maps (I had raster and vectors) from the data box
  3. Click on the rotate 3D scene tool (orange 4 arrows), OR the zoom to map, then play around the map
  4. See error in the console tab

Expected behavior

Inverting a matrix can happen to hit a singular matrix, we can't beat the maths on this. I did not expect to have it unhandled and have a long traceback in the console window though. Could we be handling this better?

Screenshots

image

The saved log:
grass_cmd_output.txt

In text here to help for searches:

Details

Starting 3D view mode...                                                        
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\gui_core\
treeview.py", line 71, in <lambda>

lambda evt: self._emitSignal(evt.GetItem(),
self.itemActivated),
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\gui_core\
treeview.py", line 197, in _emitSignal

signal.emit(node=node, **kwargs)
  File "C:\OSGeo4W\apps\grass\grass85\etc\python\grass\pydis
patch\signal.py", line 229, in emit

dispatcher.send(signal=self, *args, **kwargs)
  File "C:\OSGeo4W\apps\grass\grass85\etc\python\grass\pydis
patch\dispatcher.py", line 340, in send

response = robustapply.robustApply(

^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\grass\grass85\etc\python\grass\pydis
patch\robustapply.py", line 90, in robustApply

return receiver(*arguments, **named)



^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\datacatal
og\tree.py", line 897, in OnDoubleClick

self.DisplayLayer()
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\datacatal
og\tree.py", line 1691, in DisplayLayer

self._giface.GetMapWindow().ZoomToMap()
TypeError
:
GLWindow.ZoomToMap() missing 1 required positional argument:
'layers'
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix
Vector map <boundary_region@PERMANENT> loaded (2 features)
Loading raster map <basins_georect20800@PERMANENT>...
Vector map <census@PERMANENT> loaded (8695 features)
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 643, in OnMouseAction

self.OnDragging(event)
  File "C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\mapw
indow.py", line 740, in OnDragging

angle, x, y, z = self._display.GetRotationParameters(dx, dy)^
^
^
^
  File
"C:\OSGeo4W\apps\grass\grass85\gui\wxpython\nviz\wxnviz.py",
line 2243, in GetRotationParameters

inv = matrix(m).I


^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\matrixlib\defmatrix.py", line 836, in I

return asmatrix(func(self))



^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 561, in inv

ainv = _umath_linalg.inv(a, signature=signature,
extobj=extobj)
^
^
^
^
^
^
^
^
^
^
^
^
  File "C:\OSGeo4W\apps\Python312\Lib\site-
packages\numpy\linalg\linalg.py", line 112, in
_raise_linalgerror_singular

raise LinAlgError("Singular matrix")
numpy.linalg
.
LinAlgError
:
Singular matrix

System description

  • Operating System: Windows 11 24H2 26100.2605

  • GRASS GIS version: 8.5 dev, from osgeo4w grass-dev 8.5-435-68a51f64a-1 for 68a51f6

  • details about further software components

$ g.version -rge
version=8.5.0dev
date=2024
revision=68a51f64a
build_date=2024-12-31
build_platform=x86_64-w64-mingw32
build_off_t_size=8
libgis_revision=5c1ea4afc
libgis_date=2024-11-29T10:01:48+00:00
proj=9.5.0
gdal=3.9.3
geos=3.13.0
sqlite=3.46.1

$ python3 -c "import sys, wx; print(sys.version); print(wx.version())"
3.12.8 (main, Dec 20 2024, 15:21:15) [MSC v.1938 64 bit (AMD64)]
4.2.2 msw (phoenix) wxWidgets 3.2.6

Additional context

When working on nviz/3D view gui code recently, I saw that there were some warnings suggesting to use plain ndarrays instead of the "matrix" object we use there. It will probably not fix the math issue though.

@echoix echoix added bug Something isn't working GUI wxGUI related labels Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related
Projects
None yet
Development

No branches or pull requests

1 participant