Skip to content
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

Struct fieldnames that start with number are ignored #220

Open
bobnal opened this issue Mar 9, 2022 · 1 comment
Open

Struct fieldnames that start with number are ignored #220

bobnal opened this issue Mar 9, 2022 · 1 comment
Labels

Comments

@bobnal
Copy link

bobnal commented Mar 9, 2022

I found out that, passing a python dict or octave struct to an octave function, fieldnames that start with number are ignored.

Here an example.
python script

from oct2py import octave, Struct

test = Struct()

test["word"] = 100
test[str(3)] = 200
test["4"] = 300
test["4test"] = 400
test["test4"] = 500

print("Structure inside python")
print(test)
print("\n")

octave.oct_test(test)

octave function:

function oct_test(test_struct)

    disp("Structure inside octave function")
    disp(test_struct)

endfunction

the output is:
Structure inside python
{'word': 100, '3': 200, '4': 300, '4test': 400, 'test4': 500}

Structure inside octave function
scalar structure containing the fields:

word = 100
test4 = 500

Am i doing something wrong?

@blink1073
Copy link
Owner

I think it is a limitation in scipy.savemat. Here's the value we're passing to it in my local experiment:

array(['base', 'test', {'test4': 500.0, '4test': 400.0}], dtype=object)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants