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

Titles of data collection via aggergators should be improved... #61

Closed
Datseris opened this issue Nov 15, 2019 · 4 comments
Closed

Titles of data collection via aggergators should be improved... #61

Datseris opened this issue Nov 15, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Datseris
Copy link
Member

Datseris commented Nov 15, 2019

In the forest fire model I am doing:

forest = model_initiation(f=0.05, d=0.8, p=0.01, griddims=(20, 20), seed=2)
agent_properties = Dict(:status => [x -> count(x)/400])
when = 1:10

data = step!(forest, dummystep, forest_step!, 10, agent_properties, when=when)

which returns:

2 DataFrames.DataFrame
│ Row │ status_getfield(Main, Symbol("##12#13"))() │ step  │
│     │ Float64                                    │ Int64 │
├─────┼────────────────────────────────────────────┼───────┤
│ 1   │ 0.0575                                     │ 1     │
│ 2   │ 0.06                                       │ 2     │
│ 3   │ 0.0675                                     │ 3     │
│ 4   │ 0.075                                      │ 4     │
│ 5   │ 0.0725                                     │ 5     │
│ 6   │ 0.085                                      │ 6     │
│ 7   │ 0.09                                       │ 7     │
│ 8   │ 0.0925                                     │ 8     │
│ 9   │ 0.1                                        │ 9     │
│ 10  │ 0.105                                      │ 10    │

Okay, you can say that this is because I defined an anonymous function. But I definitely imagine that one of the main use cases of this aggregation will be with anonymous functions.

On the otherhand, using a named function:

average_green(x) = count(x)/400
agent_properties = Dict(:status => [average_green])
forest = model_initiation(f=0.05, d=0.8, p=0.01, griddims=(20, 20), seed=2)
data = step!(forest, dummystep, forest_step!, 10, agent_properties, when=when)

gives

10×2 DataFrames.DataFrame
│ Row │ status_average_green │ step  │
│     │ Float64              │ Int64 │
├─────┼──────────────────────┼───────┤
│ 1   │ 0.8175               │ 1     │
│ 2   │ 0.4975               │ 2     │
│ 3   │ 0.0375               │ 3     │
│ 4   │ 0.015                │ 4     │
│ 5   │ 0.02                 │ 5     │
│ 6   │ 0.0325               │ 6     │
│ 7   │ 0.035                │ 7     │
│ 8   │ 0.0425               │ 8     │
│ 9   │ 0.055                │ 9     │
│ 10  │ 0.0575               │ 10    │

which is better. But maybe it would be even better if we changed the title to use function_name(property), which would display here as average_green(status). I think this is more reasonable. If someone used mean as the function, then the field would display as mean(status) which makes super much sense!

@Datseris Datseris added the bug Something isn't working label Nov 15, 2019
@Datseris
Copy link
Member Author

Datseris commented Nov 15, 2019

@kavir1698 I also think it is important that in step! docstring the return type dataframe is discussed in more detail. The behavior differs fundamentally when aggregators is a vector or a dictionary. Because on the latter, the row number is actually the step number, but if it is a vector the column number is actually the step number.

This is definitely not something I would imagine without reading it at the documentation.

@kavir1698
Copy link
Collaborator

kavir1698 commented Nov 16, 2019

display here as average_green(status)

I agree. This is better and easy to do.
But how could we produce a name for an anonymous function?

@kavir1698
Copy link
Collaborator

kavir1698 commented Nov 16, 2019

I also think it is important that in step! docstring the return type dataframe is discussed in more detail.

I'll add an explanation for that.

@kavir1698 kavir1698 self-assigned this Nov 16, 2019
@kavir1698
Copy link
Collaborator

d88d793 addresses two of the requests.

Anonymous functions do not have good names yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants