Skip to content

Commit

Permalink
swapping some strings
Browse files Browse the repository at this point in the history
  • Loading branch information
john-b-edwards committed Oct 14, 2024
1 parent 4c029da commit 464a7b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/ffverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function load_ff_playerids()
end

"""
load_ff_rankings(type::String = "draft")
load_ff_rankings(type::AbstractString = "draft")
Load current fantasy football rankings from FantasyPros.com. The argument `type` has three valid parameters:
* `"draft"`: FantasyPros rankings for draft leagues for the current fantasy football season. The default parameter.
Expand All @@ -29,7 +29,7 @@ Load current fantasy football rankings from FantasyPros.com. The argument `type`
For information about this resource, see its data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_ff_rankings.html).
"""
function load_ff_rankings(type::String = "draft")
function load_ff_rankings(type::AbstractString = "draft")
if !(type in ["draft","week","all"])
throw(DomainError(type,"Please pass in one of \"draft\", \"week\", or \"all\" for the argument `type`!"))
end
Expand All @@ -44,7 +44,7 @@ function load_ff_rankings(type::String = "draft")
end

"""
function load_ff_opportunity(seasons::Number = most_recent_season(), stat_type::String = "weekly", model_version::String = "latest")
function load_ff_opportunity(seasons::Number = most_recent_season(), stat_type::AbstractString = "weekly", model_version::AbstractString = "latest")
Load the FFOpportunity dataset for a given season. `seasons` indicates the years to pull data from and defaults to the most recently played NFL season. Pass in `seasons = true` for all available seasons.
`stat_type` takes three potential arguments:
Expand All @@ -59,8 +59,8 @@ Load the FFOpportunity dataset for a given season. `seasons` indicates the years
For information about this resource, see its data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_ff_opportunity.html).
"""
function load_ff_opportunity(seasons = most_recent_season(),
stat_type::String = "weekly",
model_version::String = "latest")
stat_type::AbstractString = "weekly",
model_version::AbstractString = "latest")
seasons = check_years(seasons, 2006, "FF opportunity data")
if !(stat_type in ["weekly","pbp_pass","pbp_rush"])
throw(DomainError(stat_type,"Please pass in one of \"weekly\",\"pbp_pass\",\"pbp_rush\" for the argument `stat_type`!"))
Expand Down
8 changes: 4 additions & 4 deletions src/getdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function __init__()
end

"Helper function for reading a .parquet file to a DataFrame (while ensuring the connection closes after the file is read)."
function parquet2df(file::String)
function parquet2df(file::AbstractString)
open(file) do io
ds = Parquet2.Dataset(io)
df = DataFrame(ds)
Expand All @@ -70,11 +70,11 @@ function parquet2df(file::String)
end

"""
from_url(url::String; file_type::String = ".parquet")
from_url(url::AbstractString; file_type::AbstractString = ".parquet")
Reads a file from a URL and caches it. `file_type` can be one of `".parquet"`, `".csv"`, or `".csv.gz"`.
"""
function from_url(url::String; file_type::String = ".parquet")
function from_url(url::AbstractString; file_type::AbstractString = ".parquet")
if !(file_type in [".parquet",".csv",".csv.gz"])
throw(DomainError(file_type,"`file_type` must be one of either \".parquet\", \".csv\", or \".csv.gz\"."))
end
Expand All @@ -101,7 +101,7 @@ function from_url(url::String; file_type::String = ".parquet")
end

"..."
function from_url(url::String, seasons::Int; file_type::String = ".parquet")
function from_url(url::AbstractString, seasons::Int; file_type::AbstractString = ".parquet")
if !(file_type in [".parquet",".csv",".csv.gz"])
throw(DomainError(file_type,"`file_type` must be one of either \".parquet\", \".csv\", or \".csv.gz\"."))
end
Expand Down
12 changes: 6 additions & 6 deletions src/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function compute_labor_day(season::Int)
end

