X Tutup
Skip to content

Cast stackplot input to float when required.#7827

Merged
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:stackplot-integer-input
Jan 15, 2017
Merged

Cast stackplot input to float when required.#7827
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:stackplot-integer-input

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented Jan 14, 2017

See #7802.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 14, 2017

Current coverage is 62.10% (diff: 100%)

Merging #7827 into master will not change coverage

@@             master      #7827   diff @@
==========================================
  Files           174        174          
  Lines         56052      56052          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          34809      34809          
  Misses        21243      21243          
  Partials          0          0          

Powered by Codecov. Last update 9edcb03...c87133a

Copy link
Copy Markdown
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

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

I have a minor comment, but else LGTM 👍

# Assume data passed has not been 'stacked', so stack it here.
stack = np.cumsum(y, axis=0)
# We'll need a float buffer for the upcoming calculations.
stack = np.cumsum(y, axis=0).astype(np.promote_types(y.dtype, np.float32))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use np.cumsum's dtype's argument instead of casting explicitly after the sum.

np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a performance, functional, or an aesthetic improvement?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have no clue what it does under the hood, so it might be a performance improvement or just aesthetic improvement. It might avoid a memory allocation, but I wouldn't bet on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No idea whether it is optimized to avoid the memory allocation but at least it could do so in theory, whereas astype certainly cannot... so I changed it accordingly.

@NelleV NelleV changed the title Cast stackplot input to float when required. [MRG+1] Cast stackplot input to float when required. Jan 14, 2017
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Jan 14, 2017
@tacaswell
Copy link
Copy Markdown
Member

Please do not backport until after 2.0

@anntzer anntzer force-pushed the stackplot-integer-input branch from c87133a to e81b280 Compare January 15, 2017 04:14
@tacaswell tacaswell merged commit 86bf661 into matplotlib:master Jan 15, 2017
@tacaswell
Copy link
Copy Markdown
Member

Thanks!

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Jan 30, 2017

Backported to v2.0.x as 7cd3068.

@QuLogic QuLogic changed the title [MRG+1] Cast stackplot input to float when required. Cast stackplot input to float when required. Jan 30, 2017
@anntzer anntzer deleted the stackplot-integer-input branch January 30, 2017 03:26
QuLogic pushed a commit that referenced this pull request Jan 30, 2017
MNT: Cast stackplot input to float when required.
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.

5 participants

X Tutup