Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overloading methods to Raster #73

Closed
atedstone opened this issue Feb 19, 2021 · 3 comments
Closed

Add overloading methods to Raster #73

atedstone opened this issue Feb 19, 2021 · 3 comments
Assignees
Labels
enhancement Feature improvement or request priority

Comments

@atedstone
Copy link
Member

We would like to be able to support operations like this:

im1 = Raster(...)
im2 = Raster(...)
combined = im1 + im2

At the moment, this requires a fairly unsemantic approach:

combined = im1.copy()
combined.data = combined.data + im2.data

Proposal: add operator overloading methods to the Raster class, e.g. __add__, __multiply__. See e.g. https://stackabuse.com/overloading-functions-and-operators-in-python/ for more info.

@atedstone atedstone added enhancement Feature improvement or request priority labels Feb 19, 2021
@adehecq
Copy link
Member

adehecq commented May 21, 2021

Now done for add/sub and neg with PR #173.
Still waiting to add mult/div to close this issue.

@adehecq adehecq self-assigned this May 21, 2021
@adehecq
Copy link
Member

adehecq commented Oct 15, 2021

See https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types for a list of arithmetic operations that can be overloaded, as well as for the difference between e.g __add__ and __radd__.

@adehecq
Copy link
Member

adehecq commented Oct 22, 2021

Closed via #257

@adehecq adehecq closed this as completed Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature improvement or request priority
Projects
None yet
Development

No branches or pull requests

2 participants