Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 79983a9

Browse files
author
Jonathan Kliem
committed
fix pickling of representation objects with backend normaliz
1 parent d6c5cd9 commit 79983a9

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

src/sage/geometry/polyhedron/backend_normaliz.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,12 +1272,28 @@ def __getstate__(self):
12721272
A vertex at (0, 0, 1, 0),
12731273
A vertex at (0, 1, 0, 0),
12741274
A vertex at (1, 0, 0, 0)),
1275-
'_normaliz_field': Rational Field})
1275+
'_normaliz_field': Rational Field,
1276+
'_pickle_equations': [(-1, 1, 1, 1, 1)],
1277+
'_pickle_inequalities': [(0, 0, 0, 0, 1),
1278+
(0, 0, 0, 1, 0),
1279+
(0, 0, 1, 0, 0),
1280+
(0, 1, 0, 0, 0)],
1281+
'_pickle_lines': [],
1282+
'_pickle_rays': [],
1283+
'_pickle_vertices': [(0, 0, 0, 1),
1284+
(0, 0, 1, 0),
1285+
(0, 1, 0, 0),
1286+
(1, 0, 0, 0)]})
12761287
"""
12771288
state = super(Polyhedron_normaliz, self).__getstate__()
12781289
state = (state[0], state[1].copy())
12791290
# Remove the unpicklable entries.
12801291
del state[1]['_normaliz_cone']
1292+
state[1]["_pickle_vertices"] = [v._vector for v in self.vertices()]
1293+
state[1]["_pickle_rays"] = [v._vector for v in self.rays()]
1294+
state[1]["_pickle_lines"] = [v._vector for v in self.lines()]
1295+
state[1]["_pickle_inequalities"] = [v._vector for v in self.inequalities()]
1296+
state[1]["_pickle_equations"] = [v._vector for v in self.equations()]
12811297
return state
12821298

12831299
def __setstate__(self, state):
@@ -1327,16 +1343,32 @@ def __setstate__(self, state):
13271343
sage: P == P2 # optional - pynormaliz
13281344
True
13291345
"""
1346+
if "_pickle_vertices" in state[1]:
1347+
vertices = state[1].pop("_pickle_vertices")
1348+
rays = state[1].pop("_pickle_rays")
1349+
lines = state[1].pop("_pickle_lines")
1350+
inequalities = state[1].pop("_pickle_inequalities")
1351+
equations = state[1].pop("_pickle_equations")
1352+
else:
1353+
vertices = None
1354+
13301355
super(Polyhedron_normaliz, self).__setstate__(state)
13311356

13321357
if self.is_empty():
13331358
# Special case to avoid.
13341359
self._normaliz_cone = None
13351360
return
13361361

1362+
if vertices is None:
1363+
vertices = self.vertices()
1364+
rays = self.rays()
1365+
lines = self.lines()
1366+
inequalities = self.inequalities()
1367+
equations = self.equations()
1368+
13371369
self._normaliz_cone = \
13381370
self._cone_from_Vrepresentation_and_Hrepresentation(
1339-
self.vertices(), self.rays(), self.lines(), self.inequalities(), self.equations())
1371+
vertices, rays, lines, inequalities, equations)
13401372

13411373
def integral_hull(self):
13421374
r"""

0 commit comments

Comments
 (0)