bartneck / swiML

A project to formalise swimming programs using XML
MIT License
2 stars 2 forks source link

'Repetition' object has no attribute 'totalLength' #93

Open bartneck opened 3 months ago

bartneck commented 3 months ago

The python program repetitionTest.py does not run. It gives the error message:

'Repetition' object has no attribute 'totalLength'
calloc262 commented 3 months ago

This file hasn't been pushed to main yet There might also be a problem as I think the only swiML.py that was updated was the one sitting at the top level in pythonXMLtest, I can go through and change all of them although I was planning on moving to top-level tomorrow

bartneck commented 3 months ago

The same error happens in the file JasiMasters2024030501.py

I had copied the latest version of swiML.py into this directory this morning. It should be up to date.

calloc262 commented 3 months ago

in repetitionTest.py this section of code is erroring `oneSet1=swiML.Instruction( length=('lengthAsDistance',150), stroke=('kicking',('standardKick','any')) )

oneSet2Continue=swiML.Continue( instructions=[ swiML.Instruction( length=('lengthAsDistance',25), stroke=('drill',('6KickDrill','freestyle')) ), swiML.Instruction( length=('lengthAsDistance',25), stroke=('drill',('singleArm','butterfly')) ) ] )

oneSet2=swiML.Repetition( repetitionCount=2, instructions=[oneSet2Continue] )

oneSet3=swiML.Instruction( length=('lengthAsDistance',150), stroke=('standardStroke','any') )

oneSet=swiML.Repetition( simplify=True, rest=('afterStop','PT0M15S'), instructions=[ oneSet1, oneSet2, oneSet3 ] )` but you're trying to simplify 150 kick 2 x 50 drill 150 swim which doesn't make much sense What should this output be?

calloc262 commented 3 months ago
fixed the issue so JasiMasters2024030501.py works now repetitionTestpy now displays the correct error: `xception: Cannot simplify continue with repetitions of different lengths 150 meters any kick cannot be simplified with 50 swim as 25 meters freestyle 6KickDrill drill
25 meters butterfly singleArm drill`
bartneck commented 3 months ago

The error is best seen in JasiMasters2024022501.py. Have a look at the JasiMasters2024022501.jpeg. It is 3x150. The second 150 is 3x(25drill, 25 another drill).

I think I modelled it in Python correctly, but maybe I got something wrong.

bartneck commented 3 months ago

I made an attempt to model this directly in XML: JasiMasters2024022501-manualXML.xml and I do get a validation error. Futhermore, the rendering in HTML looks almost okay, but there is the 25 meter missing.

SCR-20240314-oowz
calloc262 commented 3 months ago

It's erroring because the second 150 isn't a 150 its 3x50 drill, you would need to wrap it in a continue. It gives a validation error because you can't simplify 150 with 3x50.

This is a good example of why I had made it possible to specify the total length of a continue. So in this case you could replace the 3x repetition with a continue that had a continue length of 150.

bartneck commented 3 months ago

I updated the Python program JasiMasters2024022501.py and it gives the error:

Continue.__init__() got an unexpected keyword argument 'continueLength'

I also updated the JasiMasters2024022501-manualXML.xml with the continueLength. It transformed to HTML reasonably well.

Screenshot 2024-03-15 at 12 49 27 PM

But it also still triggers a validation error:

Assertion evaluation ('                 ((./sw:simplify = true()) and (every $length in .//sw:length                     satisfies $length/*[1] = (.//sw:length)[1]/*[1])) or ./sw:simplify = false() or count(./sw:simplify) = 0') for element 'repetition' on schema type 'repetitionType' did not succeed. 
calloc262 commented 3 months ago

fixed the python - it now works with continue length had a go at fixing the assertion but I'm still not sure whether its working properly

bartneck commented 3 months ago

The assertion does not seem to work. I created a new program and it has the same validation error: JasiMasters2024031201.xml