Commit fecc16743c549c1896eed45ea6ff7930d8d64008
1 parent
061a2145
Implement division operators for Python 3.x.
Showing
3 changed files
with
23 additions
and
4 deletions
pyext/GEnergy.i
| ... | ... | @@ -97,9 +97,14 @@ public: |
| 97 | 97 | GEnergy __mul__(const double& factor) const { |
| 98 | 98 | return ((*self) * factor); |
| 99 | 99 | } |
| 100 | + // Python 2.x | |
| 100 | 101 | GEnergy __div__(const double& factor) const { |
| 101 | 102 | return ((*self) / factor); |
| 102 | 103 | } |
| 104 | + // Python 3.x | |
| 105 | + GEnergy __truediv__(const double& factor) const { | |
| 106 | + return ((*self) / factor); | |
| 107 | + } | |
| 103 | 108 | bool __eq__(const GEnergy& eng) const { |
| 104 | 109 | return ((*self) == eng); |
| 105 | 110 | } | ... | ... |
pyext/GSkymap.i
| ... | ... | @@ -201,12 +201,12 @@ public: |
| 201 | 201 | } |
| 202 | 202 | // Python 2.x operator/= |
| 203 | 203 | GSkymap __idiv__(const GSkymap& map) { |
| 204 | - self->operator /=(map); | |
| 204 | + self->operator/=(map); | |
| 205 | 205 | return (*self); |
| 206 | 206 | } |
| 207 | 207 | // Python 3.x operator/= |
| 208 | 208 | GSkymap __itruediv__(const GSkymap& map) { |
| 209 | - self->operator /=(map); | |
| 209 | + self->operator/=(map); | |
| 210 | 210 | return (*self); |
| 211 | 211 | } |
| 212 | 212 | }; | ... | ... |
pyext/GVector.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GVector.i - Vector class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2014 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -55,7 +55,6 @@ public: |
| 55 | 55 | GVector& operator+=(const double& value); |
| 56 | 56 | GVector& operator-=(const double& value); |
| 57 | 57 | GVector& operator*=(const double& value); |
| 58 | - GVector& operator/=(const double& value); | |
| 59 | 58 | GVector operator-(void) const; |
| 60 | 59 | |
| 61 | 60 | // Vector functions |
| ... | ... | @@ -105,9 +104,24 @@ public: |
| 105 | 104 | GVector __mul__(const double &a) { |
| 106 | 105 | return (*self) * a; |
| 107 | 106 | } |
| 107 | + // Python 2.x | |
| 108 | 108 | GVector __div__(const double &a) { |
| 109 | 109 | return (*self) / a; |
| 110 | 110 | } |
| 111 | + // Python 3.x | |
| 112 | + GVector __truediv__(const double &a) { | |
| 113 | + return (*self) / a; | |
| 114 | + } | |
| 115 | + // Python 2.x operator/= | |
| 116 | + GVector __idiv__(const double& value) { | |
| 117 | + self->operator/=(value); | |
| 118 | + return (*self); | |
| 119 | + } | |
| 120 | + // Python 3.x operator/= | |
| 121 | + GVector __itruediv__(const double& value) { | |
| 122 | + self->operator/=(value); | |
| 123 | + return (*self); | |
| 124 | + } | |
| 111 | 125 | int __is__(const GVector &a) { |
| 112 | 126 | return (*self) == a; |
| 113 | 127 | } | ... | ... |