Skip to content

Commit

Permalink
__str__ -> __repr__ (no generator yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-wagner committed Oct 2, 2020
1 parent 1852f11 commit f487e7c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
20 changes: 10 additions & 10 deletions pygimli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ def __BoundingBox_str(self):
s += "BoundingBox [{0}, {1}]".format(self.min(), self.max())
return s

_pygimli_.RVector.__str__ = __RVector_str
_pygimli_.CVector.__str__ = __RVector_str
_pygimli_.BVector.__str__ = __RVector_str
_pygimli_.IVector.__str__ = __RVector_str
_pygimli_.IndexArray.__str__ = __RVector_str
_pygimli_.RVector3.__str__ = __RVector3_str
_pygimli_.R3Vector.__str__ = __R3Vector_str

_pygimli_.Line.__str__ = __Line_str
_pygimli_.BoundingBox.__str__ = __BoundingBox_str
_pygimli_.RVector.__repr__ =__RVector_str
_pygimli_.CVector.__repr__ =__RVector_str
_pygimli_.BVector.__repr__ =__RVector_str
_pygimli_.IVector.__repr__ =__RVector_str
_pygimli_.IndexArray.__repr__ =__RVector_str
_pygimli_.RVector3.__repr__ =__RVector3_str
_pygimli_.R3Vector.__repr__ =__R3Vector_str

_pygimli_.Line.__repr__ =__Line_str
_pygimli_.BoundingBox.__repr__ =__BoundingBox_str

############################
# compatibility stuff
Expand Down
2 changes: 1 addition & 1 deletion pygimli/core/datacontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __DataContainer_str(self):
return "Data: Sensors: " + str(self.sensorCount()) + " data: " + \
str(self.size()) + ", nonzero entries: " +\
str([d for d in self.dataMap().keys() if self.haveData(d)])
DataContainer.__str__ = __DataContainer_str
DataContainer.__repr__ =__DataContainer_str


def __DataContainer_setSensors(self, sensors):
Expand Down
8 changes: 4 additions & 4 deletions pygimli/core/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def __ElementMatrix_str(self):
s += '\n'
return s

pgcore.RMatrix.__str__ = __RMatrix_str
pgcore.CMatrix.__str__ = __CMatrix_str
pgcore.ElementMatrix.__str__ = __ElementMatrix_str
pgcore.RMatrix.__repr__ =__RMatrix_str
pgcore.CMatrix.__repr__ =__CMatrix_str
pgcore.ElementMatrix.__repr__ =__ElementMatrix_str


## Special Monkeypatch core classes
Expand Down Expand Up @@ -160,7 +160,7 @@ def __BlockMatrix_str__(self):

pgcore.RBlockMatrix.addMatrix = __BlockMatrix_addMatrix_happy_GC__
pgcore.RBlockMatrix.add = __BlockMatrix_addMatrix_happy_GC__
pgcore.RBlockMatrix.__str__ = __BlockMatrix_str__
pgcore.RBlockMatrix.__repr__ =__BlockMatrix_str__
pgcore.RBlockMatrix.ndim = 2
# pgcore.CBlockMatrix.addMatrix = __BlockMatrix_addMatrix_happy_GC__
# pgcore.CBlockMatrix.add = __BlockMatrix_addMatrix_happy_GC__
Expand Down
6 changes: 3 additions & 3 deletions pygimli/core/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __Mesh_str(self):
st += d + " "

return st
Mesh.__str__ = __Mesh_str
Mesh.__repr__ =__Mesh_str


def __addPLCs__(self, other):
Expand All @@ -73,7 +73,7 @@ def __MeshEntity_str(self):
for n in self.nodes():
s += '\t' + str(n.id()) + " " + str(n.pos()) + "\n"
return s
MeshEntity.__str__ = __MeshEntity_str
MeshEntity.__repr__ =__MeshEntity_str


def __Node_str(self):
Expand All @@ -83,7 +83,7 @@ def __Node_str(self):
', Marker: ' + str(self.marker())
s += '\t' + str(self.pos()) + '\n'
return s
Node.__str__ = __Node_str
Node.__repr__ =__Node_str

# For Jupyer Notebook use.. check me
# Node.__repr__ = Node_str
Expand Down
2 changes: 1 addition & 1 deletion pygimli/physics/SIP/sipspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def __repr__(self):
"""String representation of the class."""
return self.__str__()

def __str__(self):
def __repr__(self):
"""Human readable string representation of the class."""
out = self.__class__.__name__ + " object"
if self.f is not None:
Expand Down
2 changes: 1 addition & 1 deletion pygimli/physics/traveltime/importData.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __call__(self):
self.load()
self.convert()

def __str__(self):
def __repr__(self):
s = 'header line: ' + self.header
s += '\nalldata length: {}\nfirst row: '.format(len(self.alldata))
s += str(self.alldata[0, :]) + '\nlast row: '
Expand Down
2 changes: 1 addition & 1 deletion pygimli/physics/traveltime/refraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# # self.inv = self.createInv(self.fop,
# # verbose=self.verbose, doSave=self.doSave)

# # def __str__(self): # no need to overwrite with identical content
# # def __repr__(self): # no need to overwrite with identical content
# # """string representation of the class"""
# # return self.__repr__()
# #
Expand Down
4 changes: 2 additions & 2 deletions pygimli/viewer/mpl/boreholes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, fname):
def __repr__(self):
return self.__class__.__name__ + '("{}")'.format(self._fname)

def __str__(self):
def __repr__(self):
out = 'Borehole id: {}\n Inline position (x, z): {}\n Layers:'.format(
self.borehole_id, self.inline_pos)

Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(self, fnames):
def __repr__(self):
return self.__class__.__name__ + '({})'.format(self._fnames)

def __str__(self):
def __repr__(self):
out = '{} borehole files loaded:'.format(len(self._fnames))

for b in self.boreholes:
Expand Down

0 comments on commit f487e7c

Please sign in to comment.