You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
get_value_refpts(ring, array_of_indexes, 'PolynomB', 0)
works, giving the first element of PolynomB for the elements of ring with indexes in array_of_indexes.
get_value_refpts(ring, array_of_indexes, 'Length', 0)
instead fails, as Length is a scalar.
I had this second line in my code, the index 0 being there from copy-paste. I did not expect it to fail, Length has length 1, so index 0 did not seem to be possibly generating an error.
The help of get_value_refpts says it: " ... IF attr_name is an array"
I find this somehow strange that the user has to remember if the specific attribute is an array or not when using the command get_value_refpts.
The error message is a python error and it is not very immediate. It could be caught and translated to a warning. For example: "For scalar attributes index is ignored".
This action, would also recover a usage similar to the matlab equivalent of this function atgetfieldvalues, that does not fail in the case atgetfieldvalues(r, ind, 'Length', 0).
The text was updated successfully, but these errors were encountered:
simoneliuzzo
changed the title
at.get_value_refpts fails if the field value is scalar and an index is provided
at.get_value_refpts fails if the field value is scalar and an index 0 is provided
Aug 27, 2022
Unlike in Matlab, scalar and numpy arrays are completely different python objects ! You indeed need to know what is the attribute. But I doubt that you would extract attribute values without knowing what they mean…
Anyway, I very much prefer using a simple python command rather that using get_value_refpts: in your example, you would write
It's more efficient, it works for integer or boolean indices (get_value_refpts also, of course) and it's self-explanatory for a python developer… The function does not bring anything, but it's a matter of taste.
get_value_refpts(ring, array_of_indexes, 'PolynomB', 0)
works, giving the first element of PolynomB for the elements of ring with indexes in array_of_indexes.
get_value_refpts(ring, array_of_indexes, 'Length', 0)
instead fails, as Length is a scalar.
I had this second line in my code, the index 0 being there from copy-paste. I did not expect it to fail, Length has length 1, so index 0 did not seem to be possibly generating an error.
The help of get_value_refpts says it: " ... IF attr_name is an array"
I find this somehow strange that the user has to remember if the specific attribute is an array or not when using the command
get_value_refpts
.The error message is a python error and it is not very immediate. It could be caught and translated to a warning. For example: "For scalar attributes index is ignored".
This action, would also recover a usage similar to the matlab equivalent of this function
atgetfieldvalues
, that does not fail in the case atgetfieldvalues(r, ind, 'Length', 0).The text was updated successfully, but these errors were encountered: