rmnldwg / lymph

Python package for statistical modelling of lymphatic metastatic spread in head & neck cancer.
https://lymph-model.readthedocs.io
MIT License
5 stars 4 forks source link

if things are expensive, they should look expensive #40

Closed rmnldwg closed 5 months ago

rmnldwg commented 1 year ago

Right now, the package makes heavy use of Python's @property decorator. For example, loading data is as "easy" as writing

model.patient_data = some_pandas_table

This looks like I am only storing the table inside the model object. But actually, it is computing the diagnose matrix which is rather expensive. So, making this a function instead of a property would give it the look and feel of something potentially resource-intensive:

model.load_patient_data(some_pandas_table)
rmnldwg commented 5 months ago

A lot has happened with the new 1.0 API. In particular, setting new parameters does not immediately trigger a recomputation of expensive stuff like the transition matrix.

Thus, in keeping with this issue, it would make sense to replace model.transition_matrx with model.transition_matrix() to hint at the user that this might be expensive (although it often is not due to caching).