Simplify np.max([np.max(prnus) + np.max(images)]) #1

Open
opened 2024-03-22 17:16:45 +01:00 by Benjamin_Loison · 0 comments

Context:

allImages = np.max([np.max(prnus) + np.max(images)])

np.max([prnus, images])
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/benjamin/.local/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2810, in max
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
  File "/home/benjamin/.local/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (2, 1) + inhomogeneous part.
np.array([prnus, images]).flatten()

does not help.

https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flatten.html

Context: https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/src/commit/72e37a252aa59ac620d441548a3740f0ab8fdcfc/datasets/fake/generate_dataset.py#L31 ```py np.max([prnus, images]) ``` ``` Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/benjamin/.local/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2810, in max return _wrapreduction(a, np.maximum, 'max', axis, None, out, File "/home/benjamin/.local/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (2, 1) + inhomogeneous part. ``` ```py np.array([prnus, images]).flatten() ``` does not help. https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flatten.html
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Benjamin_Loison/numpy#1
No description provided.