Skip to content

The MATLAB "bridges" use inconsistent MATLAB classes for MDSplus text strings #3060

Description

@mwinkel-dev

Affiliation
MIT PSFC

Version(s) Affected
Various -- see the attached files

Platform(s)
All

Installation Method(s)
Developer builds

Describe the bug
MATLAB can access data in MDSplus trees using three "bridges": Java, Python and mdsthin. However, the three bridges are inconsistent when returning text to MATLAB. Depending on the platform, software stack and versions, MATLAB will receive the text in different object types: string, py.str or char.

As shown in the attached files . . .

  • Java always returns text as string
  • Python returns text as char or string (apparently depending on the NumPy version)
  • MDSplus errors are always returned as char

Note that MATLAB introduced the string class in R2016b. All MDSplus customers are surely using newer versions of MATLAB, thus string is the preferred class for text.

Configuring MATLAB to work with the three bridges can be a bit of a challenge, especially if a computer has multiple versions of Java, Python and NumPy installed. Furthermore prior to R2025a, MATLAB used Java for its user interface so shipped a version of Java bundled with MATLAB. From a support standpoint, it can thus be difficult to determine exactly which versions of the software stack are being used by a MDSplus customer.

To Reproduce
Examine the attached files and run similar commands.

Expected behavior

  1. All text nodes in MDSplus trees should be returned as MATLAB string objects.
  2. MDSplus error messages are now consistently being returned as MATLAB char objects. Perhaps, these also should be returned as string objects.

Screenshots
n/a

Additional context
PR #2990 fixed a symptom but overlooked the root cause, namely that the bridges don't use consistent MATLAB classes for MDSplus text nodes. When this issue is fixed, the mdstest.m code added in PR #2990 can be simplified.

One possible fix for this issue is to modify the mdsvalue.m script to detect results returned as py.str or char objects and then use MATLAB's string() function to convert them to string objects.

These files show output of the three bridges for different platforms and software stacks.
matlab_macos.txt
matlab_ubuntu24_a.txt
matlab_ubuntu24_b.txt
matlab_win11.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions