Skip to content

Commit

Permalink
allows python to create a label volume; fixes and augments label volu…
Browse files Browse the repository at this point in the history
…me python test
  • Loading branch information
Stephen Plaza committed Apr 26, 2015
1 parent 4b247dc commit 0c8f2e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libdvid/DVIDNodeService.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class DVIDNodeService {
Json::Value get_typeinfo(std::string datatype_name);

/************* API to create datatype instances **************/
// TODO: pass configuration data
// TODO: pass configuration data.
// WARNING: DO NOT USE '-' IN NAMES FOR NOW

/*!
* Create an instance of uint8 grayscale datatype.
Expand Down
3 changes: 2 additions & 1 deletion python/src/libdvid_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ namespace libdvid { namespace python {
Labels3D (DVIDNodeService::*get_labels3D)(std::string, Dims_t, std::vector<unsigned int>, bool, bool, std::string) = &DVIDNodeService::get_labels3D;
void (DVIDNodeService::*put_gray3D)(std::string, Grayscale3D const&, std::vector<unsigned int>, bool, bool) = &DVIDNodeService::put_gray3D;
void (DVIDNodeService::*put_labels3D)(std::string, Labels3D const&, std::vector<unsigned int>, bool, bool, std::string) = &DVIDNodeService::put_labels3D;
bool (DVIDNodeService::*create_labelblk)(std::string, std::string) = &DVIDNodeService::create_labelblk;

// DVIDNodeService python class definition
class_<DVIDNodeService>("DVIDNodeService", init<std::string, UUID>())
Expand All @@ -189,7 +190,7 @@ namespace libdvid { namespace python {
( arg("service"), arg("instance"), arg("ndarray"), arg("offset"), arg("throttle")=true, arg("compress")=false))

// labels
.def("create_labelblk", &DVIDNodeService::create_labelblk)
.def("create_labelblk", create_labelblk, (arg("service"), arg("instance"), arg("instance2")=object() ))
.def("get_labels3D", get_labels3D,
( arg("service"), arg("instance"), arg("dims"), arg("offset"), arg("throttle")=true, arg("compress")=false, arg("roi")=object() ))
.def("put_labels3D", put_labels3D,
Expand Down
8 changes: 8 additions & 0 deletions python/tests/test_node_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def test_labels_3d(self):
retrieved_data = node_service.get_labels3D( "test_labels_3d", (30,30,30), (20,20,20) )
self.assertTrue( (retrieved_data == data[20:50, 20:50, 20:50]).all() )

def test_labels_3d_volsync(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_labelblk("test_labels_3d2", "test_labels_3d2_vol")
data = numpy.random.randint(0, 2**63-1, (128,128,128)).astype(numpy.uint64)
node_service.put_labels3D( "test_labels_3d2", data, (0,0,0) )
retrieved_data = node_service.get_labels3D( "test_labels_3d2", (30,30,30), (20,20,20) )
self.assertTrue( (retrieved_data == data[20:50, 20:50, 20:50]).all() )

@unittest.skip("FIXME: No way to create tile data via the DVID http API.")
def test_grayscale_2d_tile(self):
# Create tile data here...
Expand Down

0 comments on commit 0c8f2e8

Please sign in to comment.