COMCIFS / cif_core

The IUCr CIF core dictionary
15 stars 9 forks source link

is dREL formatting important? #421

Open rowlesmr opened 1 year ago

rowlesmr commented 1 year ago

Is the way dREL is formatted in _method.expression important? Some of them are hurting my eyes!

What's with all the whitespace between things?

    With  a  as  atom_site

    label = a.label

    If      (a.ADP_type == 'Uani')  {
        Loop b as atom_site_aniso     {
          If(label == b.label)           {

              UIJ = b.matrix_U
              Break
    } } }

    Else If (a.ADP_type == 'Bani')  {
        Loop b as atom_site_aniso     {
          If(label == b.label)           {

             UIJ = b.matrix_B / (8 * Pi**2)
             Break
    } } }

    Else                                    {
        If (a.ADP_type == 'Uiso')  U  =  a.U_iso_or_equiv
        Else                       U  =  a.B_iso_or_equiv / (8 * Pi**2)

            UIJ = U * _cell.convert_Uiso_to_Uij
    }

             CUB = _cell.convert_Uij_to_betaij

       _atom_site.tensor_beta =  CUB * UIJ * CUB

Why don't things line up?

    With c  as  cell

    _cell.convert_Uij_to_betaij =                              1.4142 * Pi *
    Matrix([[ c.reciprocal_length_a, 0, 0 ],
                [ 0, c.reciprocal_length_b, 0 ],
                    [ 0, 0, c.reciprocal_length_c ]])
vaitkus commented 1 year ago

If I recall correctly, the indentation got a bit messed up the first time we applied the automatic dictionary linter to the dictionaries. I think it should be safe to reformat them, but @jamesrhester is more qualified to answer this since he has a working dREL parser.

As for the preferred code formatting style, I do not think that there currently is one. I guess we could start a discussion on this in the https://github.com/COMCIFS/comcifs.github.io repository, if that seems needed.

jamesrhester commented 1 year ago

Nope, the formatting is largely irrelevant, except for whitespace delimiting the tokens. Newline is not significant except as whitespace. You are welcome to have a discussion as @vaitkus suggested as to the best formatting rules, but that would also mean we would then have to actually format these bits correctly and to check them, so I've not been in a hurry to do that.