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

LinearMapper.map_screen should return scalar output for scalar input. #486

Closed
mdickinson opened this issue Oct 30, 2019 · 2 comments
Closed

Comments

@mdickinson
Copy link
Member

The LinearMapper.map_screen method normally returns a scalar output given scalar input. However, if self._null_data_range is True, it'll return a 1d array instead of a scalar, given scalar input.

While we're here, there's also an isinstance check that makes little sense: it checks for either an ndarray, a tuple, or a list, but then looks up the .shape attribute in all three cases:

if isinstance(data_array, (tuple, list, ndarray)):
x = empty(data_array.shape)

@mdickinson
Copy link
Member Author

@rkern points out on another repository that:

map_screen() is not a very coherent interface. In some of the AbstractMapper interfaces, like LinearMapper, map_screen() behaves inconsistently when given a scalar. If the data range is null, it returns a 1-element array. When it has a non-null data range, it computes the result via a very standard arithmetic expression involving only scalars, so the result is a scalar. In others, like LogMapper, it coerces the input to an array first so it always returns an array, regardless of branch. Returning an array is the intended interface of map_screen(), it seems.

@mdickinson
Copy link
Member Author

Closing this; from discussion, map_screen should be returning arrays. (There's still the looking up .shape on a list/tuple part, but that's a separate issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant