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

Fixing issues related to dtype=object arrays in interpolation routines #1649

Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2b3edef
Ensure the distances to computed linear-interpolation weights from ar…
leftaroundabout Aug 8, 2024
80b1d8e
Failure to convert to array implies it is not a suitable input array.
leftaroundabout Aug 8, 2024
30626fe
Disable a test that currently fails and is probably not worth support…
leftaroundabout Aug 8, 2024
380ee09
Ensure interpolation weight is computed with the correct array type.
leftaroundabout Aug 8, 2024
c90044a
Ensure mesh coordinate calculations are not carried out with dtype=ob…
leftaroundabout Aug 8, 2024
bd73b42
Linter whitespace rules.
leftaroundabout Aug 8, 2024
600fecd
For integral data, interpolating on integral points may not be approp…
leftaroundabout Aug 9, 2024
3e3ea87
NumPy changed what exception is raised for ufunc-call with wrong numb…
leftaroundabout Aug 12, 2024
16474de
Don't rely on obsolete NumPy inhomogenous arrays for boundary specifi…
leftaroundabout Aug 13, 2024
b6a912a
Explicitly go through elements that may need to be broadcasted in fn.…
leftaroundabout Aug 13, 2024
2828057
Coding style details criticised by pep8speaks.
leftaroundabout Aug 14, 2024
53c7760
Add warning when falling back to `float` for interpolation coefficients.
leftaroundabout Aug 27, 2024
77e17f3
Manual broadcasting for the general tensor-with-inconsistent-dimensio…
leftaroundabout Aug 29, 2024
e80c43d
Revert "Disable a test that currently fails and is probably not worth…
leftaroundabout Aug 29, 2024
3b38e7f
Change doc test to have floating zero.
leftaroundabout Aug 29, 2024
7c5e31f
Omit unnecessary type coercion.
leftaroundabout Aug 29, 2024
9b3f4f4
Only perform manual broadcasting in case NumPy fails to broadcast hom…
leftaroundabout Aug 29, 2024
de6bc52
Explicitly pass domain dimension as an argument to inhomogeneous-broa…
leftaroundabout Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions odl/discr/discr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,12 +1339,12 @@ def dual_use_func(x, out=None, **kwargs):
elif tensor_valued:
# The out object can be any array-like of objects with shapes
# that should all be broadcastable to scalar_out_shape.
results = np.array(out)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test relates to the function func_tens_oop, which checks that ODL broadcasts a list of float values to declare a numpy array to the appropriate numpy lingo. For now, what about adding a deprecation warning to this test?

if results.dtype == object or scalar_in:

if any(res.shape != scalar_out_shape for res in out) or scalar_in:
# Some results don't have correct shape, need to
# broadcast
bcast_res = []
for res in results.ravel():
for res in out:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loops only through the outer dimension. I think we should either remove the broadcasting all together or make it general.

if ndim == 1:
# As usual, 1d is tedious to deal with. This
# code deals with extra dimensions in result
Expand All @@ -1355,17 +1355,17 @@ def dual_use_func(x, out=None, **kwargs):
if shp and shp[0] == 1:
res = res.reshape(res.shape[1:])
bcast_res.append(
np.broadcast_to(res, scalar_out_shape))
np.broadcast_to(res, scalar_out_shape).astype(scalar_out_dtype))

out_arr = np.array(bcast_res, dtype=scalar_out_dtype)
elif results.dtype != scalar_out_dtype:
else:
out_arr = np.asarray(out)
if out_arr.dtype != scalar_out_dtype:
raise ValueError(
'result is of dtype {}, expected {}'
''.format(dtype_repr(results.dtype),
''.format(dtype_repr(out_arr.dtype),
dtype_repr(scalar_out_dtype))
)
else:
out_arr = results

out = out_arr.reshape(out_shape)

Expand Down