-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2440 from CliMA/ck/gpu_compat
Assert atmos to not have UnionAll types
- Loading branch information
Showing
5 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
@any_reltype(::Any, t::Tuple, warn=true) | ||
Returns a Bool (and prints warnings) if the given | ||
data structure has an instance of any types in `t`. | ||
""" | ||
function any_reltype(found, obj, name, ets, pc = (); warn = true) | ||
for pn in propertynames(obj) | ||
prop = getproperty(obj, pn) | ||
pc_full = (pc..., ".", pn) | ||
pc_string = name * string(join(pc_full)) | ||
for et in ets | ||
if prop isa et | ||
warn && @warn "$pc_string::$(typeof(prop)) is a DataType" | ||
found = true | ||
end | ||
end | ||
found = found || any_reltype(found, prop, name, ets, pc_full; warn) | ||
end | ||
return found | ||
end | ||
macro any_reltype(obj, ets, warn = true) | ||
return :(any_reltype( | ||
false, | ||
$(esc(obj)), | ||
$(string(obj)), | ||
$(esc(ets)); | ||
warn = $(esc(warn)), | ||
)) | ||
end |