Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occupation measure construction #396

Merged
merged 8 commits into from
Mar 15, 2022
Merged

Conversation

alvaro-castillo
Copy link
Contributor

@alvaro-castillo alvaro-castillo commented Nov 23, 2021

Closes #371

@codecov
Copy link

codecov bot commented Nov 23, 2021

Codecov Report

Merging #396 (c8cb523) into develop (89c3cd9) will increase coverage by 0.00%.
The diff coverage is 83.33%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #396   +/-   ##
========================================
  Coverage    80.19%   80.20%           
========================================
  Files           93       93           
  Lines         7266     7289   +23     
========================================
+ Hits          5827     5846   +19     
- Misses        1439     1443    +4     
Impacted Files Coverage Δ
...kfda/exploratory/stats/_functional_transformers.py 87.50% <83.33%> (-12.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89c3cd9...c8cb523. Read the comment docs.

@alvaro-castillo alvaro-castillo changed the title Issue 371 Feature Construction Dec 2, 2021
skfda/misc/feature_construction/__init__.py Outdated Show resolved Hide resolved
skfda/misc/feature_construction/_evaluation_trasformer.py Outdated Show resolved Hide resolved
skfda/misc/feature_construction/_evaluation_trasformer.py Outdated Show resolved Hide resolved
skfda/representation/basis/_fdatabasis.py Outdated Show resolved Hide resolved
skfda/representation/basis/_fdatabasis.py Outdated Show resolved Hide resolved

left, right = domain_range[0]
interval_size = (right - left) / n_intervals
integrated_data = []

Choose a reason for hiding this comment

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

🚫 [mypy] reported by reviewdog 🐶
Need type annotation for 'integrated_data' (hint: "integrated_data: List[] = ...")

def _calculate_curves_occupation_(
curve_y_coordinates: np.ndarray,
curve_x_coordinates: np.ndarray,
interval: Tuple,

Choose a reason for hiding this comment

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

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "Tuple"

Copy link
Member

Choose a reason for hiding this comment

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

This should be Tuple[float, float].

@@ -124,12 +130,11 @@ def __init__(
self.extrapolation = extrapolation
self.grid = grid

def fit( # noqa: D102
def fit(

Choose a reason for hiding this comment

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

🚫 [mypy] reported by reviewdog 🐶
Argument 1 of "fit" is incompatible with supertype "TransformerMixin"; supertype defines the argument type as "Input"

@@ -124,12 +130,11 @@ def __init__(
self.extrapolation = extrapolation
self.grid = grid

def fit( # noqa: D102
def fit(

Choose a reason for hiding this comment

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

📝 [mypy] reported by reviewdog 🐶
This violates the Liskov substitution principle

@@ -124,12 +130,11 @@ def __init__(
self.extrapolation = extrapolation
self.grid = grid

def fit( # noqa: D102
def fit(

Choose a reason for hiding this comment

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

integrand = d1 * d2
integrand = arg1 * arg2
return integrand.integrate()

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
W293 blank line contains whitespace

@@ -124,12 +130,11 @@ def __init__(
self.extrapolation = extrapolation
self.grid = grid

def fit( # noqa: D102
def fit(

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method

@@ -140,12 +145,11 @@ def fit( # noqa: D102

return self

def transform( # noqa: D102
def transform(

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method

interval: Optional[DomainRange] = None,
) -> NDArrayFloat:
"""
Integration of the FData object.

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
DAR003 Incorrect indentation: ~<

*,
interval: Optional[DomainRange] = None,
) -> NDArrayFloat:
"""Examples.

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D205 1 blank line required between summary line and description

interval: Optional[DomainRange] = None,
) -> NDArrayFloat:
"""Integration of the FData object.

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
DAR003 Incorrect indentation: ~<

@alvaro-castillo alvaro-castillo changed the title Feature Construction Occupation measure constructor Feb 3, 2022
@alvaro-castillo alvaro-castillo changed the title Occupation measure constructor Occupation measure construction Feb 3, 2022
@@ -1,5 +1,9 @@
from ._fisher_rao import _fisher_rao_warping_mean, fisher_rao_karcher_mean
from ._functional_transformers import local_averages
from ._functional_transformers import (

Choose a reason for hiding this comment

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

🚫 [mypy] reported by reviewdog 🐶
Module 'skfda.exploratory.stats._functional_transformers' has no attribute 'number_up_crossings'


def occupation_measure(
data: Union[FDataGrid, FDataBasis],
intervals: np.ndarray,
Copy link
Member

Choose a reason for hiding this comment

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

Why not a Sequence of Tuple[float, float]?

data: Union[FDataGrid, FDataBasis],
intervals: np.ndarray,
*,
n_points: Union[int, None] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Use Optional[int] instead of Union[int, None].

intervals: np.ndarray,
*,
n_points: Union[int, None] = None,
) -> np.ndarray:
Copy link
Member

Choose a reason for hiding this comment

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

Use a more specific type if possible, such as NDArrayFloat.

+ " as an argument for a FDataBasis. Instead None was passed.",
)

for interval_check in intervals:
Copy link
Member

Choose a reason for hiding this comment

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

This can be checked in _calculate_curves_occupation_ without the need of an additional loop.

def _calculate_curves_occupation_(
curve_y_coordinates: np.ndarray,
curve_x_coordinates: np.ndarray,
interval: Tuple,
Copy link
Member

Choose a reason for hiding this comment

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

This should be Tuple[float, float].

skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
less_than_y2 = curve_y_coordinates <= y2
inside_interval_bools = greater_than_y1 & less_than_y2

# Correct booleans so they are not repeated
Copy link
Member

Choose a reason for hiding this comment

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

Care to explain more?

skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
Copy link
Member

@vnmabus vnmabus left a comment

Choose a reason for hiding this comment

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

Please don't mark conversations as solved unless the underlying issue is addressed.

skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved

Args:
data: FDataGrid or FDataBasis where we want to calculate
the occupation measure.
Copy link
Member

Choose a reason for hiding this comment

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

Indent multiline descriptions properly.

skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
skfda/exploratory/stats/_functional_transformers.py Outdated Show resolved Hide resolved
Copy link
Member

@vnmabus vnmabus left a comment

Choose a reason for hiding this comment

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

LGTM

@vnmabus vnmabus merged commit bd29e69 into develop Mar 15, 2022
@alvaro-castillo alvaro-castillo deleted the feature/featureConstruction branch March 28, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature construction
2 participants