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

QuantEcon / QuantEcon.py / 18963640808 / 2
93%
main: 93%

Build:
DEFAULT BRANCH: main
Ran 31 Oct 2025 05:31AM UTC
Files 162
Run time 4s
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.2

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>

7710 of 8328 relevant lines covered (92.58%)

0.93 hits per line

Source Files on job 18963640808.2
  • Tree
  • List 162
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 18963640808
  • 3ba4f745 on github
  • Prev Job for on main (#18712862855.1)
  • Next Job for on main (#18963651100.1)
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