question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Very poor performance with Angle.__str__ and Angle._repr_latex_

See original GitHub issue

The following illustrates very poor performance with Angle.__str__ and Angle._repr_latex_ with arrays:

In [15]: a = Angle(np.ones(1000000), u.deg)

In [16]: %time a.__repr__()
CPU times: user 324 µs, sys: 23 µs, total: 347 µs
Wall time: 332 µs
Out[16]: '<Angle [ 1., 1., 1.,...,  1., 1., 1.] deg>'

In [17]: %time a.__str__()
CPU times: user 22.4 s, sys: 341 ms, total: 22.8 s
Wall time: 23.4 s
Out[17]: "['1d00m00s' '1d00m00s' '1d00m00s' ..., '1d00m00s' '1d00m00s' '1d00m00s']"

In [18]: %time a._repr_latex_()
CPU times: user 22.6 s, sys: 436 ms, total: 23.1 s
Wall time: 23.7 s
Out[18]: '[$1^\\circ00{}^\\prime00{}^{\\prime\\prime}$\n $1^\\circ00{}^\\prime00{}^{\\prime\\prime}$\n $1^\\circ00{}^\\prime00{}^{\\prime\\prime}$ ...,\n $1^\\circ00{}^\\prime00{}^{\\prime\\prime}$\n $1^\\circ00{}^\\prime00{}^{\\prime\\prime}$\n $1^\\circ00{}^\\prime00{}^{\\prime\\prime}$]'

This poor performance is unnecessary since only a few items are returned in the strings, and the rest is ...

This is not an issue with Quantity or Distance, but does percolate up to e.g. SkyCoord I think.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Dec 15, 2017

It seems clear that it is representing all the items – the solution likely is to pass on our own formatter to arrayprint - then the numpy machinery will take care of calling it only for those elements that are actually shown.

0reactions
mhvkcommented, Dec 18, 2017

Great! I think no additional tests are needed - this would be a performance label. We do want this in the benchmarks, but that is a different repo (maybe @astrofrog can advice)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code-Datasets/rank_list.txt at master - GitHub
Original data for the text to code experiments of Richardson and Kuhn - Code-Datasets/rank_list.txt at master · yakazimir/Code-Datasets.
Read more >
Full text of "Virginia Beach sun" - Internet Archive
1 full bath condo with cathedral ceilings at Broolcside. Op- tion to buy with non-qualifying FHA assumption. FAIRHELD Assume 7% mortgage, must qualify....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found