Giter VIP home page Giter VIP logo

pleque's People

Contributors

coobas avatar davidtskhakaya avatar evamac avatar jirakova avatar kripnerl avatar mateasek avatar ondrejfi avatar peterkamatej avatar seidlj avatar smartass101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nucg1gb louloufev

pleque's Issues

io.compass - Use last revision by default

Function pleque.io.compass.cdb() uses revision=1 as a default parameter value. I would propose a change to revision=-1, i.e. the most recent revision.

Arguments:

  • On the one hand, the original behaviour enforces some degree of reproducibility of the returned value on subsequent calls. On the other hand, there are cases where the revision=1 data in CDB are broken (cause exception when you attempt to load them) but a fixed version of the data are available in revision=2. As a result, the original behaviour ensures that that particular discharge will always throw error, possibly misleading the user into thinking that no "fixed data" exist.
  • A second argument for the change is the fact that the pyCDB client loads the most recent revision by default. A user then might logically expect the same behaviour from pleque as well, since this feels as the defining property/philosophy of the CDB database itself (i.e. "last revision is always/eventually the best revision which everyone should use").

Nine or zero?

I suppose there should be 9 instead of 0

attrs_pos = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17]

instead of

attrs_pos = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 11, 13, 15, 17]

attrs_pos = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 10, 11, 13, 15, 17]

Set ".shot" attribute of Equilibrium when loading using io.compass.cdb()

Currently, Equilibrium object loaded via pleque.io.compass.cdb() has .shot=0. This then causes further minor inconveniences such as the loss of this metadata when writing the equilibrium into a file, e.g. to_geqdsk(). While I usually depend on the filename to store this metadata (shot number and time) I feel like it would be nice to have this additional backup given that this is already a feature of the eqdsk format.

Proposal for fix:

Probaly just add something like

# Accessing `sig_ref` instead of parameter `shot` should handle cases when user uses `shot=None`
eq.shot = sig_ref.record_number

added just below

eq = read_efithdf5(data_ref.full_path, time=time)

Proposal for further investigation:

  • Might be worth to look into the other io options (such as cudb) and how they handle the shot attribute, potentially fix them as well

copy object to itself

@smartass101 @coobas
Is it possible to simply satisfy something like this:

class A:
  def __init__(self, name):
    if isinstance(name, str):
      self.name = name
    elif isinstance(name, A):
      self = name

a = A('foo')
b = A(a)

Where I intend to a and b be the same objects/or copies of one object.
Thanks

FluxSurface class

  • implement into class Equilibrium as
def flux_surface(*coordinates, psi_n=None, coord_type=('psi_n'), resolution = 100, **coords):
    """
    :param resolution: number of points used for generation of FluxSurface
    :return FluxSurface or list of FluSurfaces generated on given coordinates. 
    """
    grid = False
    ...
  • add test file to test all implemented functions
  • FluxSurface should accept instance of Coordinates on input
  • implement (r, theta) coordinates into Coordinates class
  • implement as_array into Coordinates
  • all functions returning some set of points should return instance of Coordinates

Pleque Structure

While preparing export of FluxFunction objects to omas I realised this is one way how to get equilibrium data from a coordinate object is for example this:

coords._eq.tor_flux(coords)

I am not sure if the possibility or need to do this is a good Idea. I am also afraid it could lead to growing ambiguity, cyclic referencing and confusion in the module and it's using as it grows.

Please correct me if I'm wrong.

Equilibriumclass functions work with coordinates objects, e.g.:

code

The equilibrium object has to be passed to the coordinates upon creation and is saved as a property :
code

Isn't this kind of a cycle which could in future fire back? Another disadvantage is (as I've already mentioned) is that the user has to be either keeping both equilibrium and coordinates objects to get
some equilibrium value for the coordinates (although the equilibrium is saved in coordinates), e.g.:

equi = Equilibrium(...)
coords = equi.coordinates(...)
equi.tor_flux(coords)
`
or keep using this:

equi = Equilibrium(...)
coords = equi.coordinates(...)
coords._equi.tor_flux(coords)
`