"""
clean_team_abbrs(team::String; current_location::Bool = true, keep_non_matches::Bool = true)
clean_team_abbrs(team::AbstractString; current_location::Bool = true, keep_non_matches::Bool = true)
Clean abbreviations of teams to NFLverse friendly abbreviations.
Expand All @@ -59,7 +59,7 @@ julia> clean_team_abbrs("SD")
"LAC"
```
"""
function clean_team_abbrs(team::String; current_location::Bool = true, keep_non_matches::Bool = true)
function clean_team_abbrs(team::AbstractString; current_location::Bool = true, keep_non_matches::Bool = true)
if current_location
m = team_abbr_mapping
else
Expand All @@ -76,7 +76,7 @@ function clean_team_abbrs(team::String; current_location::Bool = true, keep_non_
end

"""
clean_player_names(player_name::String; lowercase::Bool = false, convert_lastfirst::Bool = true, use_name_database::Bool = true, convert_to_ascii::Bool = true)
clean_player_names(player_name::AbstractString; lowercase::Bool = false, convert_lastfirst::Bool = true, use_name_database::Bool = true, convert_to_ascii::Bool = true)
Clean up player names for merges. Can convert names to lowercase, swap first/last names, remove diacritics, and also rely on manual overrides as specified by nflverse devs.
Expand All @@ -102,7 +102,7 @@ julia> clean_player_names("Gordon Jr., Melvin", convert_lastfirst = true)
"Melvin Gordon"
```
"""
function clean_player_names(player_name::String; lowercase::Bool = false, convert_lastfirst::Bool = true, use_name_database::Bool = true, convert_to_ascii::Bool = true)
function clean_player_names(player_name::AbstractString; lowercase::Bool = false, convert_lastfirst::Bool = true, use_name_database::Bool = true, convert_to_ascii::Bool = true)

player_name = strip(replace(player_name,r"\s+"=>" "))
if convert_lastfirst
Expand All @@ -126,7 +126,7 @@ function clean_player_names(player_name::String; lowercase::Bool = false, conver
end

"""
nflverse_game_id(season::Number,week::Number,away::String,home::String)
nflverse_game_id(season::Number,week::Number,away::AbstractString,home::AbstractString)
Check and calculate an nflverse game ID.
Expand All @@ -137,7 +137,7 @@ julia> nflverse_game_id(2022, 2, "LAC", "KC")
"2022_02_LAC_KC"
```
"""
function nflverse_game_id(season::Number,week::Number,away::String,home::String)
function nflverse_game_id(season::Number,week::Number,away::AbstractString,home::AbstractString)
check_years(season, 1999, "NFLverse game ID")
if (week > 22) | (week < 0)
throw(DomainError(week,"`week` must be between 1 and 22!"))
Expand Down
14 changes: 7 additions & 7 deletions src/statsdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export load_player_stats
export load_snap_counts

"""
load_espn_qbr(summary_type::String = "season")
load_espn_qbr(summary_type::AbstractString = "season")
Load ESPN QBR data. Defaults to loading data by `"season"`, pass in `"week"` to `summary_type` to get weekly QBR data. For information about this resource, see its data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_espn_qbr.html).
"""
function load_espn_qbr(summary_type = "season")
function load_espn_qbr(summary_type::AbstractString = "season")
if !(summary_type in ["season","week"])
throw(DomainError(summary_type,"Please pass in one of \"season\" or \"week\" for the argument `summary_type`!"))
end
Expand All @@ -28,11 +28,11 @@ function load_espn_qbr(summary_type = "season")
end

"""
load_nextgen_stats(stat_type::String = "passing")
load_nextgen_stats(stat_type::AbstractString = "passing")
Load NGS data by week. Specify the types of stats returned by passing in one of the following to `stat_type`: `"passing"`, `"receiving"`,`"rushing"`. For information about this resource, see its data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_nextgen_stats.html).
"""
function load_nextgen_stats(stat_type::String = "passing")
function load_nextgen_stats(stat_type::AbstractString = "passing")
if !(stat_type in ["passing", "receiving", "rushing"])
throw(DomainError(stat_type,"Please pass in one of \"passing\",\"receiving\",\"rushing\" for the argument `stat_type`!"))
end
Expand All @@ -51,7 +51,7 @@ Specify the summary level of stats returned by passing one of `"week"` or `"seas
For information about this resource, see its data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_pfr_passing.html).
"""
function load_pfr_advstats(seasons = most_recent_season(), stat_type::String = "pass", summary_level::String = "week")
function load_pfr_advstats(seasons = most_recent_season(), stat_type::AbstractString = "pass", summary_level::AbstractString = "week")
seasons = check_years(seasons, 2018, "PFR advanced stats")
if !(stat_type in ["pass","rush","rec","def"])
throw(DomainError(stat_type,"Please pass in one of \"pass\",\"rush\",\"rec\", or \"def\" for the argument `stat_type`!"))
Expand All @@ -70,13 +70,13 @@ function load_pfr_advstats(seasons = most_recent_season(), stat_type::String = "
end

"""
load_player_stats(stat_type::String = "offense")
load_player_stats(stat_type::AbstractString = "offense")
Load stats for individual players as calculated from NFLFastR PBP data. Specify the type of stats returned by passing one of `"offense"`, `"defense"`, or `"kicking"` to `stat_type`.
For information about this resource, see the offensive stats data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_player_stats.html), and the defensive stats data dictionary [here](https://nflreadr.nflverse.com/articles/dictionary_player_stats_def.html).
"""
function load_player_stats(stat_type::String = "offense")
function load_player_stats(stat_type::AbstractString = "offense")
if stat_type == "offense"
file_ext = "player_stats"
elseif stat_type == "defense"
Expand Down

0 comments on commit 464a7b7

Please sign in to comment.