Skip to content

Conversation

mmcky
Copy link
Contributor

@mmcky mmcky commented Jul 29, 2025

This PR upgrades

  • ananconda=2025.06
  • python=3.13
  • quantecon-book-theme=0.9.2 (fixes for modal issues)

and associated compatible build infrastructure.

Tasks

@github-actions github-actions bot temporarily deployed to commit July 30, 2025 00:00 Inactive
@mmcky
Copy link
Contributor Author

mmcky commented Jul 30, 2025

  • fix execution incompatibilities with anaconda=2025.06 and numpy>=2.0

amss.err.log
amss2.err.log
amss3.err.log
match_transport.err.log

Copy link

netlify bot commented Aug 5, 2025

Deploy Preview for lustrous-melomakarona-3ee73e ready!

Name Link
🔨 Latest commit 3af6f28
🔍 Latest deploy log https://app.netlify.com/projects/lustrous-melomakarona-3ee73e/deploys/68d1012de5f1d100089e51f7
😎 Deploy Preview https://deploy-preview-215--lustrous-melomakarona-3ee73e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mmcky
Copy link
Contributor Author

mmcky commented Aug 25, 2025

@kp992 this is currently blocked by amss and the interpolations package.

There are some suggestions in #223

We were thinking of Step 1 removing our dependency on interpolations then Step 2 look at converting this lecture to JAX. @HumphreyYang and I gave copilot a go in #244 if those ideas are helpful. Also please liaise with @HumphreyYang through #236 for the jax translation but I think Step 1 would be good to do first.

@kp992
Copy link
Collaborator

kp992 commented Aug 25, 2025

Thanks @mmcky. I will look into it.

@HumphreyYang
Copy link
Member

HumphreyYang commented Aug 25, 2025

Many thanks @mmcky and @kp992,

There is a drop-in replacement for the interpolation in #228.

We can move it into one of script in the static Python file.

This produces the same figures.

Here is a copy of the replacement if that is helpful:

@njit
def get_grid_nodes(grid):
    """
    Get the actual grid points from a grid tuple.
    """
    x_min, x_max, x_num = grid
    return np.linspace(x_min, x_max, x_num)

@njit
def linear_interp_1d_scalar(x_min, x_max, x_num, y_values, x_val):
    """Helper function for scalar interpolation"""
    x_nodes = np.linspace(x_min, x_max, x_num)

    # Extrapolation with linear extension
    if x_val <= x_nodes[0]:
        # Linear extrapolation using first two points
        if x_num >= 2:
            slope = (y_values[1] - y_values[0]) / (x_nodes[1] - x_nodes[0])
            return y_values[0] + slope * (x_val - x_nodes[0])
        else:
            return y_values[0]

    if x_val >= x_nodes[-1]:
        # Linear extrapolation using last two points
        if x_num >= 2:
            slope = (y_values[-1] - y_values[-2]) / (x_nodes[-1] - x_nodes[-2])
            return y_values[-1] + slope * (x_val - x_nodes[-1])
        else:
            return y_values[-1]

    # Binary search for the right interval
    left = 0
    right = x_num - 1
    while right - left > 1:
        mid = (left + right) // 2
        if x_nodes[mid] <= x_val:
            left = mid
        else:
            right = mid

    # Linear interpolation
    x_left = x_nodes[left]
    x_right = x_nodes[right]
    y_left = y_values[left]
    y_right = y_values[right]

    weight = (x_val - x_left) / (x_right - x_left)
    return y_left * (1 - weight) + y_right * weight

@njit
def linear_interp_1d(x_grid, y_values, x_query):
    """
    Perform 1D linear interpolation.
    """
    x_min, x_max, x_num = x_grid
    return linear_interp_1d_scalar(x_min, x_max, x_num, y_values, x_query[0])

@kp992
Copy link
Collaborator

kp992 commented Aug 26, 2025

Thanks @HumphreyYang for sharing this. Should we add this in the quantecon package? This is because we can reuse the same snippets across all the series?

@HumphreyYang
Copy link
Member

HumphreyYang commented Sep 21, 2025

Thanks @HumphreyYang for sharing this. Should we add this in the quantecon package? This is because we can reuse the same snippets across all the series?

I think for now we can put it into the script that is used across the lecture since we are going to rewrite things in JAX later.

@HumphreyYang
Copy link
Member

Hi @mmcky, I will use this PR to test the workaround now.

Copy link

github-actions bot commented Sep 21, 2025

@github-actions github-actions bot temporarily deployed to pull request September 21, 2025 03:14 Inactive
@mmcky
Copy link
Contributor Author

mmcky commented Sep 21, 2025

@HumphreyYang nice work!

The preview is looking pretty good. Are you happy for me to merge this?

@mmcky
Copy link
Contributor Author

mmcky commented Sep 21, 2025

@HumphreyYang it is interesting that the modal issue is still a problem in this preview build. So this isn't going to directly solve the problem.

@HumphreyYang
Copy link
Member

@HumphreyYang nice work!

The preview is looking pretty good. Are you happy for me to merge this?

Sounds great! I will commence stage 2 when migrating it to JAX since JAX result looks a bit different.

@HumphreyYang it is interesting that the modal issue is still a problem in this preview build.

Could you please let me know which model issue you are referring to?

@mmcky
Copy link
Contributor Author

mmcky commented Sep 22, 2025

@HumphreyYang nice work!
The preview is looking pretty good. Are you happy for me to merge this?

Sounds great! I will commence stage 2 when migrating it to JAX since JAX result looks a bit different.

@HumphreyYang it is interesting that the modal issue is still a problem in this preview build.

Could you please let me know which model issue you are referring to?

Thanks @HumphreyYang a modal is an html object that shows as a window. The colab button should show a modal :-)

@kp992
Copy link
Collaborator

kp992 commented Sep 22, 2025

Thanks @HumphreyYang and @mmcky for taking it forward. I missed the track of this PR somehow while working on the other JAX lectures.

@HumphreyYang
Copy link
Member

Thanks @HumphreyYang a modal is an html object that shows as a window. The colab button should show a modal :-)

Ah roger that. I thought the namedtuple model has some problem : )

@mmcky
Copy link
Contributor Author

mmcky commented Sep 22, 2025

@HumphreyYang, @kp992 has submitted a patch to fix the modal issue on the theme. Are you happy if we merge this as we will need the later version of sphinx unless we want to back port the fix to an earlier version of quantecon-book-theme but that is a lot of work. I'd prefer to merge this if we can.

@HumphreyYang
Copy link
Member

Hi @mmcky, please feel free to merge when you are ready!

@mmcky
Copy link
Contributor Author

mmcky commented Sep 22, 2025

if works then,

@github-actions github-actions bot temporarily deployed to pull request September 22, 2025 04:03 Inactive
@mmcky
Copy link
Contributor Author

mmcky commented Sep 22, 2025

thanks @kp992 and @HumphreyYang -- once I get the green tick of approval I will merge this.

@github-actions github-actions bot temporarily deployed to pull request September 22, 2025 08:16 Inactive
@mmcky mmcky merged commit d65b66e into main Sep 22, 2025
9 checks passed
@mmcky mmcky deleted the maint-software branch September 22, 2025 08:20
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.

3 participants