Comments (9)
Hello,
I tried the same piece of code on the newest Debian and the result was
>> config = ReadYaml(fname)
config =
List: {'Item1' 'Item2'}
Hence, it seems that there is some incompatibility within linux operating
systems.
What version of matlab do you have? Paste here the output of ver command,
please.
This package makes use of jar library snakeyaml, and you can easily detect
whether the problem lies in the library:
First, open ReadYaml and put brakepoint on line 37 then run the same code as
before.
Now, the yml and yymlobj variables should look like as follows:
>> yml
yml =
List:
- Item1
- Item2
K>> jymlobj = yamlreader.load(yml)
jymlobj =
{List=[Item1, Item2]}
Original comment by [email protected]
on 6 May 2011 at 6:23
from yamlmatlab.
Hello,
>> What version of matlab do you have? Paste here the output of ver command,
please.
MATLAB Version 7.10.0.499 (R2010a)
Operating System: Linux 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:21 UTC
2011 i686
Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM)
Client VM mixed mode
I tried printing out jymlobj and that part seems to be working:
K>> jymlobj = yamlreader.load(yml)
jymlobj =
{List=[Item1, Item2]}
The problem seems to be in Hash2Struct function.
K>> str2num(d.toString);
ans =
[]
K>> d
d =
[Item1, Item2]
I replaced the offending line with the following, it seems to do something.
K>> char(d.toArray())
ans =
Item1
Item2
I'm not sure what data type I should try to convert to through... I'm getting
this for the end result now:
K>> config
config =
List: [2x5 char]
Original comment by [email protected]
on 6 May 2011 at 4:13
from yamlmatlab.
Unfortunately, I cannot find the offending line of code in Hash2Struct. You
wrote you use version 0.2.2 therefore please have a look at
http://code.google.com/p/yamlmatlab/source/browse/tags/0.2.2/Hash2Struct.m and
write here which part of the code seems to be problematic.
Anyway, the resulting variable config should look like
config =
List: {'Item1' 'Item2'}
which is a Matlab structure with one field List which value is 1x2 cell of
chars.
Original comment by [email protected]
on 6 May 2011 at 5:00
- Added labels: Priority-High
- Removed labels: Priority-Medium
from yamlmatlab.
Thanks for the response. Well it wasn't working because I was being an idiot. I
had been experimenting with snakeyaml before and had a pre-existing
Hash2Struct.m file in my directory. :P. Srry. It seems to work fine with the
test file.
I tried running yamlmatlab on my actual config file and seem to be running into
a completely different problem now. Here is the yaml file I'm trying to parse:
=== test.yaml ===
sensors:
- class: Compass
tiltSigma: 0.2
headingSigma: 0.5
Hz: 20
translation: [1,1,1]
rotationaxis: [1, 0, 0, 0]
- class: DepthSensor
whiteSigma: 0.1
translation: [0.1, 0.2, 0.3]
And am getting this error:
??? Subscripted assignment between dissimilar structures.
Error in ==> Hash2Struct at 88
Data.(field)(hh+1)=Hash2Struct(hm);
Error in ==> ReadYaml at 37
Data = Hash2Struct(jymlobj);
Error in ==> dvlAlign at 7
config = ReadYaml('test.yaml') %'../../config/sunfish/sunfish.yaml');
Seems like this might be an actual issue now. Currently the Matlab data
structure being generated is
sensors (struct)
Compass (struct)
When it crashes, maybe it should be something like this?
sensors (struct)
[Compass(struct), DepthSensor(struct)]
Original comment by [email protected]
on 6 May 2011 at 5:28
from yamlmatlab.
Unfortunately, this kind of structure is not, to my knowledge, representable in
a matlab struct since if you have an array of structs (as you specified in YAML
file) all structs must have the same fields.
For example your test.yaml contains field sensors, there is array indicator
"-". Each item of this array contains stucture
-the first one with fields class, tiltSigma,Hz, translation, rotationaxis
-the second one only class, whiteSigma,translation
and now, try to merge these structs to an array :-)
For example
>> a.test='a'
a =
test: 'a'
>> b.x ='b'
b =
x: 'b'
>> [a, b]
??? Error using ==> horzcat
CAT arguments are not consistent in structure field names.
>> [a;b]
??? Error using ==> vertcat
CAT arguments are not consistent in structure field names.
>> x(1)=a
x =
test: 'a'
>> x(2)=b
??? Subscripted assignment between dissimilar structures.
Moreover, the structures which are to be merged must have the same order of
fields :(
We faced to the same problem in our project and finally, we had to have the
same structure of structures, unfortunately.
So I'd suggest you to do the same if possible.
Original comment by [email protected]
on 6 May 2011 at 5:52
from yamlmatlab.
Original comment by [email protected]
on 6 May 2011 at 5:53
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from yamlmatlab.
after all, We decided to implement suppot for the YAML file structure you have.
So if you download version 0.3.0, then you should get the following
>> config = ReadYaml('test2.yaml')
config =
sensors: {[1x1 struct] [1x1 struct]}
>> config.sensors{1}
ans =
class: 'Compass'
tiltSigma: 0.2000
headingSigma: 0.5000
Hz: 20
translation: [1 1 1]
rotationaxis: [1 0 0 0]
>> config.sensors{2}
ans =
class: 'DepthSensor'
whiteSigma: 0.1000
translation: [0.1000 0.2000 0.3000]
Original comment by [email protected]
on 8 May 2011 at 8:36
from yamlmatlab.
Thanks! This works great now, I will include it in my project.
Original comment by [email protected]
on 9 May 2011 at 4:14
from yamlmatlab.
Original comment by [email protected]
on 9 May 2011 at 9:55
- Changed state: Done
from yamlmatlab.
Related Issues (15)
- error: YAMLMatlab:init:failed, YAMLMatlab initialization failed HOT 2
- data.(field) crashes when field has whitespace HOT 2
- DecodeUnicode throws null pointer exception when orig_utf is empty HOT 2
- index out of bounds exception when importing empty array HOT 1
- Multiple formatting problems under Windows HOT 1
- Problem with empty maps HOT 1
- Tests will not run due to incorrect path settings. HOT 1
- read "inf" and "eps" values request HOT 2
- Support for integer HOT 1
- usecase_struct_01 fails with fresh install
- Emission of empty strings.
- scan_map error: numbered map names
- makeords doesn't correctly handle row-vectors HOT 1
- Cannot read multi-document stream
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamlmatlab.