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

added testInterpolation for 1d grids #31

Merged
merged 4 commits into from
May 30, 2021
Merged

added testInterpolation for 1d grids #31

merged 4 commits into from
May 30, 2021

Conversation

iintSjds
Copy link
Member

No description provided.

@iintSjds iintSjds linked an issue May 26, 2021 that may be closed by this pull request
@iintSjds iintSjds requested a review from kunyuan May 26, 2021 20:23
function testInterpolation1D(func, grid1, grid2)
data1 = []
for i in 1:grid1.size
push!(data1, func(grid1[i]))
Copy link
Member

@kunyuan kunyuan May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may do it with the pythonic way

data1=[func(grid1[i]) for i in range(grid1.size)]

for i in 1:grid2.size
push!(data2, func(grid2[i]))
push!(data2_int, linear1D(data1, grid1, grid2[i]))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

data1 = []
for i in 1:grid1.size
push!(data1, func(grid1[i]))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

for i in 1:grid2.size
push!(data2, func(grid2[i]))
push!(data2_int, linear1D(data1, grid1, grid2[i]))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


Test interpolation on grid1 with function func, compare results with func(grid2).
Return max deviation and std of deviation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the standard format for the comments:

#Arguments

  • func: function needs to be interpolated
  • grid1: grid to test
  • grid2: grid to test

Return max deviation and std of deviation.

"""
function testInterpolation1D(func, grid1, grid2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may merge testInterpolation1D and testInterpolation1D_rel: You may add a flag relativeError`. If true, return relative error; if false, return absoluate error.

return d_max, d_std
end

function optimizeUniLog(generator, para, MN, func)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the standard format for the documentation

"""
function optimizeUniLog(generator, para, MN, func)

return an automatically optimized UniLog grid....

Arguments:

  • generator: function generator(para, M, N) to generate a UniLog grid
  • ...
    """

@kunyuan kunyuan merged commit c9b5fec into master May 30, 2021
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.

Exponential Grids for Tau and K
2 participants