Action #1495
Clarify if csresmap works with Python 3
Status: | Closed | Start date: | 06/30/2015 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assigned To: | Mayer Michael | % Done: | 100% | |
Category: | - | |||
Target version: | 1.0.0 | |||
Duration: |
Description
I stumbled across these “Python 3.x does not like this” comments in csresmap:
https://github.com/ctools/ctools/blob/6955c7c078e36e4c39b83a13153114ec33ce9c38/scripts/csresmap.py#L272
https://github.com/ctools/ctools/blob/6955c7c078e36e4c39b83a13153114ec33ce9c38/scripts/csresmap.py#L282
elif self.m_algorithm == "SUBDIV": # Subtract and divide by model map self.resmap -= modelmap self.resmap /= modelmap # Python 3.x does not like this !!! #for pixel in modelmap: # if pixel != 0.0: # pixel = 1.0/pixel #self.resmap *= modelmap elif self.m_algorithm == "SUBDIVSQRT": # subtract and divide by sqrt of model map self.resmap -= modelmap self.resmap /= modelmap.sqrt() # Python 3.x does not like this !!! #for pixel in modelmap: # if pixel != 0.0: # pixel = 1.0/math.sqrt(pixel) #self.resmap *= modelmap
What needs to be done here? Fix or just remove that comment?
(tests pass for me and I’m using Python 3 ... does this mean it’s not covered or it works?)
Michael, if this doesn’t work and it’s not clear how to fix it, please re-assign the issue to me.
Recurrence
No recurrence.
Related issues
History
#1 Updated by Knödlseder Jürgen over 9 years ago
I think it works now, the comments are probably obsolete, but someone should check.
I added the following code to the GSkymap.i
interface that normally should fix this issue:
// Python 2.x operator/= GSkymap __idiv__(const GSkymap& map) { self->operator/=(map); return (*self); } // Python 3.x operator/= GSkymap __itruediv__(const GSkymap& map) { self->operator/=(map); return (*self); } // Python 2.x operator/= GSkymap __idiv__(const double& factor) { self->operator/=(factor); return (*self); } // Python 3.x operator/= GSkymap __itruediv__(const double& factor) { self->operator/=(factor); return (*self); }
Note: check #1341 for original issue on this topic.
#2 Updated by Mayer Michael over 9 years ago
It works for me but I don’t have Python 3
#3 Updated by Bregeon Johan over 9 years ago
I just tested and it works for me with python3.4 for gammalib/ctools available in git now.
#4 Updated by Mayer Michael over 9 years ago
great, thanks. I guess we can remove the comment and close the issue. Jürgen, there is a pending pull request for this file (#1439), maybe the comments can be removed while merging the code.
#5 Updated by Knödlseder Jürgen over 9 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
- Remaining (hours) set to 0.0