Skip to content

Curve fit base - #54

Open
alirezazolanvari wants to merge 10 commits into
devfrom
curve-fit-base
Open

Curve fit base#54
alirezazolanvari wants to merge 10 commits into
devfrom
curve-fit-base

Conversation

@alirezazolanvari

Copy link
Copy Markdown
Member

What does this implement?

  • CurveFit class is added

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov-commenter

codecov-commenter commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.50000% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.15%. Comparing base (f1c3a6a) to head (19f5fe1).

Files with missing lines Patch % Lines
drux/curve_fit.py 36.99% 46 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              dev      #54       +/-   ##
===========================================
- Coverage   98.69%   84.15%   -14.54%     
===========================================
  Files           9       10        +1     
  Lines         229      309       +80     
  Branches       26       33        +7     
===========================================
+ Hits          226      260       +34     
- Misses          2       48       +46     
  Partials        1        1               

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread requirements-latest.txt Outdated
@@ -1,2 +1,3 @@
numpy==2.2.6
matplotlib==3.10.3
scipy>=1.7.3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scipy==1.7.3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this because scipy==1.7.3 is the latest version that supports Python 3.7, but it only supports Python versions up to 3.10. What should we do in this case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to be concerned. As you may know, we do not directly install this fixed version, and this file is intended solely for triggering Dependabot. PyPI automatically installs the latest available version of each dependency across different Python versions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 19f5fe1.

Comment thread CHANGELOG.md Outdated

## [Unreleased]
### Added
- `CurveFit` object

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectclass

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 5529231.

Comment thread drux/curve_fit.py Outdated
)

# Single point of registration mapping a model name to its class.
MODEL_CLASSES: Dict[str, Type[DrugReleaseModel]] = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use typing for internal variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5529231.

@alirezazolanvari
alirezazolanvari marked this pull request as ready for review August 19, 2026 07:51
@sepandhaghighi sepandhaghighi added the enhancement New feature or request label Aug 20, 2026
@sepandhaghighi sepandhaghighi added this to the drux v0.5 milestone Aug 20, 2026
Comment thread drux/curve_fit.py Outdated
if self._fit_result is None:
return f"drux.CurveFit({self._model_name}, not fitted)"
params = ", ".join(f"{k}={v:.4f}" for k, v in self._fit_result.parameters.items())
return f"drux.CurveFit({self._model_name}: {params}, R²={self._fit_result.r_squared:.4f})"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use Unicode superscript ² (R²) in this function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 75af54c.

Comment thread drux/curve_fit.py
for name in self._parameter_names
}

def _equation(self, t: np.ndarray, *free_values: float) -> np.ndarray:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring for inputs.

:param t: ...
:param free_values: ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 9e82dfe.

Comment thread drux/curve_fit.py

self._fit_result: Optional[FitResult] = None

def _merge_parameters(self, free_values: Sequence[float]) -> Dict[str, float]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring for inputs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 9e82dfe.

Comment thread drux/curve_fit.py
}


def _model_parameter_names(model_class: Type[DrugReleaseModel]) -> List[str]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring for inputs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 9e82dfe.

Comment thread drux/messages.py Outdated
ERROR_INVALID_GEOMETRY_FACTOR = "Geometry factor (n) must be 1 (slab), 2 (cylinder), or 3 (sphere)."

# Error messages for curve fitting
ERROR_UNKNOWN_MODEL = "Unknown model '{}'. Available models: {}."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest using names in formatting.

For example:

ERROR_UNKNOWN_MODEL = "Unknown model '{model_name}'. Available models: {available_models}."

And then:

ERROR_UNKNOWN_MODEL.format(model_name=model_name, available_models=available_models)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in effc410.

Comment thread CHANGELOG.md
## [Unreleased]
### Added
- `CurveFit` class
- `FitResult` object

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectclass

Comment thread drux/curve_fit.py
for name in self._parameter_names
}

def _equation(self, t: np.ndarray, *free_values: float) -> np.ndarray:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about the type of *free_values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants