MethodicalAcceleratorDesign / MAD-NG

MAD Next-Generation official repository
GNU General Public License v3.0
32 stars 11 forks source link

`totable` in TPSA errors #445

Closed jgray-19 closed 5 months ago

jgray-19 commented 5 months ago

In PyMAD-NG the tests are currently failing, it appears that the totable is the cause of it.

The following represents what seems to happen.

    ____  __   ______    ______     |   Methodical Accelerator Design
     /  \/  \   /  _  \   /  _  \   |   release: 0.9.9_P (Linux 64)
    /  __   /  /  /_/ /  /  /_/ /   |   support: http://cern.ch/mad
   /__/  /_/  /__/ /_/  /_____ /    |   licence: GPL3 (C) CERN 2016+
                                    |   started: 2024-05-08 00:47:55

> d = MAD.gtpsad(3, 6)
> res = MAD.tpsa(6):set(1,2):set(2, 1)
> res:totable(true)
madl_gtpsa.mad:518: attempt to get length of 'struct tpsa_'
stack traceback:
        madl_gtpsa.mad:518: in function 'totable'
        stdin:1: in main chunk
        [C]: at 0x63d98914deb0
> res:totable()
madl_gtpsa.mad:518: attempt to get length of 'struct tpsa_'
stack traceback:
        madl_gtpsa.mad:518: in function 'totable'
        stdin:1: in main chunk
        [C]: at 0x63d98914deb0
> 
ldeniau commented 5 months ago

fixed in #dff1d08a it was removed because length of a tpsa is not so obvious to define... in particular, future version of gtpsa lib may use sparse representation...

ldeniau commented 5 months ago

Finally I changed my mind and remove the __len operator again. The len method has been renamed to mlen and the hi flag has been added, similar to mord. Totable has been updated to not use this method/operator as it could book a large amount of memory beforehand for nothing.