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 #646 from gsomix/buffer_protocol
Fixes for buffer protocol
- Loading branch information
Showing
5 changed files
with
43 additions
and
47 deletions.
There are no files selected for viewing
29 changes: 0 additions & 29 deletions
29
examples/undocumented/python_modular/features_dense_buffer_modular.py
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
examples/undocumented/python_modular/features_dense_buffer_protocol_modular.py
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,29 @@ | ||
from shogun.Features import RealFeatures | ||
from shogun.Features import LongIntFeatures | ||
|
||
from numpy import array, float64, int64 | ||
|
||
# create dense matrice | ||
data=[[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]] | ||
|
||
parameter_list = [[data]] | ||
|
||
def features_dense_real_modular(in_data=data): | ||
m_real=array(in_data, dtype=float64) | ||
m_long=array(in_data, dtype=int64) | ||
|
||
f_real=RealFeatures(m_real) | ||
f_long=LongIntFeatures(m_long) | ||
|
||
mem_real=memoryview(f_real) | ||
mem_long=memoryview(f_long) | ||
|
||
ret_real=array(f_real) | ||
ret_long=array(f_long) | ||
|
||
print ret_real | ||
print ret_long | ||
|
||
if __name__=='__main__': | ||
print('dense_real') | ||
features_dense_real_modular(*parameter_list[0]) |
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