Skip to content

Commit

Permalink
Move repr from JSONDict to _SyncedDict. (#183)
Browse files Browse the repository at this point in the history
* Move repr from JSONDict to _SyncedDict.

* Add test for repr.

* Update changelog.
  • Loading branch information
bdice authored and csadorf committed May 6, 2019
1 parent ee29e47 commit 0a16292
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ next
- Fix: Searches for whole numbers will match all numerically matching integers regardless of whether they are stored as decimals or whole numbers (#169).
- Fix: Passing an instance of dict to `H5Store.setdefault()` will return an instance of `H5Group` instead of a dict (#180).
- Improve the representation (return value of `repr()`) of instances of `H5Group`.
- Improve the representation (return value of `repr()`) of instances of `SyncedAttrDict`.


[1.0.0] -- 2019-02-28
Expand Down
3 changes: 0 additions & 3 deletions signac/core/jsondict.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ def _save(self, data=None):
with open(self._filename, 'wb') as file:
file.write(blob)

def __repr__(self):
return repr(self())

@contextmanager
def buffered(self):
buffered_dict = BufferedSyncedAttrDict(self, parent=self)
Expand Down
3 changes: 3 additions & 0 deletions signac/core/synceddict.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def items(self):
self._synced_load()
return self._convert_to_dict(self._data).items()

def __repr__(self):
return repr(self())

def __str__(self):
return str(self())

Expand Down
6 changes: 5 additions & 1 deletion tests/test_synced_attrdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def test_str(self):

def test_repr(self):
sad = self.get_sad()
repr(sad)
self.assertEqual(repr(sad), repr(dict(sad())))
sad['a'] = 0
self.assertEqual(repr(sad), repr(dict(sad())))
sad['a'] = {'b': 0}
self.assertEqual(repr(sad), repr(dict(sad())))

def test_call(self):
sad = self.get_sad()
Expand Down

0 comments on commit 0a16292

Please sign in to comment.