Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lin space #2840

Merged
merged 9 commits into from Jun 11, 2019
Merged

Lin space #2840

merged 9 commits into from Jun 11, 2019

Conversation

fweik
Copy link
Contributor

@fweik fweik commented May 15, 2019

Maybe fixes #2837.

@KaiSzuttor
Copy link
Member

as I said, I already tried that...

@codecov
Copy link

codecov bot commented May 15, 2019

Codecov Report

Merging #2840 into python will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           python   #2840   +/-   ##
======================================
  Coverage      82%     82%           
======================================
  Files         519     519           
  Lines       26958   26958           
======================================
  Hits        22312   22312           
  Misses       4646    4646
Impacted Files Coverage Δ
src/utils/tests/raster_test.cpp 100% <100%> (ø) ⬆️
src/utils/include/utils/raster.hpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b88304...348a427. Read the comment docs.

mkuron
mkuron previously approved these changes May 15, 2019
@mkuron
Copy link
Member

mkuron commented May 15, 2019

The Numpy thing can easily be fixed by replacing numpy.linalg.norm(A, axis=1) with numpy.sqrt(numpy.einsum('ij,ij->i',A,A)). That already works in Numpy 1.6.0.

@KaiSzuttor
Copy link
Member

this is hard to read, I'd prefer to have a utility function that wraps this logic for older numpy versions

@fweik
Copy link
Contributor Author

fweik commented May 15, 2019

diff --git a/src/utils/include/utils/math/make_lin_space.hpp b/src/utils/include/utils/math/make_lin_space.hpp
index fa2198d06..6145048a3 100644
--- a/src/utils/include/utils/math/make_lin_space.hpp
+++ b/src/utils/include/utils/math/make_lin_space.hpp
@@ -45,8 +45,21 @@ auto make_lin_space(T start, T stop, size_t number, bool endpoint = true) {
   using boost::make_iterator_range;
   using boost::make_transform_iterator;
 
+  struct X {
+       using result_type = T;
+
+       T dx;
+       T start;
+
+       T operator()(size_t i) const {
+          return start + i * dx;
+       }
+  };
+
   auto const dx = (stop - start) / (number - endpoint);
-  auto x = [dx, start](size_t i) { return start + i * dx; };
+//  auto x = [dx, start](size_t i) { return start + i * dx; };
+
+      auto const x = X{dx, start};
 
   return make_iterator_range(
       make_transform_iterator(make_counting_iterator(size_t(0)), x),

@@ -22,19 +23,19 @@ namespace Utils {
template <class T, class F>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is T actually used?

@KaiSzuttor
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Jun 11, 2019
2840: Lin space r=KaiSzuttor a=fweik

Maybe fixes #2837.

Co-authored-by: Florian Weik <fweik@icp.uni-stuttgart.de>
Co-authored-by: Kai Szuttor <kai@icp.uni-stuttgart.de>
@bors
Copy link
Contributor

bors bot commented Jun 11, 2019

Build succeeded

@bors bors bot merged commit 348a427 into espressomd:python Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Utils function not compatible with required boost version
3 participants