Giter Club home page Giter Club logo

Comments (8)

fremling avatar fremling commented on May 29, 2024 1

As the W2Julia function solves the original issue is will close this ticket.

from mathlink.jl.

simonbyrne avatar simonbyrne commented on May 29, 2024

You can just access the .args field of the returned object, but that is probably not ideal. This is related to #22.

from mathlink.jl.

simonbyrne avatar simonbyrne commented on May 29, 2024

I guess there is no harm in making them iterable and defining getindex on them? then you could just call collect?

from mathlink.jl.

jebej avatar jebej commented on May 29, 2024

Would there be any efficiency issues (e.g unnecessary copying)?

from mathlink.jl.

simonbyrne avatar simonbyrne commented on May 29, 2024

Yes, but we already copy so much stuff it probably wouldn’t make much difference.

from mathlink.jl.

jebej avatar jebej commented on May 29, 2024

Ok, then that seems fine, intuitive (I did try calling collect initially to see if it would work), and certainly better than the current situation.

Would it be at-all useful to define specialized collect methods that would just return args when we detect that it is already an array?

from mathlink.jl.

simonbyrne avatar simonbyrne commented on May 29, 2024

we may want a different function, since collect doesn't alias even for arrays:

julia> X = rand(3);

julia> collect(X) === X
false

parent is often used for similar things, and might make sense?

from mathlink.jl.

fremling avatar fremling commented on May 29, 2024

Hi @jebej , based on ticket (#72) I have snuck in the feature (W2Julia ) in into the 0.5.3 release of yesterday (https://github.com/JuliaInterop/MathLink.jl/releases/tag/v0.5.3). It aims to convert MathLink objects to Julia style objects.

At the moment it can convert the "Assumptions" to a dictionary and lists to a list. Below are some examples:

@test W2Julia(W`{1,2,3}`) == [1,2,3]
@test W2Julia(W`{1,a,3}`) == [1,W"a",3]
@test W2Julia(W`{1,a,{1,2}}`) == [1,W"a",[1,2]]
@test W2Julia(W`Association["team" -> "HOU", "lastName" -> "Ching"]`) == Dict( "team" => "HOU" , "lastName" => "Ching")
@test W2Julia(W`Association["team" -> {1,2,3}, "lastName" -> "Ching"]`) == Dict( "team" => [1,2,3] , "lastName" => "Ching")
@test W2Julia(W`{1,Association["team" -> {1,2,3}, "lastName" -> "Ching"]}`) == [1,Dict( "team" => [1,2,3] , "lastName" => "Ching")]

As this is almost at the embryo stage, feel free to report strange (or lacking) behavior i other tickets.

from mathlink.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.