Skip to content

feat: Implement flat Mesa namespace alternative - #1244

Closed
rht wants to merge 1 commit into
mesa:mainfrom
rht:flat
Closed

rht wants to merge 1 commit into
mesa:mainfrom
rht:flat

Conversation

@rht

@rht rht commented Apr 4, 2022 •

Copy link
Copy Markdown
Contributor

Close #1229.
Examples:

In [1]: import mesa.all as ma

In [2]: ma.Agent
Out[2]: mesa.agent.Agent

In [3]: ma.Model
Out[3]: mesa.model.Model

In [4]: ma.RandomActivation
Out[4]: mesa.time.RandomActivation

In [5]: ma.SingleGrid
Out[5]: mesa.space.SingleGrid

In [6]: ma.ModularServer
Out[6]: mesa.visualization.ModularVisualization.ModularServer

In [7]: ma.UserSettableParameter
Out[7]: mesa.visualization.UserParam.UserSettableParameter

In [8]: ma.DataCollector
Out[8]: mesa.datacollection.DataCollector

I'm thinking of whether it should be called import mesa.flat as mf instead of import mesa.all as ma.

@codecov

codecov Bot commented Apr 4, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #1244 (1246f40) into main (def2c1b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1244   +/-   ##
=======================================
  Coverage   89.07%   89.07%           
=======================================
  Files          19       19           
  Lines        1245     1245           
  Branches      246      246           
=======================================
  Hits         1109     1109           
  Misses        101      101           
  Partials       35       35           

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 def2c1b...1246f40. Read the comment docs.

@rht

rht commented Apr 4, 2022

Copy link
Copy Markdown
Contributor Author

My contenders so far:

  • import mesa.all as ma
  • import mesa.flat as mf
  • import mesa.simple as ms
  • import mesa.lite as ml

Let's bring this up in the next dev meeting.

@tpike3

tpike3 commented Apr 4, 2022 •

Copy link
Copy Markdown
Member

@rht This is awesome, so simple yet very powerful. My gut says mesa.all. @jackiekazil , @EwoutH, @aiwhoo thoughts?

@rht

rht commented Apr 4, 2022 •

Copy link
Copy Markdown
Contributor Author

Note: I intentionally put the time in ma.time instead of flattening it inside ma, because of the concern in #1231. If there is no time as a namespace prefix, then ma.Random doesn't make sense. It needs to be ma.time.Random.

@jackiekazil

Copy link
Copy Markdown
Member

I see the value. Quick question -- what if there are name space collisions? (I guess we handle when they occur?)

@jackiekazil

Copy link
Copy Markdown
Member

Also do libraries normally maintain both?

@rht

rht commented Apr 4, 2022 •

Copy link
Copy Markdown
Contributor Author

Yeah, collisions can be handled by hand. One example from other library: import matplotlib.pyplot as plt.

Another alternative is to import into mesa namespace directly, so we have:

import mesa
mesa.DataCollector  # in addition to mesa.datacollection.DataCollector
mesa.UserSettableParameter
...

@clarkpetri

Copy link
Copy Markdown

Excited to follow this. Loving Mesa so far for my school work.

@rht

rht commented May 15, 2022

Copy link
Copy Markdown
Contributor Author

Reimplemented in #1294

@rht rht closed this May 15, 2022
@rht
rht deleted the flat branch May 15, 2022 04:35
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.

UX: flat Mesa namespace alternative

4 participants