-
Notifications
You must be signed in to change notification settings - Fork 26
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
Package Structure and API design #9
Comments
API - Package StructureOPTION 1:
Pro:
Con:
OPTION 2:
With options:
Pro:
Con:
Resolved with additional options(see above)
OPTION 3:
Pro:
Con:
OPTION 4:
Main difference: Conceptual structure for plots
Pros: Cons: Note:To date, underlying
|
Designing Functions for Splot - Parameters and ReturnsOPTION 1:Main difference: Moran_local calculated in plotting function Parameters
mpl function examples:
Bokeh function examples:
OPTION 2:Main difference: moran_locasl as input Parameters
mpl function examples:
A:
B:
Bokeh function examples:
Notes:
Discussion points:
|
This is fantastic @slumnitz!!! Thank you very much for taking the plunge and have a first go! On the general API design, my sense would be to have a hierarchical structure that begins with the from splot.esda.mpl import Moran_scatterplot
from splot.giddy.bk import Rose_plot Pro
Con
|
As for designing functions, again I think this is a great start @slumnitz. My sense would be to start by the functionality we want to support. For example, maybe we could say that the lead developer of each package could provide the list of visualisations to work on. We could start with For example, for
|
This is definitely bikeshedding, but I would prefer one name and a backend flag/option that defaults to matplotlib. I do not think it makes sense to build in the other package names and things directly into a namespace in the API, although it does make sense from a function dispatch and a file organization perspective. Again, consider that most users are going to focus on getting the plot and not what rendering engine it uses. To me, this would be like if your calls in matplotlib required you to specify This is option 2 in the first comment so far as I understand it. Also, under option 2, we could also set this using some kind of I like this because I think it's the smallest maintainable API, it's used elsewhere, and I don't think the cons are accurately assessed?
yes, or possibly letting a
No, I don't see this as needed any more than other cases: if backend.lower() == 'bokeh':
from splot.whatever import plot_bokeh_stuff
plot_bokeh_stuff
elif backend.lower() == 'matplotlib':
from splot.whatever import plot_matplotlib_stuff
plot_matplotlib_stuff This would require that something be installed if the user asks for it explicitly. If the user asks for it and doesn't have it, then (and only then) will it error.
Expose a plotting function everywhere where it might be used. If we go for a semantically-meaningful API (rather than a program structure API) then I think this makes sense. Anywhere where we'd expect a user to want a Moran plot, expose it. Or, instead of tying functions to each package, we could take a stab at making a conceptual structure for the plots themselves, like
Not sure how this is a bad thing? Again, if we're composing a semantically meaningful api and need to expose |
@darribas and @ljwolf thank you for your comments and additions! I added your comments and suggestions to the option overview. I think making a detailed overview of visualisations to support each subpackage is a good idea. I started a collection space here: #10. Looking forward to discuss more ideas tomorrow! |
This seems to be getting fleshed out already, but figured I'd just add my quick two cents. I agree with not including package names/backends in the namespaces. Even though it is the most modular, it requires users to do a lot more thinking about what they want to import. I really like the simplicity of relying on default backend, and just being able to change it if you are interested in doing so. I also agree with exposing plotting functions wherever it is thought that they might be useful. This is flexible for future cases say where it is realized that an existing plot is useful in a new package or once new features are added to a package. In the other option, wouldn't it make the imports redundant? Say if for the case of plotting both for data and then residuals:
|
Seems like this can be closed now. Please reopen if I am jumping the gun here. |
Ideas and decisions regarding the design of package structure and API for
splot
Overall package idea
.plot
methods for objects called fromsplot
andsplot.sub_package
namespace depending on PySAL object that is plottedmatplotlib
andgeopandas
splot.mapping
offers tools for coropleth, color and mapping supportDecisions (indicating implementation status):
splot.plot.py
intosplot._viz_mpl.py
giddy
visualisations insplot
mapping.py
intosplot._viz_mpl.py
.mpl
functions returnfig, ax
splot
(See API - Package Structure comment):splot.giddy
), common_viz_utils.py
for utility functions used by all subpackagessplot
functionality as.plot
methods in sub packages (see Idea Collection: Functionality to support in splot #10 for supported functionalityhttp://pysal.org/getting_started.html#submodule-contract)
To be decided:
Open questions/ ideas:
Rejected options:
plot
(See API - Package Structure comment):splot.mpl
andsplot.bk
), chose function names according to statistics they are helping to visualise (e.g.moran_scatterplot()
,local_autocorrelation_statistics()
...)plot
(See API - Package Structure comment):.mpl
) submodule:* e.g.
mplot
,plot_choropleth
,plot_local_autocorrelation
,... forbk
andmpl
* except if one plotting package doesn't have the needed features (e.g. if interactivity is essential,
matplotlib
may not be able to create such a plot)splot.mpl
only:ax
splot.bk
only:reverse_colors
plot(method="interactive")
option, more flexibility by integrating submodules instead of function callsThe text was updated successfully, but these errors were encountered: