Skip to content

Commit

Permalink
Remove all notions of morphology equality (#91)
Browse files Browse the repository at this point in the history
This is now handled in morph-tool
  • Loading branch information
Benoit Coste authored Jul 19, 2019
1 parent c9a08e6 commit cfe0462
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 476 deletions.
21 changes: 0 additions & 21 deletions binds/python/bind_immutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@ static void bind_immutable_module(py::module &m) {
.def(py::init<const morphio::URI&, unsigned int>(),
"filename"_a, "options"_a=morphio::enums::Option::NO_MODIFIER)
.def(py::init<morphio::mut::Morphology&>())
.def("__eq__", [](const morphio::Morphology& a, const morphio::Morphology& b) {
return a.operator==(b);
}, py::is_operator(),
"Are considered equal, 2 morphologies with the same:\n"
"- point vector\n"
"- diameter vector\n"
"- perimeter vector\n"
"- cell family\n"
"- section types\n"
"- topology (children/parent relationship)\n\n"
"Note: the soma types are NOT required to be equal")
.def("__ne__", [](const morphio::Morphology& a, const morphio::Morphology& b) {
return a.operator!=(b);
}, py::is_operator())
.def(py::self != py::self)

.def("as_mutable", [](const morphio::Morphology* morph) { return morphio::mut::Morphology(*morph); })

Expand Down Expand Up @@ -146,12 +131,6 @@ static void bind_immutable_module(py::module &m) {
"Note: the soma surface computation depends on the soma type");

py::class_<morphio::Section>(m, "Section")
.def("__eq__", [](const morphio::Section& a, const morphio::Section& b) {
return a.operator==(b);
}, py::is_operator())
.def("__ne__", [](const morphio::Section& a, const morphio::Section& b) {
return a.operator!=(b);
}, py::is_operator())
.def("__str__", [](const morphio::Section& section) {
std::stringstream ss;
ss << section;
Expand Down
12 changes: 0 additions & 12 deletions binds/python/bind_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,4 @@ static void bind_misc(py::module &m) {
"neuronal_section_ids"_a, "distances_to_section_start"_a, "diameters"_a);

m.doc() = "pybind11 example plugin"; // optional module docstring


m.def("diff", static_cast<bool (*)(const morphio::Morphology& left, const morphio::Morphology& right, morphio::enums::LogLevel logLevel)>(&morphio::diff),
"Perform a diff on 2 morphologies, returns True if items differ", "left"_a, "right"_a, "log_level"_a=morphio::enums::LogLevel::INFO);
m.def("diff", static_cast<bool (*)(const morphio::Section& left, const morphio::Section& right, morphio::enums::LogLevel logLevel)>(&morphio::diff),
"Perform a diff on 2 sections, returns True if items differ", "left"_a, "right"_a, "log_level"_a=morphio::enums::LogLevel::INFO);

m.def("diff", static_cast<bool (*)(const morphio::mut::Morphology& left, const morphio::mut::Morphology& right, morphio::enums::LogLevel logLevel)>(&morphio::mut::diff),
"Perform a diff on 2 morphologies, returns True if items differ", "left"_a, "right"_a, "log_level"_a=morphio::enums::LogLevel::INFO);
m.def("diff", static_cast<bool (*)(const morphio::mut::Section& left, const morphio::mut::Section& right, morphio::enums::LogLevel logLevel)>(&morphio::mut::diff),
"Perform a diff on 2 sections, returns True if items differ", "left"_a, "right"_a, "log_level"_a=morphio::enums::LogLevel::INFO);

}
23 changes: 0 additions & 23 deletions binds/python/bind_mutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ static void bind_mutable_module(py::module &m) {
.def(py::init<const morphio::mut::Morphology&, unsigned int>(),
"morphology"_a, "options"_a=morphio::enums::Option::NO_MODIFIER)

.def("__eq__", [](const morphio::mut::Morphology& a, const morphio::mut::Morphology& b) {
return a.operator==(b);
}, py::is_operator(),
"Are considered equal, 2 morphologies with the same:\n"
"- root sections\n"
"- section topology\n"
"- cell family\n"
"For each section:"
"- same points\n"
"- same diameters\n"
"- same perimeters\n"
"- same type\n"
"Note: the soma types are NOT required to be equal")
.def("__ne__", [](const morphio::mut::Morphology& a, const morphio::mut::Morphology& b) {
return a.operator!=(b);
}, py::is_operator())

// Cell sub-part accessors
.def_property_readonly("sections", &morphio::mut::Morphology::sections,
"Returns a list containing IDs of all sections. "
Expand Down Expand Up @@ -226,12 +209,6 @@ static void bind_mutable_module(py::module &m) {
"immutable_section"_a, "recursive"_a=false);

py::class_<morphio::mut::Section, std::shared_ptr<morphio::mut::Section>>(m, "Section")
.def("__eq__", [](const morphio::mut::Section& a, const morphio::mut::Section& b) {
return a.operator==(b);
}, py::is_operator())
.def("__ne__", [](const morphio::mut::Section& a, const morphio::mut::Section& b) {
return a.operator!=(b);
}, py::is_operator())
.def("__str__", [](const morphio::mut::Section& section) {
std::stringstream ss;
ss << section;
Expand Down
13 changes: 0 additions & 13 deletions binds/python/bind_vasculature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ static void bind_vasculature(py::module &m) {
.def(py::init<const morphio::URI&>(),
"filename"_a)
// .def(py::init<morphio::mut::Morphology&>())
.def("__eq__", [](const morphio::vasculature::Vasculature& a, const morphio::vasculature::Vasculature& b) {
return a.operator==(b);
}, py::is_operator(),
"Are considered equal, 2 morphologies with the same:\n"
"- point vector\n"
"- diameter vector\n"
"- section types\n"
"- topology\n")
.def("__ne__", [](const morphio::vasculature::Vasculature& a, const morphio::vasculature::Vasculature& b) {
return a.operator!=(b);
}, py::is_operator())
.def(py::self != py::self)

// .def("as_mutable", [](const morphio::vasculature::VasculatureMorphology* morph) { return morphio::mut::Morphology(*morph); })

.def_property_readonly("sections", &morphio::vasculature::Vasculature::sections,
Expand Down
16 changes: 0 additions & 16 deletions include/morphio/morphology.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ class Morphology
Morphology(Morphology&&);
Morphology& operator=(Morphology&&);

/**
Equality operator:
Are considered equal, 2 morphologies with the same:
- point vector
- diameter vector
- perimeter vector
- cell family
- section types
- topology (children/parent relationship)
Note: the soma types are NOT required to be equal
**/
bool operator==(const Morphology& other) const;
bool operator!=(const Morphology& other) const;


/** @name Read API */
//@{
/** Open the given source to a morphology file and parse it.
Expand Down
15 changes: 0 additions & 15 deletions include/morphio/mut/morphology.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,6 @@ class Morphology

virtual ~Morphology();

/**
Are considered equal, 2 morphologies with the same:\n
- root sections
- section topology
- cell family
For each section:
- same points
- same diameters
- same perimeters
- same type
Note: the soma types are NOT required to be equal
**/
bool operator==(const Morphology& other) const;
bool operator!=(const Morphology& other) const;

/**
Returns all section ids at the tree root
**/
Expand Down
10 changes: 0 additions & 10 deletions include/morphio/mut/section.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ class Section : public std::enable_shared_from_this<Section>
const Property::PointLevel&,
SectionType sectionType = SectionType::SECTION_UNDEFINED);

/**
Two sections are equal if they have same:
- points
- diameters
- perimeters
- type
**/
bool operator==(const Section& other) const;
bool operator!=(const Section& other) const;

private:
friend class Morphology;

Expand Down
12 changes: 0 additions & 12 deletions include/morphio/section.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ class Section : public SectionBase<Section>
using PointAttribute = Property::Point;

public:
/**
Equality operator:
Are considered equal, 2 sections with the same:
- point vector
- diameter vector
- perimeter vector
- section types
- topology (children/parent relationship)
**/
bool operator==(const Section& other) const;
bool operator!=(const Section& other) const;

/**
Depth first search iterator
**/
Expand Down
11 changes: 0 additions & 11 deletions include/morphio/vasc/vasculature.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ class Vasculature
Vasculature(Vasculature&&);
Vasculature& operator=(Vasculature&&);

/**
Equality operators :
Two vasculature morphologies are considered equal if they have the same:
- point vector
- diameter vector
- section types
- topology (successor / predecessor relationship)
**/
bool operator==(const Vasculature& other) const;
bool operator!=(const Vasculature& other) const;

/** @name Read API */
/** Open the given source to a vasculature file and parse it.
*/
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ set(MORPHIO_SOURCES
morphology.cpp
soma.cpp
section.cpp
tools.cpp
vasc/section.cpp
vasc/vasculature.cpp
vasc/properties.cpp
Expand Down
10 changes: 0 additions & 10 deletions src/morphology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ Morphology::~Morphology()
{
}

bool Morphology::operator==(const Morphology& other) const
{
return !diff(*this, other, LogLevel::ERROR);
}

bool Morphology::operator!=(const Morphology& other) const
{
return diff(*this, other, LogLevel::ERROR);
}

const Soma Morphology::soma() const
{
return Soma(_properties);
Expand Down
10 changes: 0 additions & 10 deletions src/mut/morphology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,5 @@ void Morphology::write(const std::string& filename)
LBTHROW(UnknownFileType(_err.ERROR_WRONG_EXTENSION(filename)));
}

bool Morphology::operator==(const Morphology& other) const
{
return !diff(*this, other, LogLevel::ERROR);
}

bool Morphology::operator!=(const Morphology& other) const
{
return diff(*this, other, LogLevel::ERROR);
}

} // end namespace mut
} // end namespace morphio
10 changes: 0 additions & 10 deletions src/mut/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,6 @@ std::shared_ptr<Section> Section::appendSection(
return ptr;
}

bool Section::operator==(const Section& other) const
{
return !diff(*this, other, LogLevel::ERROR);
}

bool Section::operator!=(const Section& other) const
{
return diff(*this, other, LogLevel::ERROR);
}

} // end namespace mut
} // end namespace morphio

Expand Down
10 changes: 0 additions & 10 deletions src/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@

namespace morphio {

bool Section::operator==(const Section& other) const
{
return !diff(*this, other, LogLevel::ERROR);
}

bool Section::operator!=(const Section& other) const
{
return diff(*this, other, LogLevel::ERROR);
}

SectionType Section::type() const
{
auto val = _properties->get<Property::SectionType>()[_id];
Expand Down
Loading

0 comments on commit cfe0462

Please sign in to comment.