[go: up one dir, main page]

Menu

#201 Simpler conversion between states/tensors and numpy arrays

0.3.3
done
nobody
None
nobody
2021-05-13
2020-11-09
Ulf Lorenz
No
What and Why

With the current Python interface, it is that it is relatively cumbersome to convert between tensors and Numpy arrays. This is somewhat worse for states, whose use may increase in the future because there will be Python-only functionality, e.g., with respect to plotting.

There should be some conversion functions that can directly map a state to a Numpy array. If there is any improvement possible for the conversion between tensors and numpy arrays, that would be fine as well.

Acceptance criteria
  • add a conversion function to wavepacket::State that converts a state directly into a Numpy array
    ** it is acceptable that we thus depend on numpy
  • if possible (implicit conversions?) simplify the conversion between tensors and Numpy arrays
  • Add tests for all conversions

I only did some very minimalistic changes here and improved the conversion from Numpy arrays / python buffer protocol. In general, these are mostly not that helpful, though, because in most cases you also need some input (grids), which makes the whole exercise a bit annoying.

The other direction, from tensors to Numpy arrays is a bit tricky, because you would need to actually register a specific type conversion that I frankly feel not up to right now. This has been offloaded into a separate issue [#208].

Related

Tickets: #208

Discussion

  • Ulf Lorenz

    Ulf Lorenz - 2020-11-09
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -3,3 +3,10 @@
     With the current Python interface, it is that it is relatively cumbersome to convert between tensors and Numpy arrays. This is somewhat worse for states, whose use may increase in the future because there will be Python-only functionality, e.g., with respect to plotting.
    
     There should be some conversion functions that can directly map a state to a Numpy array. If there is any improvement possible for the conversion between tensors and numpy arrays, that would be fine as well.
    +
    +#####Acceptance criteria#####
    +
    +* add a conversion function to wavepacket::State that converts a state directly into a Numpy array
    +** it is acceptable that we thus depend on numpy
    +* if possible (implicit conversions?) simplify the conversion between tensors and Numpy arrays
    +* Add tests for all conversions
    
     
  • Ulf Lorenz

    Ulf Lorenz - 2021-01-30
    • Milestone: 0.4 goal --> 0.3.3
     
  • Ulf Lorenz

    Ulf Lorenz - 2021-05-05
    • status: open --> assigned
    • assigned_to: Ulf Lorenz
     
  • Ulf Lorenz

    Ulf Lorenz - 2021-05-13
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -10,3 +10,7 @@
     ** it is acceptable that we thus depend on numpy
     * if possible (implicit conversions?) simplify the conversion between tensors and Numpy arrays
     * Add tests for all conversions
    +
    +----
    +
    +I only did some very minimalistic changes here and improved the conversion _from_ Numpy arrays / python buffer protocol. The other way is a bit tricky, because you would need to actually register a specific type conversion that I frankly feel not up to right now. This has been offloaded into a separate issue [#208].
    
    • status: assigned --> done
    • assigned_to: Ulf Lorenz --> nobody
     

    Related

    Tickets: #208

  • Ulf Lorenz

    Ulf Lorenz - 2021-05-13
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -13,4 +13,6 @@
    
     ----
    
    -I only did some very minimalistic changes here and improved the conversion _from_ Numpy arrays / python buffer protocol. The other way is a bit tricky, because you would need to actually register a specific type conversion that I frankly feel not up to right now. This has been offloaded into a separate issue [#208].
    +I only did some very minimalistic changes here and improved the conversion _from_ Numpy arrays / python buffer protocol. In general, these are mostly not that helpful, though, because in most cases you also need some input (grids), which makes the whole exercise a bit annoying.
    +
    +The other direction, from tensors _to_ Numpy arrays is a bit tricky, because you would need to actually register a specific type conversion that I frankly feel not up to right now. This has been offloaded into a separate issue [#208].
    
     

    Related

    Tickets: #208


Log in to post a comment.