Skip to content

[BCG_complete_mkts] code error #221

Open

Description

@bishmaybarik

Hi @mmcky , I run the Google Colab version of the lecture named 38. Irrelevance of Capital Structures with Complete Markets, and this error pops up.

Image

Activity

  1. HumphreyYang commented on Aug 5, 2025

    @HumphreyYang
    Member

    Many thanks @bishmaybarik!

    I think we need to add pip install --upgrade kaleido for this lecture.

    You can see an example here:

    ```{code-cell} ipython3
    :tags: [hide-output]
    !pip install --upgrade quantecon
    !pip install --upgrade optax
    !pip install --upgrade statsmodels
    ```

    Would you like to self-assign this task and have a go at cleaning up the code?

  2. bishmaybarik commented on Aug 5, 2025

    @bishmaybarik
    MemberAuthor

    Hi @HumphreyYang, thanks for pointing it out. I had already tried the same

    !pip install --upgrade kaleido
    

    Yet, I end up getting the error. However this time, the error is about the incompatible versions of plotly and kaleido. Here's a snapshot:

    Image

    Also, once I try to upgrade plotly using

    !pip install plotly==6.1.1 --upgrade
    

    Here's the error that comes up:

    Image

    Re: self assigning task -- I would love to work on cleaning up the codes. But for some reason I can't self assign the task, possibly because I don't have the permissions. @mmcky could you please help me out with this?

  3. HumphreyYang commented on Aug 5, 2025

    @HumphreyYang
    Member

    Thanks @bishmaybarik,

    To fix this, I think we can convert it as HTML

    from IPython.display import HTML
    # Import plotly
    import plotly.graph_objs as go
    
    # Plot optimal k
    fig = go.Figure(data=[go.Surface(x=𝜒1grid, y=𝜒2grid, z=kgrid)])
    fig.update_layout(scene = dict(xaxis_title='x - 𝜒1',
                                   yaxis_title='y - 𝜒2',
                                   zaxis_title='z - k',
                                   aspectratio=dict(x=1,y=1,z=1)))
    fig.update_layout(width=500,
                      height=500,
                      margin=dict(l=50, r=50, b=65, t=90))
    fig.update_layout(scene_camera=dict(eye=dict(x=2, y=-2, z=1.5)))
    
    HTML(fig.to_html(full_html=False))
    

    This generates an interactive plot as HTML code, and when I built the lecture, we could interact with the figure in the QuantEcon lecture (CC @mmcky):

    Image

    Colab works as well on my side.

  4. bishmaybarik commented on Aug 5, 2025

    @bishmaybarik
    MemberAuthor

    Many thanks @HumphreyYang. Having this version with interactive graph solves the problem.

    Image

    Thanks again :-)

  5. jstac commented on Aug 5, 2025

    @jstac
    Contributor

    Hi @HumphreyYang @bishmaybarik @mmcky

    Thanks @bishmaybarik for flagging the problem and @HumphreyYang for the solution. Very nice work.

    However, do we really want to be adding this interactive stuff here?

    • What happens to the PDF?
    • How do we keep an eye on what's happening with the colab versions and the downloaded versions?
    • Should we be dealing with the extra libraries?

    Whenever we add complexity we eventually run into problems with PDFs, Colab, maintenance, etc.

    I have a very strong dislike for complexity.

    I suggest we drop the interactive view and just show the plot statically for a couple of different values of the correlation parameter.

    It might also be the case that the impact is clearer after switching from 3D to contour plots.

    @thomassargent30 might have views on this.

    Side notes: @mmcky , the greek letters used as variables in the code are rendered in a weird italic font. They should be rendered in the same font as the rest of the code, as they typically are in a code editor. Would you mind looking into this -- maybe open a separate issue?

    Another side note: This is a good example of a lecture where we could break up the large class as discussed earlier and then explain functions as we introduce them. This could also be a separate issue.

  6. self-assigned this
    on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions