Skip to content

tuple unpacking in permutationTesting.py no longer compatible w/python3. Potential solution included. #2

@lindsayshaffer

Description

@lindsayshaffer

Hello,
I noticed the arguments for _maxTpermutation() from permutationTesting.py includes the tuple [diff_arr, nullmean, tail, seed] as our input.

Tuple unpacking is no longer compatible with python3, but the code still works in python2. I developed, however, a workaround for this fantastic script to run in python3:

Old code:

def _maxTpermutation((diff_arr,nullmean,tail,seed)):
    """
    Helper function to perform a single permutation
    """

    np.random.seed(seed)

New code:

def _maxTpermutation(t_tuple: tuple): -> int:
    """
    Helper function to perform a single permutation
    """ 

    diff_arr = t_tuple[0]
    nullmean = t_tuple[1]
    tail = t_tuple[2]
    seed = t_tuple[3]
    
    np.random.seed(seed)

I understand one solution could be to pass individual arguments, but our inputs is of variable length and incorporating type annotations allows your list of inputs to successfully pass through map_async(). Therefore, this solution should remain faithful to the logic of the original script.

I was able to successfully run pythonMaxT_Test.py with the new code. Hope this helps! I can submit a pull request for permutationTesting.py too, if you like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions