• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

QuantEcon / QuantEcon.py / 18963640808
93%

Build:
DEFAULT BRANCH: main
Ran 31 Oct 2025 05:31AM UTC
Jobs 3
Files 162
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

31 Oct 2025 05:26AM UTC coverage: 92.579%. Remained the same
18963640808

push

github

web-flow
Optimize shorrocks_index (#810)

The optimization replaces `np.diag(A).sum()` with `np.trace(A)` to compute the sum of diagonal elements. This single change provides a 9% speedup because:

**What changed:** The diagonal sum calculation was changed from a two-step process (`np.diag()` then `.sum()`) to a single optimized NumPy function (`np.trace()`).

**Why it's faster:** `np.trace()` is specifically designed to compute the sum of diagonal elements directly, avoiding the intermediate array creation that `np.diag()` requires. The line profiler shows the diagonal sum computation time decreased from 680,989 ns to 600,218 ns (12% faster for that line).

**Performance characteristics:** The optimization is most effective for:
- Small to medium matrices (2x2 to 500x500) where it shows consistent 8-16% improvements
- Dense matrices where diagonal access patterns matter
- Identity matrices and structured matrices benefit significantly

However, for very large sparse matrices or random matrices with complex access patterns, the optimization may show smaller gains or even slight regressions (as seen in the large random test cases), likely due to cache behavior differences. Overall, this is a clean micro-optimization that improves performance across most typical use cases without changing any behavior or dependencies.

Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>

1 of 1 new or added line in 1 file covered. (100.0%)

7710 of 8328 relevant lines covered (92.58%)

2.78 hits per line

Jobs
ID Job ID Ran Files Coverage
1 18963640808.1 31 Oct 2025 05:31AM UTC 162
92.58
GitHub Action Run
2 18963640808.2 31 Oct 2025 05:31AM UTC 162
92.58
GitHub Action Run
3 18963640808.3 31 Oct 2025 05:31AM UTC 162
92.58
GitHub Action Run
Source Files on build 18963640808
  • Tree
  • List 162
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 3ba4f745 on github
  • Prev Build on main (#18712862855)
  • Next Build on main (#18963651100)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc