TALON icon indicating copy to clipboard operation
TALON copied to clipboard

test failures on the development branch "argument "ascending" expected type bool, received type str."

Open detrout opened this issue 2 years ago • 0 comments

While running tests on the development branch with these software versions;

attrs==21.4.0,iniconfig==1.1.1,numpy==1.22.3,packaging==21.3,pandas==1.4.2,pluggy==1.0.0,py==1.11.0,pybedtools==0.9.0,pyfaidx==0.6.4,pyparsing==3.0.8,pysam==0.15.4,pytest==7.1.1,python-dateutil==2.8.2,pytz==2022.1,six==1.16.0,talon @ file:///woldlab/loxcyc/home/diane/proj/talon/.tox/.tmp/package/1/talon-5.0.zip,tomli==2.0.1

I got this error:

test_longest_ends.py:22: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../.tox/py3/lib/python3.9/site-packages/talon/post/call_longest_ends.py:76: in get_longest_ends
    df = df.sort_values(by='transcript_ID', ascending='True')
../.tox/py3/lib/python3.9/site-packages/pandas/util/_decorators.py:311: in wrapper
    return func(*args, **kwargs)
../.tox/py3/lib/python3.9/site-packages/pandas/core/frame.py:6286: in sort_values
    ascending = validate_ascending(ascending)
../.tox/py3/lib/python3.9/site-packages/pandas/util/_validators.py:433: in validate_ascending
    return validate_bool_kwarg(ascending, "ascending", **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

value = 'True', arg_name = 'ascending', none_allowed = False, int_allowed = True

    def validate_bool_kwarg(value, arg_name, none_allowed=True, int_allowed=False):
        """
        Ensure that argument passed in arg_name can be interpreted as boolean.
    
        Parameters
        ----------
        value : bool
            Value to be validated.
        arg_name : str
            Name of the argument. To be reflected in the error message.
        none_allowed : bool, default True
            Whether to consider None to be a valid boolean.
        int_allowed : bool, default False
            Whether to consider integer value to be a valid boolean.
    
        Returns
        -------
        value
            The same value as input.
    
        Raises
        ------
        ValueError
            If the value is not a valid boolean.
        """
        good_value = is_bool(value)
        if none_allowed:
            good_value = good_value or value is None
    
        if int_allowed:
            good_value = good_value or isinstance(value, int)
    
        if not good_value:
>           raise ValueError(
                f'For argument "{arg_name}" expected type bool, received '
                f"type {type(value).__name__}."
            )
E           ValueError: For argument "ascending" expected type bool, received type str.

../.tox/py3/lib/python3.9/site-packages/pandas/util/_validators.py:251: ValueError

I'm pretty sure this is the right solution:

modified   src/talon/post/call_longest_ends.py
@@ -73,7 +73,7 @@ def get_longest_ends(df, how='tes', novelty='novel', datasets='all'):
     # concat fwd and rev
     df = pd.concat([fwd, rev])
 
-    df = df.sort_values(by='transcript_ID', ascending='True')
+    df = df.sort_values(by='transcript_ID', ascending=True)
 
     return df

detrout avatar Apr 20 '22 21:04 detrout