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

Change statcast pool from process to thread; fix TypeError #231

Merged
merged 2 commits into from
Aug 16, 2021

Conversation

TheCleric
Copy link
Contributor

@TheCleric TheCleric commented Aug 11, 2021

Fixes #229 by converting out ProcessPoolExecutor to a ThreadPoolExecutor. ProcessPoolExecutor is a little more picky about where it runs.

As well I was getting a TypeError in statcast_pitcher_spin.py when running the tests (python 3.7.9):

pybaseball/statcast_pitcher_spin.py:135: in find_phi
    df['phi'] = df['phi'].round(0).astype('int64')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = 0       190.754943
1       300.794706
2        243.13629
3        288.17292
4       291.559998
           ...    
4215...5478
4216    448.531754
4217    436.495487
4218    440.636358
4219    434.056495
Name: phi, Length: 4220, dtype: object
decimals = 0, args = (), kwargs = {}

    def round(self, decimals=0, *args, **kwargs) -> Series:
        """
        Round each value in a Series to the given number of decimals.
    
        Parameters
        ----------
        decimals : int, default 0
            Number of decimal places to round to. If decimals is negative,
            it specifies the number of positions to the left of the decimal point.
        *args, **kwargs
            Additional arguments and keywords have no effect but might be
            accepted for compatibility with NumPy.
    
        Returns
        -------
        Series
            Rounded values of the Series.
    
        See Also
        --------
        numpy.around : Round values of an np.array.
        DataFrame.round : Round values of a DataFrame.
    
        Examples
        --------
        >>> s = pd.Series([0.1, 1.3, 2.7])
        >>> s.round()
        0    0.0
        1    1.0
        2    3.0
        dtype: float64
        """
        nv.validate_round(args, kwargs)
>       result = self._values.round(decimals)
E       TypeError: loop of ufunc does not support argument 0 of type float which has no callable rint method

So I followed the recommendation to make sure the column is cast to a float first before rounding.

@schorrm schorrm merged commit 0935d8e into jldbc:master Aug 16, 2021
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

Successfully merging this pull request may close these issues.

Hanging on statcast imports
2 participants