Skip to content

Python warnings found in code output #548

Closed

Description

@github-actions

Python Warnings Detected

🚨 12 Python warning(s) were found in the HTML output during the documentation build.

Details:

  • Repository: QuantEcon/lecture-python.myst
  • Workflow: Build Project [using jupyter-book]
  • Run ID: 17004617251
  • Commit: abcb9f1
  • Branch: 529/merge
  • Date: 2025-08-16T05:31:34.512Z

RuntimeWarning in ./_build/html/back_prop.html

Found 2 instance(s):

1:/home/runner/miniconda3/envs/quantecon/lib/python3.12/pty.py:95: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.
  pid, fd = os.forkpty()

RuntimeWarning in ./_build/html/two_auctions.html

Found 8 instance(s):

6:/tmp/ipykernel_8932/521884726.py:25: RuntimeWarning: Mean of empty slice.
  return array_conditional[-order,:].mean()
/home/runner/miniconda3/envs/quantecon/lib/python3.12/site-packages/numpy/core/_methods.py:129: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)
6:/tmp/ipykernel_8932/919518230.py:37: RuntimeWarning: Mean of empty slice.
  return array_conditional[-order,:].mean()
/home/runner/miniconda3/envs/quantecon/lib/python3.12/site-packages/numpy/core/_methods.py:129: RuntimeWarning: invalid value encountered in scalar divide
  ret = ret.dtype.type(ret / rcount)

RuntimeWarning in ./_build/html/status.html

Found 2 instance(s):

1:/home/runner/miniconda3/envs/quantecon/lib/python3.12/pty.py:95: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.
  pid, fd = os.forkpty()

Next Steps:

  1. Review the warnings listed above
  2. Fix the underlying code that's generating these warnings
  3. Re-run the build to verify the warnings are resolved

Note: This issue was automatically created by the Check for Python Warnings Action.

Please close this issue once all warnings have been addressed.

Activity

  1. added
    bug
    on Aug 16, 2025
  2. HumphreyYang commented on Aug 17, 2025

    @HumphreyYang
    Member

    Hi @mmcky,

    I think I figured out the source of the fork warnings:

    Image

    It is not easy : (

    ipython syntax sugar ! calls system function in

    https://github.com/ipython/ipython/blob/cbac235320fe91056a0fb6dba74cd8bef7fc21d9/IPython/core/interactiveshell.py#L2622-L2643

    which involves pexpect.spawn() that calls ptyprocess.PtyProcess.spawn() that calls os.forkpty()

    https://github.com/ipython/ipython/blob/cbac235320fe91056a0fb6dba74cd8bef7fc21d9/IPython/utils/_process_posix.py#L122-L126

    pexpect.spawn()
    ↓
    ptyprocess.PtyProcess.spawn()
    ↓
    os.forkpty() 
    

    I think we can try to use

    import os
    os.system("nvidia-smi");
    

    to avoid it:

    Image

    I think it's the same issue in the back_prop. I will run some tests to see.

  3. mmcky commented on Aug 18, 2025

    @mmcky
    Contributor

    Nice work @HumphreyYang.

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

Metadata

Metadata

Labels

bugexecutionpython-warnings

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions