Skip to content

[searchlight] sys.exit used in _get_block_data #156

Closed

Description

@mihaic

https://github.com/IntelPNI/brainiak/blob/master/brainiak/searchlight/searchlight.py#L136
Instead, an exception should be raised (and documented) in distribute if the input data does not have the proper shape.

Activity

  1. YSanchezAraujo commented on Jun 21, 2017

    @YSanchezAraujo

    @mihaic are you saying the exception should be raised here instead of here

  2. mihaic commented on Jun 21, 2017

    @mihaic
    MemberAuthor

    @YSanchezAraujo, thanks for looking into this issue.

    Indeed, I am saying that an exception should be raised in distribute, such that the user code can decide what to do, instead of exiting the program as we are doing now. This is the approach we are using everywhere else in BrainIAK.

    In practice, in addition to raising an exception in _get_block_data, the exception should be caught and a new one raised in distribute (so the user does not see the implementation details in the traceback).

    Instead, it would be simpler to check the input shape in distribute and just remove the else code from _get_block_data.

  3. YSanchezAraujo commented on Jun 21, 2017

    @YSanchezAraujo

    thanks for the response, some questions:

    is the mask argument guaranteed to be a numpy array, and or the 4d arrays inside subjects, should there be an instance check and maybe a np.array(<argument>) if isinstance(<argument>, np.ndarray) returns false?

    thinking of something like:

    assert mask.ndim == 3, "mask should be a 3D array"
    
    for (idx, subj) in enumerate(subjects):
        assert subj.ndim == 4, \
        "expected 4D data for index {} in subjects".format(idx)
  4. mihaic commented on Jun 21, 2017

    @mihaic
    MemberAuthor

    We should also check mask. And arguments should be np.ndarray instances. It is better if users explicitly apply np.array to other data structures themselves and deal with potential issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions