gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
30 stars 15 forks source link

Avoid in-place multiplication of color list #133

Closed eldond closed 3 years ago

eldond commented 3 years ago
smithsp commented 3 years ago

Maybe https://matplotlib.org/cycler/ would be helpful here?

eldond commented 3 years ago

@smithsp it doesn't seem easy to use cycler this time. I want definite colors for each value of a counter, and I may use two loops over the same thing in places.

codecov[bot] commented 3 years ago

Codecov Report

Merging #133 into master will decrease coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
- Coverage   79.80%   79.80%   -0.01%     
==========================================
  Files          50       50              
  Lines        9562     9561       -1     
==========================================
- Hits         7631     7630       -1     
  Misses       1931     1931              
Impacted Files Coverage Δ
omas/omas_plot.py 78.76% <100.00%> (-0.02%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 98f9528...25bc839. Read the comment docs.

smithsp commented 3 years ago

@eldond Maybe the matplotlib cycler was too much. I investigated further and it uses itertools.cycle underneath, which could be used as:

for i,(l,c) in enumerate(zip(labels,itertools.cycle(colors))):

or

colors = [c for c in zip(labels, itertools.cycle(color))]
...
   colors[i]
eldond commented 3 years ago

@smithsp I don't know how to test for how the plots look in terms of using consistent or reasonable colors, so the unit tests won't catch a problem with the wrong coloration due to a mishap with a cycler. So, that increases the time and effort required for redevelopment and testing and I can't do it right now. You're welcome to take over or open an issue if you think it's important. I agree that using a cycler from the start would've been nicer than these lists, and I'll try to remember to do that next time.

smithsp commented 3 years ago

@eldond I'm not going to take over. I just wanted to make sure that you were aware when you have the bandwidth.