Skip to content

Commit

Permalink
Ensure metadata and getPixel results are json serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed May 29, 2023
1 parent 9cdd1cf commit 1b1b8a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Improvements
- Parse qptiff and imagej vendor information ([#1168](../../pull/1168))
- Ensure metadata and getPixel results are json serializable ([#1182](../../pull/1182))

### Changes
- Remove an unneeded warnings filter ([#1172](../../pull/1172))
Expand Down
2 changes: 1 addition & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ def getMetadata(self):
'magnification': mag['magnification'],
'mm_x': mag['mm_x'],
'mm_y': mag['mm_y'],
'dtype': self.dtype,
'dtype': str(self.dtype),
})

@property
Expand Down
4 changes: 4 additions & 0 deletions test/test_source_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import json
import os
import re
import sys
Expand Down Expand Up @@ -209,6 +210,9 @@ def testSourcesTilesAndMethods(source, filename):
# This should be an image and a mime type
assert len(ts.getAssociatedImage(ts.getAssociatedImagesList()[0])) == 2
assert ts.getAssociatedImage('nosuchimage') is None
# Test the serializability of common methods
assert json.dumps(ts.getMetadata())
assert json.dumps(ts.getPixel(region=dict(left=0, top=0)))
# Test module open method
mod = sys.modules[sourceClass.__module__]
assert mod.open(imagePath) is not None
Expand Down

0 comments on commit 1b1b8a9

Please sign in to comment.