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

Create to_field function #295

Open
ericspod opened this issue May 3, 2022 · 0 comments
Open

Create to_field function #295

ericspod opened this issue May 3, 2022 · 0 comments
Assignees

Comments

@ericspod
Copy link
Member

ericspod commented May 3, 2022

Create a function called to_field which accepts something that can be coerced into a Numpy array and returns a new field containing that data. Other arguments such as dtype may be needed. The method should use np.asarray to coerce the input to an array. The dtype of the array should be checked to see if it's a known type, if not raise an exception.

For example:

n=np.random.rand(10,dtype=np.float32)

f=exetera.core.fields.to_field([1,2,3])  # using asarray this can be used to create a field from Python array data

f=exetera.core.fields.to_field(n)  # returns a new field containing float32

f1= exetera.core.fields.to_field(n) + n  #  allows adding numpy arrays to the new field

Do we want a to_categorical_field as well?

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

No branches or pull requests

2 participants