Skip to content

Commit

Permalink
Merge pull request #711 from kordejong/gh710
Browse files Browse the repository at this point in the history
Replace overload accepting future with overload accepting scalarReplace all overloads accepting a `future<Element>` with overloads accepting a `Scalar<Element>`
  • Loading branch information
kordejong authored Aug 20, 2024
2 parents 6506542 + 106bb7d commit d6b32ac
Show file tree
Hide file tree
Showing 30 changed files with 547 additions and 448 deletions.
22 changes: 11 additions & 11 deletions source/framework/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ add_library(lue_py_framework SHARED
src/algorithm/accu_threshold.cpp
src/algorithm/accu_threshold3.cpp
src/algorithm/acos.cpp
src/algorithm/add.cpp
src/algorithm/all.cpp
src/algorithm/array_partition_id.cpp
src/algorithm/aspect.cpp
Expand All @@ -44,29 +43,19 @@ add_library(lue_py_framework SHARED
src/algorithm/atan2.cpp
src/algorithm/cos.cpp
src/algorithm/d8_flow_direction.cpp
src/algorithm/divide.cpp
src/algorithm/downstream.cpp
src/algorithm/downstream_distance.cpp
src/algorithm/equal_to.cpp
src/algorithm/exp.cpp
src/algorithm/greater_than.cpp
src/algorithm/greater_than_equal_to.cpp
src/algorithm/inflow_count.cpp
src/algorithm/inflow_count3.cpp
src/algorithm/inter_partition_stream.cpp
src/algorithm/iterate_per_element.cpp
src/algorithm/less_than.cpp
src/algorithm/less_than_equal_to.cpp
src/algorithm/locality_id.cpp
src/algorithm/log.cpp
src/algorithm/multiply.cpp
src/algorithm/normal.cpp
src/algorithm/not_equal_to.cpp
src/algorithm/pow.cpp
src/algorithm/sin.cpp
src/algorithm/slope.cpp
src/algorithm/sqrt.cpp
src/algorithm/subtract.cpp
src/algorithm/tan.cpp
src/algorithm/timestamp.cpp
src/algorithm/uniform.cpp
Expand All @@ -90,17 +79,28 @@ add_library(lue_py_framework SHARED
src/algorithm/global_operation/sum.cpp

src/algorithm/local_operation.cpp
src/algorithm/local_operation/add.cpp
src/algorithm/local_operation/cast.cpp
src/algorithm/local_operation/ceil.cpp
src/algorithm/local_operation/cell_index.cpp
src/algorithm/local_operation/divide.cpp
src/algorithm/local_operation/equal_to.cpp
src/algorithm/local_operation/floor.cpp
src/algorithm/local_operation/greater_than.cpp
src/algorithm/local_operation/greater_than_equal_to.cpp
src/algorithm/local_operation/less_than.cpp
src/algorithm/local_operation/less_than_equal_to.cpp
src/algorithm/local_operation/log10.cpp
src/algorithm/local_operation/logical_and.cpp
src/algorithm/local_operation/logical_exclusive_or.cpp
src/algorithm/local_operation/logical_inclusive_or.cpp
src/algorithm/local_operation/logical_not.cpp
src/algorithm/local_operation/multiply.cpp
src/algorithm/local_operation/negate.cpp
src/algorithm/local_operation/not_equal_to.cpp
src/algorithm/local_operation/pow.cpp
src/algorithm/local_operation/round.cpp
src/algorithm/local_operation/subtract.cpp
src/algorithm/local_operation/unique_id.cpp

src/algorithm/routing_operation.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> equal_to(Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto equal_to(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::equal_to(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto equal_to(Argument1 const& argument1, Argument2 const& argument2) -> Scalar<OutputElement>
{
return value_policies::equal_to(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> greater_than(Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto greater_than(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::greater_than(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto greater_than(Argument1 const& argument1, Argument2 const& argument2) -> Scalar<OutputElement>
{
return value_policies::greater_than(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> greater_than_equal_to(
Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto greater_than_equal_to(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::greater_than_equal_to(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto greater_than_equal_to(Argument1 const& argument1, Argument2 const& argument2)
-> Scalar<OutputElement>
{
return value_policies::greater_than_equal_to(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> less_than(Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto less_than(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::less_than(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto less_than(Argument1 const& argument1, Argument2 const& argument2) -> Scalar<OutputElement>
{
return value_policies::less_than(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> less_than_equal_to(
Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto less_than_equal_to(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::less_than_equal_to(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto less_than_equal_to(Argument1 const& argument1, Argument2 const& argument2) -> Scalar<OutputElement>
{
return value_policies::less_than_equal_to(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

namespace lue::framework {

template<typename InputElement, typename OutputElement, Rank rank, typename Argument1, typename Argument2>
PartitionedArray<OutputElement, rank> not_equal_to(Argument1 const& argument1, Argument2 const& argument2)
template<typename OutputElement, Rank rank, typename Argument1, typename Argument2>
auto not_equal_to(Argument1 const& argument1, Argument2 const& argument2)
-> PartitionedArray<OutputElement, rank>
{
if constexpr (!std::is_same_v<Argument1, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument1>, InputElement>);
}
return value_policies::not_equal_to(argument1, argument2);
}

if constexpr (!std::is_same_v<Argument2, InputElement>)
{
static_assert(std::is_same_v<ElementT<Argument2>, InputElement>);
}

template<typename OutputElement, typename Argument1, typename Argument2>
auto not_equal_to(Argument1 const& argument1, Argument2 const& argument2) -> Scalar<OutputElement>
{
return value_policies::not_equal_to(argument1, argument2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace lue::framework {
template<typename Element, Rank rank, typename Argument1, typename Argument2>
auto pow(Argument1 const& argument1, Argument2 const& argument2) -> PartitionedArray<Element, rank>
{
using Policies = policy::pow::DefaultValuePolicies<Element, Element>;

return pow(Policies{}, argument1, argument2);
return value_policies::pow(argument1, argument2);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,114 +115,102 @@ namespace lue::framework {
.def(
"__lt__",
[](Array const& argument1, Array const& argument2)
{ return lfr::less_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::less_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__lt__",
[](Array const& argument1, Element const argument2)
{ return lfr::less_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::less_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__lt__",
[](Array const& argument1, Scalar const& argument2)
{ return lfr::less_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::less_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

// a <= b
.def(
"__le__",
[](Array const& argument1, Array const& argument2) {
return lfr::less_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Array const& argument2)
{ return lfr::less_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__le__",
[](Array const& argument1, Element const argument2) {
return lfr::less_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Element const argument2)
{ return lfr::less_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__le__",
[](Array const& argument1, Scalar const& argument2) {
return lfr::less_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Scalar const& argument2)
{ return lfr::less_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

// a == b
.def(
"__eq__",
[](Array const& argument1, Array const& argument2)
{ return lfr::equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__eq__",
[](Array const& argument1, Element const argument2)
{ return lfr::equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__eq__",
[](Array const& argument1, Scalar const& argument2)
{ return lfr::equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

// a != b
.def(
"__ne__",
[](Array const& argument1, Array const& argument2)
{ return lfr::not_equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::not_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__ne__",
[](Array const& argument1, Element const argument2)
{ return lfr::not_equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::not_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__ne__",
[](Array const& argument1, Scalar const& argument2)
{ return lfr::not_equal_to<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::not_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

// a > b
.def(
"__gt__",
[](Array const& argument1, Array const& argument2)
{ return lfr::greater_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::greater_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__gt__",
[](Array const& argument1, Element const argument2)
{ return lfr::greater_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::greater_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__gt__",
[](Array const& argument1, Scalar const& argument2)
{ return lfr::greater_than<ElementT<Array>, std::uint8_t, rank>(argument1, argument2); },
{ return lfr::greater_than<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

// a >= b
.def(
"__ge__",
[](Array const& argument1, Array const& argument2) {
return lfr::greater_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Array const& argument2)
{ return lfr::greater_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__ge__",
[](Array const& argument1, Element const argument2) {
return lfr::greater_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Element const argument2)
{ return lfr::greater_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())
.def(
"__ge__",
[](Array const& argument1, Scalar const& argument2) {
return lfr::greater_than_equal_to<ElementT<Array>, std::uint8_t, rank>(
argument1, argument2);
},
[](Array const& argument1, Scalar const& argument2)
{ return lfr::greater_than_equal_to<std::uint8_t, rank>(argument1, argument2); },
pybind11::is_operator())

;
Expand Down
Loading

0 comments on commit d6b32ac

Please sign in to comment.