-
Notifications
You must be signed in to change notification settings - Fork 106
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
leftaroundabout
wants to merge
18
commits into
odlgroup:master
from
leftaroundabout:compat/numpy-noimplicitobjectarray/discrops
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 80b1d8e
Failure to convert to array implies it is not a suitable input array.
leftaroundabout 30626fe
Disable a test that currently fails and is probably not worth support…
leftaroundabout 380ee09
Ensure interpolation weight is computed with the correct array type.
leftaroundabout c90044a
Ensure mesh coordinate calculations are not carried out with dtype=ob…
leftaroundabout bd73b42
Linter whitespace rules.
leftaroundabout 600fecd
For integral data, interpolating on integral points may not be approp…
leftaroundabout 3e3ea87
NumPy changed what exception is raised for ufunc-call with wrong numb…
leftaroundabout 16474de
Don't rely on obsolete NumPy inhomogenous arrays for boundary specifi…
leftaroundabout b6a912a
Explicitly go through elements that may need to be broadcasted in fn.…
leftaroundabout 2828057
Coding style details criticised by pep8speaks.
leftaroundabout 53c7760
Add warning when falling back to `float` for interpolation coefficients.
leftaroundabout 77e17f3
Manual broadcasting for the general tensor-with-inconsistent-dimensio…
leftaroundabout e80c43d
Revert "Disable a test that currently fails and is probably not worth…
leftaroundabout 3b38e7f
Change doc test to have floating zero.
leftaroundabout 7c5e31f
Omit unnecessary type coercion.
leftaroundabout 9b3f4f4
Only perform manual broadcasting in case NumPy fails to broadcast hom…
leftaroundabout de6bc52
Explicitly pass domain dimension as an argument to inhomogeneous-broa…
leftaroundabout File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?