Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preliminary design of buffer protocol stuff
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
examples/undocumented/python_modular/features_dense_buffer_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 numpy import array, float64, all | ||
|
||
# create dense matrices A,B,C | ||
matrix=array([[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]], dtype=float64) | ||
|
||
parameter_list = [[matrix]] | ||
|
||
# ... of type LongInt | ||
def features_dense_real_modular(A=matrix): | ||
|
||
# ... of type Real, LongInt and Byte | ||
a=RealFeatures(A) | ||
a.set_feature_vector(array([1,4,0,0,0,9], dtype=float64), 0) | ||
|
||
# get matrix | ||
a_out = a.get_feature_matrix() | ||
|
||
b = array(a) + a | ||
|
||
print b | ||
print a_out | ||
|
||
assert(all(a_out==A)) | ||
return a_out | ||
|
||
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