I might be wrong disliking this and maybe this way is the correct way. But I think the structure of the whole module should be changed to avoid this. One possibility to solve this could could be by using inheritance by making the coordinates class child class of the equilibrium. What do you think?

Test failures on master

Hello, I just cloned master and ran:

python3 -m venv testvenv
source testvenv/bin/activate
pip install -U pip
pip install -e .
pip install pytest
pytest

and got the following test failures/errors:

===================================================================================================================================================== warnings summary ======================================================================================================================================================
pleque/core/equilibrium.py:215: 5 tests with warnings
tests/compu_test.py: 1 test with warning
tests/test_2Dinterpolation.py: 6 tests with warnings
tests/test_cocos.py: 48 tests with warnings
tests/test_coordinates.py: 6 tests with warnings
tests/test_equilibria.py: 12 tests with warnings
tests/test_gfile.py: 12 tests with warnings
tests/test_io.py: 6 tests with warnings
tests/test_surface_param.py: 1 test with warning
  /home/peter/Codes/pleque/pleque/core/equilibrium.py:215: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead

pleque/core/coordinates.py:463
  /home/peter/Codes/pleque/pleque/core/coordinates.py:463: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working

pleque/io/metis.py:37
  /home/peter/Codes/pleque/pleque/io/metis.py:37: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.

testvenv/lib64/python3.7/site-packages/numpy/lib/type_check.py:277
  /home/peter/Codes/pleque/testvenv/lib64/python3.7/site-packages/numpy/lib/type_check.py:277: FutureWarning: elementwise == comparison failed and returning scalar instead; this will raise an error or perform elementwise comparison in the future.

testvenv/lib64/python3.7/site-packages/omas/omas_setup.py:16
  /home/peter/Codes/pleque/testvenv/lib64/python3.7/site-packages/omas/omas_setup.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working

testvenv/lib64/python3.7/site-packages/omas/omas_hdc.py:9
  /home/peter/Codes/pleque/testvenv/lib64/python3.7/site-packages/omas/omas_hdc.py:9: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================================================================================================================== short test summary info ==================================================================================================================================================
FAILED tests/compu_test.py::test_compu - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/surfaces_test.py::test_surfs - assert array([], shape=(1, 0), dtype=float64) is None
FAILED tests/test_cocos.py::test_directions[5-1] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_directions[5-2] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_directions[5-3] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_directions[5-4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-1] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-2] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-3] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-6] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-7] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_coordinates_transforms[5-8] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-1] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-2] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-3] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-6] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-7] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_cocos.py::test_cocos_consistency[5-8] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_equilibria.py::test_equilibria[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
FAILED tests/test_equilibria.py::test_equilibria[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_gfile.py::test_calculated_profiles[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
FAILED tests/test_surface_param.py::test_q_profiles - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_2Dinterpolation.py::test_surfacefunction[4-data0-coord10-coord20-3-1] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_2Dinterpolation.py::test_surfacefunction[4-data1-coord11-coord21-3-0] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_2Dinterpolation.py::test_surfacefunction[5-data0-coord10-coord20-3-1] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_2Dinterpolation.py::test_surfacefunction[5-data1-coord11-coord21-3-0] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_coordinates.py::test_coordinates[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_coordinates.py::test_coordinates[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_equilibria.py::test_critical[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_equilibria.py::test_eq_properties[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_equilibria.py::test_critical[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_equilibria.py::test_eq_properties[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_gfile.py::test_from_to_gfile[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_gfile.py::test_from_to_gfile[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
ERROR tests/test_io.py::test_dict2xarray[4] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 2 has size 2
ERROR tests/test_io.py::test_dict2xarray[5] - ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 0 and the array at index 1 has size 2
======================================================================================================================= 26 failed, 56 passed, 1 skipped, 102 warnings, 14 errors in 226.26s (0:03:46) =======================================================================================================================

Happy to attach the full failure log if that would be helpful!

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.