-
Notifications
You must be signed in to change notification settings - Fork 10
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
Handle 1D arrays with Field API + add options to fieldType.py generator #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pmarguinaud for these additions! It all looks good to me 👍 The only point I raised is an optional change to getFieldTypeList
, which I think makes it a little simpler and more readable.
fieldType.py
Outdated
|
||
def getFieldTypeList (ranks=[2,3,4,5], kinds=kinds): | ||
return [fieldType (kind=kind, rank=rank) for (kind) in kinds for rank in ranks] | ||
def eqv (a, b): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional style change]
Perhaps this could be simplified a little:
def getFieldTypeList (ranks=[1,2,3,4,5], kinds=kinds, hasView=False, alias=True, ganged=False):
l = [fieldType (kind=kind, rank=rank) for (kind) in kinds for rank in ranks]
if hasView:
l = [ft for ft in l if ft.hasView]
if not alias:
l = [ft for ft in l if not ft.alias]
if ganged:
l = [ft for ft in l if ft.ganged]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Ahmad,
I need to make selection with True/False values, so I have to keep the eqv function. I agree that the [ft for ft in l if ...] looks better then the filter function, so I will use it. But I will keep the eqv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that just
l = [ft for ft in l if hasView is not None and hasView == ft.hasView]
or
if hasView is not None:
l = [ft for ft in l if hasView == ft.hasView]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Lukas, it works !
In Fortran, it is not possible to compare logicals with ==, but with python it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the Python style suggestions, but otherwise looks good to me.
The purpose of this branch is to add Field API classes for 1D arrays. These classes are similar to exising classes, except that :
Some extra attributes have been added to the fieldType object:
The fieldType generator has been added three extra arguments: