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

Functional density #586

Merged
merged 6 commits into from
Jun 11, 2024
Merged

Functional density #586

merged 6 commits into from
Jun 11, 2024

Conversation

u3ks
Copy link
Collaborator

@u3ks u3ks commented May 20, 2024

Similar functionality to count and arearatio.
Similarly, it could be implemented by either us or the users using two calls to describe_reached.

Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.9%. Comparing base (4037c70) to head (ae585da).
Report is 29 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #586     +/-   ##
=======================================
+ Coverage   97.4%   97.9%   +0.5%     
=======================================
  Files         26      37     +11     
  Lines       4328    5612   +1284     
=======================================
+ Hits        4214    5492   +1278     
- Misses       114     120      +6     
Files Coverage Δ
momepy/functional/tests/test_diversity.py 100.0% <100.0%> (ø)
momepy/functional/tests/test_intensity.py 100.0% <100.0%> (ø)

Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

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

Check your types and ensure all supported are tested.



def density(
values: Series | np.ndarray, areas: Series | np.ndarray, graph: Graph
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
values: Series | np.ndarray, areas: Series | np.ndarray, graph: Graph
y: Series | NDArray[np.float_], area: Series | NDArray[np.float_], graph: Graph


stats = graph.apply(
pd.concat((values, areas.rename("area")), axis=1),
lambda x: (x.loc[:, x.columns != "area"].sum() / x["area"].sum()),
Copy link
Member

Choose a reason for hiding this comment

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

are you assuming here that values can be 2d and calculate density for multiple vars at one go? That is undocumented and goes against typing.

@u3ks u3ks requested a review from martinfleis June 11, 2024 14:24
@martinfleis martinfleis merged commit 0b8d1a1 into pysal:main Jun 11, 2024
14 checks passed
@martinfleis martinfleis added enhancement New feature or request and removed refactor labels Jun 16, 2024
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.

None yet

3 participants