Skip to content

Commit

Permalink
adhere to coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Mar 26, 2014
1 parent b57bee1 commit 0394446
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 70 deletions.
9 changes: 0 additions & 9 deletions blockedarray/__init__.py
@@ -1,12 +1,3 @@
from _blockedarray import *

from opBlockedConnectedComponents import OpBlockedConnectedComponents

'''
try:
from opBlockedConnectedComponents import OpBlockedConnectedComponents
except ImportError as err:
import warnings
warnings.warn("Could not import CC operator: {}".format(str(err)))
'''

45 changes: 15 additions & 30 deletions blockedarray/adapters_py.cxx
Expand Up @@ -21,30 +21,25 @@
using namespace BW;




template<int N, class T>
struct PySourceABC : Source<N,T>, boost::python::wrapper<Source<N,T> >
{
public:

typedef typename Source<N,T>::V TinyVec;

PySourceABC() {};
virtual ~PySourceABC() {};
PySourceABC() {}
virtual ~PySourceABC() {}

void setRoi(Roi<N> roi)
{
void setRoi(Roi<N> roi) {
this->pySetRoi(roi);
}

TinyVec shape() const
{
TinyVec shape() const {
return this->pyShape();
}

bool readBlock(Roi<N> roi, vigra::MultiArrayView<N,T>& block) const
{
bool readBlock(Roi<N> roi, vigra::MultiArrayView<N,T>& block) const {
bool ret;

//temporary NumpyArray, because MultiArrayView is not convertible to python
Expand All @@ -58,18 +53,15 @@ struct PySourceABC : Source<N,T>, boost::python::wrapper<Source<N,T> >
return true;
}

void pySetRoi(Roi<N> roi)
{
void pySetRoi(Roi<N> roi) {
this->get_override("pySetRoi")(roi);
}

TinyVec pyShape() const
{
TinyVec pyShape() const {
return this->get_override("pyShape")();
};

bool pyReadBlock(Roi<N> roi, vigra::NumpyArray<N,T>& block) const
{
bool pyReadBlock(Roi<N> roi, vigra::NumpyArray<N,T>& block) const {
return this->get_override("pyReadBlock")(roi, block);
};
};
Expand All @@ -82,35 +74,29 @@ struct PySinkABC : Sink<N,T>, boost::python::wrapper<Sink<N,T> > {
PySinkABC() {};
virtual ~PySinkABC() {};

bool writeBlock(Roi<N> roi, const vigra::MultiArrayView<N,T>& block)
{
bool writeBlock(Roi<N> roi, const vigra::MultiArrayView<N,T>& block) {
vigra::NumpyArray<N,T> tempArray(block);
return this->pyWriteBlock(roi, tempArray);
}

bool pyWriteBlock(Roi<N> roi, const vigra::NumpyArray<N,T>& block)
{
bool pyWriteBlock(Roi<N> roi, const vigra::NumpyArray<N,T>& block) {
return this->get_override("pyWriteBlock")(roi, block);
};


V getShape() const
{
V getShape() const {
return this->shape_;
}

void setShape(V shape)
{
void setShape(V shape) {
this->shape_ = shape;
}

V getBlockShape() const
{
V getBlockShape() const {
return this->blockShape_;
}

void setBlockShape(V shape)
{
void setBlockShape(V shape) {
this->blockShape_ = shape;
}
};
Expand All @@ -135,8 +121,7 @@ void exportSpecificSourceAdapter(std::string suffix) {
}

template <int N>
void exportSourceAdaptersForDim()
{
void exportSourceAdaptersForDim() {

exportSpecificSourceAdapter<N,vigra::UInt8>("U8");
//exportSpecificSourceAdapter<N,vigra::UInt16>("U16");
Expand Down
2 changes: 1 addition & 1 deletion blockedarray/adapters_py.h
Expand Up @@ -4,4 +4,4 @@
template <int N>
void exportSourceAdaptersForDim();

#endif /* ADAPTERS_PY_H */
#endif /* ADAPTERS_PY_H */
21 changes: 7 additions & 14 deletions blockedarray/blockwisecc_py.cxx
Expand Up @@ -51,8 +51,7 @@ using namespace BW;


template <int N, class T>
void exportSpecificCC(std::string suffix)
{
void exportSpecificCC(std::string suffix) {
using namespace boost::python;
using namespace BW;
typedef ConnectedComponents<N, T> BCC;
Expand All @@ -68,16 +67,14 @@ void exportSpecificCC(std::string suffix)

/* CC conversion */
template <int N>
void exportCCForDim()
{
void exportCCForDim() {
exportSpecificCC<N, vigra::UInt8>("U8");
exportSpecificCC<N, vigra::UInt32>("U32");
}

/* ROI conversion */
template <int N>
void exportRoiForDim()
{
void exportRoiForDim() {
using namespace boost::python;
using namespace BW;
typedef typename Roi<N>::V V;
Expand All @@ -94,8 +91,7 @@ void exportRoiForDim()


template <int N, class T>
void exportSpecificSource(std::string suffix)
{
void exportSpecificSource(std::string suffix) {

using namespace boost::python;
const char *source = ("Source"+suffix).c_str();
Expand All @@ -105,8 +101,7 @@ void exportSpecificSource(std::string suffix)
}

template <int N>
void exportSourceForDim()
{
void exportSourceForDim() {
exportSpecificSource<N,vigra::UInt8>("U8");
//exportSpecificSource<N,vigra::UInt16>("U16");
exportSpecificSource<N,vigra::UInt32>("U32");
Expand All @@ -121,8 +116,7 @@ void exportSourceForDim()


template <int N>
void exportAllForDim()
{
void exportAllForDim() {

using namespace boost::python;

Expand Down Expand Up @@ -150,8 +144,7 @@ void exportAllForDim()
}


void export_blockwiseCC()
{
void export_blockwiseCC() {
exportAllForDim<2>();
exportAllForDim<3>();
}
12 changes: 12 additions & 0 deletions blockedarray/testOpBlockedConnectedComponents.py
Expand Up @@ -76,4 +76,16 @@ def testRoi(self):
roi = dim3.Roi((0,0,0), (2,3,4))
p = roi.p
assert isinstance(p, tuple)
assert len(p) ==3
q = roi.q
assert isinstance(q, tuple)
assert len(q) ==3

roi.p = q
roi.q = p

tempQ = roi.p
assert isinstance(tempQ, tuple)
assert tempQ == q


12 changes: 4 additions & 8 deletions include/bw/roi.h
Expand Up @@ -183,23 +183,19 @@ class Roi {
return ret;
}

V getP()
{
V getP() {
return p;
}

V getQ()
{
V getQ() {
return q;
}

void setP(V p)
{
void setP(V p) {
this->p = p;
}

void setQ(V q)
{
void setQ(V q) {
this->q = q;
}

Expand Down
8 changes: 4 additions & 4 deletions include/bw/sink.h
Expand Up @@ -45,7 +45,7 @@ class Sink {
typedef typename Roi<N>::V V;

Sink() {}
virtual ~Sink() {};
virtual ~Sink() {}

/* has to be called before any calls to writeBlock */
void setShape(V shape) {
Expand All @@ -57,10 +57,10 @@ class Sink {
blockShape_ = shape;
}

V shape() { return shape_; };
V blockShape() { return blockShape_; };
V shape() { return shape_; }
V blockShape() { return blockShape_; }

virtual bool writeBlock(Roi<N> roi, const vigra::MultiArrayView<N,T>& block) { return true; };
virtual bool writeBlock(Roi<N> roi, const vigra::MultiArrayView<N,T>& block) { return true; }

protected:
V shape_;
Expand Down
8 changes: 4 additions & 4 deletions include/bw/source.h
Expand Up @@ -45,17 +45,17 @@ class Source {
typedef typename Roi<N>::V V;

Source() {}
virtual ~Source() {};
virtual ~Source() {}

/**
* selects only the region of interest given from the
* underlying data source. When readBlock() is used, the coordinates
* are relative to roi.q
*/
virtual void setRoi(Roi<N> roi) {};
virtual void setRoi(Roi<N> roi) {}

virtual V shape() const { return V(); };
virtual bool readBlock(Roi<N> roi, vigra::MultiArrayView<N,T>& block) const { return true; };
virtual V shape() const { return V(); }
virtual bool readBlock(Roi<N> roi, vigra::MultiArrayView<N,T>& block) const { return true; }
};

} /* namespace BW */
Expand Down

0 comments on commit 0394446

Please sign in to comment.