Created
June 15, 2017 02:05
-
-
Save axw/c257308e8fa241b957ea9a8763649373 to your computer and use it in GitHub Desktop.
Creating NumPy matrices/arrays from Java
This file contains hidden or 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
public class Main { | |
public static void main(String []args) throws Exception { | |
pushy.Client client = new pushy.Client("local:", null); | |
try { | |
NumpyModule m = new NumpyModule(client); | |
System.out.println(m.array(m.mat("1 2; 3 4"))); | |
} finally { | |
client.close(); | |
} | |
} | |
} | |
class NumpyModule extends pushy.Module { | |
private final pushy.Client client; | |
private final pushy.PushyObject arrayMethod; | |
private final pushy.PushyObject matMethod; | |
public NumpyModule(pushy.Client client) { | |
super(client, "numpy"); | |
this.client = client; | |
arrayMethod = __getmethod__("array"); | |
matMethod = __getmethod__("mat"); | |
} | |
public Object mat(String s) { | |
return matMethod.__call__(new Object[]{s}); | |
} | |
public Object array(Object arg) { | |
return arrayMethod.__call__(new Object[]{arg}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment