Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPackage Structure and API design #9
Comments
This comment has been minimized.
This comment has been minimized.
slumnitz
added this to To do
in GSoC 2018
May 31, 2018
slumnitz
moved this from To do
to In progress
in GSoC 2018
May 31, 2018
slumnitz
moved this from In progress
to To do
in GSoC 2018
May 31, 2018
slumnitz
moved this from To do
to In progress
in GSoC 2018
May 31, 2018
This comment has been minimized.
This comment has been minimized.
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
|
This comment has been minimized.
This comment has been minimized.
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:
|
slumnitz
changed the title
API design
Package Structure and API design
Jun 5, 2018
This comment has been minimized.
This comment has been minimized.
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
|
This comment has been minimized.
This comment has been minimized.
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 comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
@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 comment has been minimized.
This comment has been minimized.
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:
|
slumnitz commentedMay 30, 2018
•
edited
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 #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 calls