-
Notifications
You must be signed in to change notification settings - Fork 16
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
Access constants of a static class #6
Comments
The code does not handle this currently. If you are handy with low level reflection code, could add code to scan for fields and consider these to be properties more or less. Perhaps easier would be to expose some of these constants as properties, in which case the bridge will see these. In R would get the property as:
In python:
|
@tr8dr Thank you for the reply! I will try the second option. |
Could you also give me a hint how to create a .NET array of a certain type in R? I tried but I'm getting
|
If the target array is one of the types recognized: int, double, float, string. You can just create the vector on the R side and then pass to a function. For example if you have a function that takes a double[]:
You can call this function directly with an R vector.
Or if you use MathNet.Numerics, can use functions with signatures for matrices and vectors:
If you are trying to create a type that is not something R would understand, not sure why you would bother to create from R. If you provide more context in terms of what you want to do can suggest a solution. |
I need to call a function that requires an array of a custom type as one of the arguments:
So far I'm trying to figure out how much I can do without writing a wrapper in C#. |
You should be able to see the ParameterValue[] objects. I suspect where it is confused is with the IEnumerable<...>. I think the problem with the array you were creating above is that the array would initially be empty. R can view and index into an array of objects, but in creating the array initially does not have objects in it (unless it is a struct type). The Bridge will attempt to return a R list of these objects, but then the array cells are uninitialized, presenting a problem. Even if you created the array and the R bridge was OK with uninitialized cells, there is no functionality to set a value in the array. I'd have to check, but you might be able to create a R list of objects and then this will be converted in the call. If we are considering an array of MoleculeOntogeny objects, could do as follows:
if you call your function, this will be presented as a List<> of these objects. |
Great, thank you, I'll give it a try! |
Is there a way to access constants of a static class? The code would look like
namespace MyNamespace
{
public static class MyConstants
{
public const int CONST_1 = 38;
public const int CONST_2 = 20;
public const int CONST_3 = 100;
...
The text was updated successfully, but these errors were encountered: