Skip to content

[mccall_model] Replace np.sum(a * b) with a @ b #471

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

UdohNakamura
Copy link

Replace np.sum(a * b) with a @ b
#463

@mmcky
Copy link
Contributor

mmcky commented Jul 1, 2025

thank you @UdohNakamura for this FIX - I have enabled the tests to run.

@mmcky mmcky requested a review from HumphreyYang July 1, 2025 02:14
reject = c + β * np.sum(v * q)
reject = c + β * (v @ q)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @UdohNakamura and @mmcky,

When building on my side I got

<string>:3: NumbaPerformanceWarning: '@' is faster on contiguous arrays, called on (Array(float64, 1, 'C', False, aligned=True), Array(float64, 1, 'A', False, aligned=True))

Upon checking, I found we annotate the type

    ('w', float64[:]),   # array of wage values, w[i] = wage at state i
    ('q', float64[:])    # array of probabilities

The following type will help (see more here:

    ('w', float64[::1]),   # array of wage values, w[i] = wage at state i
    ('q', float64[::1])    # array of probabilities

Please let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HumphreyYang Thanks, I didn't know that. Maybe write float64[::1] in place of float64[:] and explain that it is needed to have @ work inside a jitclass?

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.

4 participants