JYU-IBA / potku

Potku is analysis and simulation software for ToF-ERD measurements
https://www.jyu.fi/science/en/physics/research/infrastructures/accelerator-laboratory/pelletron/potku/
GNU General Public License v2.0
7 stars 7 forks source link

Enable to add similar elements #196

Open jkpnen opened 3 years ago

jkpnen commented 3 years ago

Solves #194

jkpnen commented 3 years ago

Tests will not pass (after the latest commit e536dcd) if not sorted(orig_elems). Why is that and should it be sorted?

https://github.com/JYU-IBA/potku/blob/96cf37bf3be94874f9b4f96a20022abcceab0ef7/tests/unit/test_element.py#L64-L82

tpitkanen commented 3 years ago

Tests will not pass (after the latest commit e536dcd) if not sorted(orig_elems). Why is that and should it be sorted?

https://github.com/JYU-IBA/potku/blob/96cf37bf3be94874f9b4f96a20022abcceab0ef7/tests/unit/test_element.py#L64-L82

__lt__ is the less-than comparison. The new commit broke the isotope ordering/sorting as I noted here. The test should work as-is after the commented thing is fixed.

tpitkanen commented 3 years ago

I checked this pull request again while merging the open PRs and noticed the following:


More importantly, I reconsidered the risk/reward ratio of this feature. While being able to add similar elements is useful, the Element class is used in many places (around 100 non-test locations according to Find Usages, of which from_string accounts for 24 occurrences). Any of these places could break with this change.

Even if the code doesn't break, the effects of the new sequence member variable need to be considered in each of the places Element is used.

I don't think this feature should be added after all. It's too much work and code complexity for its benefits.

(Ping for the corresponding issue: #194)

tpitkanen commented 2 years ago

@mlaitin: Just two types of same element would be enough (SCT/REC).

This feature should be simpler/safer to implement this way.

194