Skip to content

Commit 97a5723

Browse files
committed
small fixes
1 parent de05a0c commit 97a5723

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Added optional `path` parameter to `compas.rpc.Proxy` to allow for non-package calls.
1616
* Added Grasshopper component to call RPC functions.
1717
* Added `Mesh.to_lines` method and tests.
18-
* Added `Data.guid` to serialization.
18+
* Added `Data.guid` to JSON serialization.
19+
* Added `Data.guid` to pickle state.
1920

2021
### Changed
2122

2223
* Set `jinja >= 3.0` to dev dependencies to fix docs build error.
2324
* Fixed removing of collections for `compas_plotters`.
25+
* Fixed bug in `compas.robots.Configuration`.
2426

2527
### Removed
2628

src/compas/data/data.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import hashlib
88
from uuid import uuid4
9+
from uuid import UUID
910
from copy import deepcopy
1011

1112
import compas
@@ -113,12 +114,19 @@ def __init__(self, name=None):
113114

114115
def __getstate__(self):
115116
"""Return the object data for state serialization with older pickle protocols."""
116-
return {"__dict__": self.__dict__, "dtype": self.dtype, "data": self.data}
117+
return {
118+
"__dict__": self.__dict__,
119+
"dtype": self.dtype,
120+
"data": self.data,
121+
"guid": str(self.guid),
122+
}
117123

118124
def __setstate__(self, state):
119125
"""Assign a deserialized state to the object data to support older pickle protocols."""
120126
self.__dict__.update(state["__dict__"])
121127
self.data = state["data"]
128+
if "guid" in state:
129+
self._guid = UUID(state['guid'])
122130

123131
@property
124132
def DATASCHEMA(self):

src/compas/robots/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ class Configuration(Data):
134134
135135
"""
136136

137-
def __init__(self, joint_values=None, joint_types=None, joint_names=None):
137+
def __init__(self, joint_values=None, joint_types=None, joint_names=None, **kwargs):
138+
super(Configuration, self).__init__(**kwargs)
139+
138140
joint_values = FixedLengthList(joint_values or [])
139141
joint_types = FixedLengthList(joint_types or [])
140142
joint_names = FixedLengthList(joint_names or [], validator=joint_names_validator)

tests/compas/data/test_pickle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ def test_pickling():
1010
assert all(a == b for a, b in zip(f1.xaxis, f2.xaxis))
1111
assert all(a == b for a, b in zip(f1.yaxis, f2.yaxis))
1212
assert all(a == b for a, b in zip(f1.zaxis, f2.zaxis))
13+
assert f1.guid == f2.guid

0 commit comments

Comments
 (0)