-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from neuro-ml/C++
Fast linear 2d interpolation
- Loading branch information
Showing
38 changed files
with
1,582 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
BasedOnStyle: Google | ||
IndentWidth: 4 | ||
AccessModifierOffset: -4 | ||
ColumnLimit: 100 | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
DerivePointerAlignment: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
SortIncludes: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
Checks: '-*,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-const-cast, google-readability-casting, google-runtime-int, modernize-replace-random-shuffle, modernize-use-nullptr, readability-braces-around-statements, readability-container-size-empty, readability-redundant-control-flow, readability-redundant-string-init, readability-identifier-naming, google-build-using-namespace' | ||
HeaderFilterRegex: '\.h$' | ||
WarningsAsErrors: '*' | ||
CheckOptions: | ||
- key: readability-identifier-naming.NamespaceCase | ||
value: lower_case | ||
- key: readability-identifier-naming.ClassCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.TypedefCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.TypeAliasCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.PrivateMemberSuffix | ||
value: '_' | ||
- key: readability-identifier-naming.StructCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.FunctionCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.VariableCase | ||
value: lower_case | ||
- key: readability-identifier-naming.PrivateMemberCase | ||
value: lower_case | ||
- key: readability-identifier-naming.ParameterCase | ||
value: lower_case | ||
- key: readability-identifier-naming.GlobalConstantPrefix | ||
value: k | ||
- key: readability-identifier-naming.GlobalConstantCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.StaticConstantPrefix | ||
value: k | ||
- key: readability-identifier-naming.StaticConstantCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.ConstexprVariableCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.ConstexprVariablePrefix | ||
value: k | ||
- key: google-runtime-int.TypeSuffix | ||
value: _t | ||
- key: readability-identifier-naming.TypeTemplateParameterCase | ||
value: CamelCase | ||
- key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp | ||
value: expr-type | ||
- key: readability-identifier-naming.FunctionIgnoredRegexp | ||
value: ^(begin|end)$ | ||
- key: readability-identifier-naming.TypeAliasIgnoredRegexp | ||
value: ^(iterator_category|value_type|difference_type|pointer|reference|iterator_type|iterator_concept)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ imops/src/_fast*.pyx | |
*.egg-info/ | ||
.asv/ | ||
dist/ | ||
*.so | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
from scipy.interpolate import LinearNDInterpolator | ||
|
||
from imops.interp2d import Linear2DInterpolator | ||
|
||
from .common import NUMS_THREADS_TO_BENCHMARK, discard_arg, load_npy_gz | ||
|
||
|
||
class Interp2dSuite: | ||
params = [('C++', 'Scipy'), ('float32', 'float64'), NUMS_THREADS_TO_BENCHMARK] | ||
param_names = ['backend', 'dtype', 'num_threads'] | ||
|
||
@discard_arg(1) | ||
@discard_arg(-1) | ||
def setup(self, dtype): | ||
x = load_npy_gz(Path(__file__).parent / 'data' / 'ribs.npy.gz').astype(dtype) | ||
add_cols = x.shape[1] // 4 | ||
distances = np.concatenate((x[..., -add_cols:], x, x[..., :add_cols]), axis=1) | ||
self.int_points = np.transpose((np.isnan(distances)).nonzero()) | ||
self.x_points = np.transpose((~np.isnan(distances)).nonzero()) | ||
self.x_values = distances[~np.isnan(distances)] | ||
|
||
@discard_arg(2) | ||
def time_interp2d(self, backend, num_threads): | ||
if backend == 'C++': | ||
Linear2DInterpolator(self.x_points, self.x_values, num_threads=num_threads)(self.int_points, fill_value=0.0) | ||
elif backend == 'Scipy': | ||
LinearNDInterpolator(self.x_points, self.x_values)(self.int_points) | ||
else: | ||
raise NotImplementedError | ||
|
||
@discard_arg(2) | ||
def peakmem_interp2d(self, backend, num_threads): | ||
if backend == 'C++': | ||
Linear2DInterpolator(self.x_points, self.x_values, num_threads=num_threads)(self.int_points, fill_value=0.0) | ||
elif backend == 'Scipy': | ||
LinearNDInterpolator(self.x_points, self.x_values)(self.int_points) | ||
else: | ||
raise NotImplementedError |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.8.4' | ||
__version__ = '0.8.5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2018 Volodymyr Bilonenko | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
|
||
#pragma once | ||
|
||
#define DELAUNATOR_HEADER_ONLY | ||
|
||
#include "delaunator.hpp" | ||
|
||
#include "delaunator.cpp" | ||
|
||
#undef DELAUNATOR_HEADER_ONLY |
Oops, something went wrong.