Giter Club home page Giter Club logo

Comments (3)

MDSplusBuilder avatar MDSplusBuilder commented on May 25, 2024

It was not clear what approach is best. I understand your point but in
the case of MDSplus users who have been using only tdi and IDL for
decades and just starting to use python might find the behavior of
python slicing to be strange. If one wants numpy/python behavior then
you can always use the data() method on an MDSplus array to get the
numpy array and slice that. The same is true for "slicing" signals. I
don't think we'd want to change the tdi subscripting behavior of signals
to resemble python slicing. It is a tough decision as to whether to use
tdi slicing of MDSplus objects or python slicing. I intentionally chose
to use tdi slicing for MDSplus objects when I implemented the python
module to retain MDSplus behavior on MDSplus objects. If this is
undesirable we could probably add a global setting to select tdi or
python slicing behavior.

On 4/18/2016 12:26 PM, Brian Standley wrote:

Python (native and numpy) interprets the end index as the first
element not included when slicing arrays, whereas TDI includes the
end element (like IDL). Since indexing in mdsobjects (see
|getitem| in mdsdata.py) eventually calls TdiExecute, MDSplus
arrays behave a bit unexpectedly:
|>>> a = numpy.array([0.4, 0.5, 0.6, 0.7])|
|>>> b = MDSplus.Float32Array(a)|
|>>> a[0:2]|
|array([ 0.4, 0.5])|
|>>> b[0:2]|
|[.4,.5,.6]|

I am happy to make a patch if you think it makes sense to fix it,
probably by adjusting the end index in the aforementioned function.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#452

from mdsplus.

bstandley avatar bstandley commented on May 25, 2024

OK, now I understand the reasoning. I do not think a global setting is necessary, but it could not hurt to highlight the implications of MDSplus vs. native types on the wiki. I will see what I can do.

from mdsplus.

bstandley avatar bstandley commented on May 25, 2024

I added a note to the wiki:
http://www.mdsplus.org/index.php/Documentation:Tutorial:MdsObjects#Python_Specific_Issues

from mdsplus.

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.