projects
/
linpy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
af70cb2
)
Simplify implementation of Coordinates.__new__()
author
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 13:09:17 +0000
(15:09 +0200)
committer
Vivien Maisonneuve
<v.maisonneuve@gmail.com>
Tue, 19 Aug 2014 13:09:17 +0000
(15:09 +0200)
linpy/geometry.py
patch
|
blob
|
history
diff --git
a/linpy/geometry.py
b/linpy/geometry.py
index
43344e4
..
cc19a72
100644
(file)
--- a/
linpy/geometry.py
+++ b/
linpy/geometry.py
@@
-85,14
+85,15
@@
class Coordinates:
if isinstance(coordinates, Mapping):
coordinates = coordinates.items()
self = object().__new__(cls)
if isinstance(coordinates, Mapping):
coordinates = coordinates.items()
self = object().__new__(cls)
- self._coordinates = OrderedDict()
- for symbol, coordinate in sorted(coordinates,
- key=lambda item: item[0].sortkey()):
+ self._coordinates = []
+ for symbol, coordinate in coordinates:
if not isinstance(symbol, Symbol):
raise TypeError('symbols must be Symbol instances')
if not isinstance(coordinate, numbers.Real):
raise TypeError('coordinates must be real numbers')
if not isinstance(symbol, Symbol):
raise TypeError('symbols must be Symbol instances')
if not isinstance(coordinate, numbers.Real):
raise TypeError('coordinates must be real numbers')
- self._coordinates[symbol] = coordinate
+ self._coordinates.append((symbol, coordinate))
+ self._coordinates.sort(key=lambda item: item[0].sortkey())
+ self._coordinates = OrderedDict(self._coordinates)
return self
@property
return self
@property