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

Indentation error in subplots tutorial #198

Closed
PennyHow opened this issue Apr 24, 2024 · 3 comments · Fixed by #212
Closed

Indentation error in subplots tutorial #198

PennyHow opened this issue Apr 24, 2024 · 3 comments · Fixed by #212

Comments

@PennyHow
Copy link
Contributor

Bug: Indentation error in subplots tutorial using .maps.plot_grid.

>>> for i, (k, v) in enumerate(layers.items()):
...     # for the first grid, need orgin_shift to be default
...     if i == 0:
...         fig = maps.plot_grd(
...             v["grid"],
...             title=k,
...             region=plot_region,
...             coast=True,
...         )
...         # plot a shapefile
...         fig.plot(
...             data=fetch.sample_shp(name="Roosevelt_Island"),
...             pen="2p,magenta",
...             label="Roosevelt Island Transect",
...         )
...         # add legend
...         fig.legend(position="JTR+jTR", box="+gwhite+p1p")
... 
>>>     # for the end of each row (mulitples of the number of columns) need to
>>>     # shift origin down and back to beginning
>>>     elif i % subplot_dimensions[1] == 0:
  File "<stdin>", line 1
    elif i % subplot_dimensions[1] == 0:
IndentationError: unexpected indent
>>>         fig = maps.plot_grd(
  File "<stdin>", line 1
    fig = maps.plot_grd(
IndentationError: unexpected indent
>>>             v["grid"],
  File "<stdin>", line 1
    v["grid"],
IndentationError: unexpected indent
>>>             title=k,
  File "<stdin>", line 1
    title=k,
IndentationError: unexpected indent
>>>             fig=fig,conda env create -f environment.yml
  File "<stdin>", line 1
    fig=fig,
IndentationError: unexpected indent
>>>             origin_shift="both_shift",
  File "<stdin>", line 1
    origin_shift="both_shift",
IndentationError: unexpected indent
>>>             xshift_amount=-(subplot_dimensions[0]),  # gives -2, shifts plot back by 2
  File "<stdin>", line 1
    xshift_amount=-(subplot_dimensions[0]),  # gives -2, shifts plot back by 2
IndentationError: unexpected indent
>>>             yshift_amount=-1,  # shift new row down by 1
  File "<stdin>", line 1
    yshift_amount=-1,  # shift new row down by 1
IndentationError: unexpected indent
>>>             region=plot_region,
  File "<stdin>", line 1
    region=plot_region,
IndentationError: unexpected indent
>>>             coast=True,
  File "<stdin>", line 1
    coast=True,
IndentationError: unexpected indent
>>>         )
  File "<stdin>", line 1
    )
IndentationError: unexpected indent
>>>         # plot a shapefile
>>>         fig.plot(
  File "<stdin>", line 1
    fig.plot(
IndentationError: unexpected indent
>>>             data=fetch.sample_shp(name="Roosevelt_Island"),
  File "<stdin>", line 1
    data=fetch.sample_shp(name="Roosevelt_Island"),
IndentationError: unexpected indent
>>>             pen="2p,magenta",
  File "<stdin>", line 1
    pen="2p,magenta",
IndentationError: unexpected indent
>>>             label="Roosevelt Island Transect",
  File "<stdin>", line 1
    label="Roosevelt Island Transect",
IndentationError: unexpected indent
>>>         )
  File "<stdin>", line 1
    )
IndentationError: unexpected indent
>>>         # add legend
>>>         fig.legend(position="JTR+jTR", box="+gwhite+p1p")
  File "<stdin>", line 1
    fig.legend(position="JTR+jTR", box="+gwhite+p1p")
IndentationError: unexpected indent
>>> 
>>>     # for the rest of the grids, just shift to the right like normal
>>>     else:
  File "<stdin>", line 1
    else:
IndentationError: unexpected indent
>>>         fig = maps.plot_grd(
  File "<stdin>", line 1
    fig = maps.plot_grd(
IndentationError: unexpected indent
>>>             v["grid"],
  File "<stdin>", line 1
    v["grid"],
IndentationError: unexpected indent
>>>             title=k,
  File "<stdin>", line 1
    title=k,
IndentationError: unexpected indent
>>>             fig=fig,
  File "<stdin>", line 1
    fig=fig,
IndentationError: unexpected indent
>>>             origin_shift="xshift",
  File "<stdin>", line 1
    origin_shift="xshift",
IndentationError: unexpected indent
>>>             region=plot_region,
  File "<stdin>", line 1
    region=plot_region,
IndentationError: unexpected indent
>>>             coast=True,
  File "<stdin>", line 1
    coast=True,
IndentationError: unexpected indent
>>>         )
  File "<stdin>", line 1
    )
IndentationError: unexpected indent
>>>         # plot a shapefile
>>>         fig.plot(
  File "<stdin>", line 1
    fig.plot(
IndentationError: unexpected indent
>>>             data=fetch.sample_shp(name="Roosevelt_Island"),
  File "<stdin>", line 1
    data=fetch.sample_shp(name="Roosevelt_Island"),
IndentationError: unexpected indent
>>>             pen="2p,magenta",
  File "<stdin>", line 1
    pen="2p,magenta",
IndentationError: unexpected indent`
>>>             label="Roosevelt Island Transect",
  File "<stdin>", line 1
    label="Roosevelt Island Transect",
IndentationError: unexpected indent
>>>         )
  File "<stdin>", line 1
    )
IndentationError: unexpected indent
>>>         # add legend
>>>         fig.legend(position="JTR+jTR", box="+gwhite+p1p")
  File "<stdin>", line 1
    fig.legend(position="JTR+jTR", box="+gwhite+p1p")
IndentationError: unexpected indent

polartoolkits installation set up as follows, and run from CLI:

# Construct environment from yml file
conda env create -f environment.yml

# Install from local repo copy
git clone [email protected]:PennyHow/polartoolkit.git
cd polartoolkit/
pip install .
Copy link

welcome bot commented Apr 24, 2024

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines.

@mdtanker
Copy link
Owner

mdtanker commented Apr 26, 2024

I tested this and seems the issue is only that there is a blank line between the if elif and else statements. It seems this blank line is no issue in a .ipynb or a .py but doesn't work in the terminal. Will be fixed with #212

@mdtanker mdtanker linked a pull request Apr 26, 2024 that will close this issue
@PennyHow
Copy link
Contributor Author

No worries. If Jupiter/pycharm/spyder...etc. is the preferred IDE for running the examples then maybe just add a line at the beginning of the tutorials stating this as a recommendation.

@mdtanker mdtanker linked a pull request Jun 14, 2024 that will close this issue
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 a pull request may close this issue.

2 participants