vnegi10 / WeatherReport.jl

A simple weather app for the Julia REPL
MIT License
27 stars 0 forks source link

keyword "i_row" does not seem to work #75

Open stephancb opened 10 months ago

stephancb commented 10 months ago
julia> show_current("Montreal", i_row=4)
ERROR: MethodError: no method matching show_current(::String; i_row::Int64)

Closest candidates are:
  show_current(::String, ::Int64) got unsupported keyword argument "i_row"
   @ WeatherReport ~/.julia/packages/WeatherReport/TBQPY/src/plots_forecast.jl:163
  show_current(::String) got unsupported keyword argument "i_row"
   @ WeatherReport ~/.julia/packages/WeatherReport/TBQPY/src/plots_forecast.jl:163

Stacktrace:
 [1] top-level scope
julia> show_current("Montreal")
[ Info: More than one match found, showing report for location in row 1.
[ Info: You can select another location by its row index.
4×4 DataFrame
 Row │ CITY      TIMEZONE         LATITUDE  LONGITUDE 
     │ String?   String31         Float64   Float64   
─────┼────────────────────────────────────────────────
   1 │ Montreal  America/Toronto   45.5088  -73.5878
   2 │ Montreal  Europe/Paris      43.9502    0.20217
   3 │ Montreal  Europe/Paris      43.1998    2.14122
   4 │ Montreal  America/Chicago   46.428   -90.246
┌─────────────────┬───────────┬────────────┬─────────────┬───────────┬─────────┬─────────┐
│        Timezone │ Elevation │ Wind speed │ Temperature │ Condition │      🌅 │      🌆 │
│           [EST] │       [m] │     [km/h] │        [°C] │        [] │ [hh:mm] │ [hh:mm] │
├─────────────────┼───────────┼────────────┼─────────────┼───────────┼─────────┼─────────┤
│ America/Toronto │     226.0 │       14.5 │        -0.3 │  Overcast │   07:34 │   16:22 │

and

help?> show_current
search: show_current

  show_current(city::String, i_row::Int64 = 1)

  Shows the current weather conditions for a given city.

  Arguments
  ≡≡≡≡≡≡≡≡≡

    •  city::String : Valid city name, e.g. "Oslo", "Paris", "Amsterdam" etc.

    •  i_row::Int64 : In case of more than one match for a given location, select the desired timezone by providing the row index from the printed DataFrame. Default is set to 1.
vnegi10 commented 10 months ago

Hi @stephancb, i_row is not a keyword but a positional argument. I have listed keywords usually under the Optional Keywords section in the help text.

In your case, you should do the following:

julia> show_current("Montreal", 4)
[ Info: More than one match found, showing report for location in row 4.
[ Info: You can select another location by its row index.
4×4 DataFrame
 Row │ CITY      TIMEZONE         LATITUDE  LONGITUDE 
     │ String?   String31         Float64   Float64   
─────┼────────────────────────────────────────────────
   1 │ Montreal  America/Toronto   45.5088  -73.5878
   2 │ Montreal  Europe/Paris      43.9502    0.20217
   3 │ Montreal  Europe/Paris      43.1998    2.14122
   4 │ Montreal  America/Chicago   46.428   -90.246
┌─────────────────┬───────────┬────────────┬─────────────┬───────────┬─────────┬─────────┐
│        Timezone │ Elevation │ Wind speed │ Temperature │ Condition │      🌅 │      🌆 │
│           [CST] │       [m] │     [km/h] │        [°C] │        [] │ [hh:mm] │ [hh:mm] │
├─────────────────┼───────────┼────────────┼─────────────┼───────────┼─────────┼─────────┤
│ America/Chicago │     489.0 │       15.3 │        -4.6 │  Overcast │   07:44 │   16:26 │
└─────────────────┴───────────┴────────────┴─────────────┴───────────┴─────────┴─────────┘
[Weather data by Open-Meteo.com]
stephancb commented 10 months ago

I see, thanks. Perhaps in the docstring ...the row index from the printed DataFrame... could be expanded to ...the row index from the printed DataFrame as the 2nd argument...?

vnegi10 commented 10 months ago

Yes, that can easily be done. Maybe there are more locations where the description can be improved? Also, PRs are most welcome! :smiley: