GithubHelp home page GithubHelp logo

Non-uniform grids in 0.6.0 about findiff HOT 8 CLOSED

maroba avatar maroba commented on July 19, 2024
Non-uniform grids in 0.6.0

from findiff.

Comments (8)

maroba avatar maroba commented on July 19, 2024

Hi,

actually the api shouldn‘t have changed from 0.5.2 to 0.6.0 and the examples should still apply... don‘t they?

Well, but you are right, the readme is incorrect there. But it’s not only ‚y’ either. It should contain the „coords“ keyword. I will correct it tomorrow after work.

You can find some non-uniform examples in the test folder in the test_findiff module.

If you have any questions or notice bugs, please let me know. :-)

from findiff.

duartenina avatar duartenina commented on July 19, 2024

Using the examples found in the readme and /examples, the same error appears (in 0.6.0):

Traceback (most recent call last):
  File "test2.py", line 58, in <module>
    d_dx = FinDiff(0, x_nu, acc=2)
  File "C:\Programs\Anaconda3\lib\site-packages\findiff\findiff.py", line 21, in __init__
    self.root = PartialDerivative(*args)
  File "C:\Programs\Anaconda3\lib\site-packages\findiff\findiff.py", line 210, in __init__
    tuples = self._convert_to_valid_tuple_list(args)
  File "C:\Programs\Anaconda3\lib\site-packages\findiff\findiff.py", line 262, in _convert_to_valid_tuple_list
    self._assert_tuple_valid(t)
  File "C:\Programs\Anaconda3\lib\site-packages\findiff\findiff.py", line 273, in _assert_tuple_valid
    if h <= 0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The code used in /test is working.

from findiff.

duartenina avatar duartenina commented on July 19, 2024

OK, I tested a bit more. FinDiff still requires at least two arguments when using the coords kwarg, but it ignores the second argument (the spacing). To change the order of the derivative, we need to give FinDiff three arguments.

Code used to test it: https://gist.github.com/duartenina/d02791e2b3733d3e18ff829bc6e8b241.

EDIT: For 1D grids, it is necessary to wrap the coords in a list. The documentation is ambiguous in this case.

from findiff.

maroba avatar maroba commented on July 19, 2024

Thanks for the sample! I see I have mixed up the 0.5.2 API and what I tried out during development. Then I accidentally merged the experiments into the master, including their correctly running tests. ;-) I fixed that now and published a patch version 0.6.1 where the examples should run as in 0.5.2 with the same API. Could you try it, please?

from findiff.

duartenina avatar duartenina commented on July 19, 2024

The 0.5.2 API now works correctly, but the new one doesn't. It should accept "(axis, count)" for non-uniform grids., but if you give two or three args and the coords kwarg, it will interpret the second arg as spacing and ignore the coords.

Code here.

figure_1

EDIT: This was the same behaviour as 0.5.2.

from findiff.

maroba avatar maroba commented on July 19, 2024

Oh, I see. I shouldn't rely on memory but look up the code history instead. ;-)

To be honest, I regret having introduced the syntax corresponding to the orange dots in your picture and actually would prefer to support only the syntax corresponding to the green one. It would make maintenance life much easier and is also more in line with the pattern for uniform grids (axis, spacing,[order]) <--> (axis, coords, [order]), where [] means optional. I'd appreciate your opinion on this. What do you think?

from findiff.

duartenina avatar duartenina commented on July 19, 2024

I also think it's more intuitive just to replace the 'spacing' for the 'coords'. I'm not sure what would be the advantage of the other syntax.

from findiff.

maroba avatar maroba commented on July 19, 2024

Agreed then. I have published 0.6.2 accordingly.

from findiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.