larray-project / larray

N-dimensional labelled arrays in Python
https://larray.readthedocs.io/
GNU General Public License v3.0
8 stars 6 forks source link

deprecate Session(obj1, obj2) #1024

Closed gdementen closed 2 years ago

gdementen commented 2 years ago

I did not realize it when I created issue #999, but it strongly pushes in that direction.

This only works for objects with a name attribute, so Axis and Group I think.

Deprecating the feature would mean users (mostly our test suite I think) would have to provide explicit names for those objects too, so instead of writing:

Session(axis1, obj2=obj2) 

Users would have to give an explicit name, i.e. write:

Session(axis1=axis1, obj2=obj2) 
# or 
Session({'axis1': axis1, 'obj2': obj2})
# or
Session([('axis1', axis1), ('obj2', obj2)])

I don't think I have ever seen this being used (except in our test suite).

The other (completely different) option is to add a name attribute to Array and allow the obj1, obj2 syntax for Arrays when that attribute is set. I am rather in favour of the first option, but wanted to mention the second one for completeness. @alixdamman: what do you think?

alixdamman commented 2 years ago

I have the same opinion as you. I think it's better that users explicitly give a name to objects when creating a Session.

I also think we should really deprecate the syntax:

Session([('axis1', axis1), ('obj2', obj2)])