Skip to content

Type agnostic, finite recursive_bottom_eltype function - #55

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
janlucaklees:recursive_bottom_eltype-improvement
Jun 28, 2019
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
janlucaklees:recursive_bottom_eltype-improvement

Conversation

@janlucaklees

Copy link
Copy Markdown
Contributor

Before the recursive_bottom_eltype function was written with only
numeric types in mind. For those, it worked. But for non-numeric types
it recused infinitely, causing a StackOverflowError.
Now it works on any type and is sure to recurse only a finite number of
time, thus always end and return a result.
The recursion ends, when the given argument a is the same as eltype(a). So, as there is a limited amount of types in Julia, we will only recurse a limited amount of times.

I also added tests that cover this specific function, testing numbers
with and without units as well as chars and strings.

Before the `recursive_bottom_eltype` function was written with only
numeric types in mind. For those, it worked. But for non-numeric types
it recused infinitely, causing a `StackOverflowError`.
Now it works on any type and is sure to recurse only a finite number of
time, thus always end and return a result.

I also added tests that cover this specific function, testing numbers
with and without units as well as chars and strings.
@ChrisRackauckas

Copy link
Copy Markdown
Member

Wow, somehow I completely didn't see this PR. Sorry!

@ChrisRackauckas
ChrisRackauckas merged commit f5e3c91 into SciML:master Jun 28, 2019
@janlucaklees

Copy link
Copy Markdown
Contributor Author

Wow, somehow I completely didn't see this PR. Sorry!

No worries :)

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 this pull request may close these issues.

2 participants