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

Pint's usage with Numpy's concatenate #619

Closed
winash12 opened this issue Feb 20, 2018 · 1 comment · Fixed by #905
Closed

Pint's usage with Numpy's concatenate #619

winash12 opened this issue Feb 20, 2018 · 1 comment · Fixed by #905

Comments

@winash12
Copy link

winash12 commented Feb 20, 2018

import numpy as np

from pint import UnitRegistry

ureg = UnitRegistry()

Q_ = ureg.Quantity

args = []

for k in range(0,17):
   uwnd = Q_(np.ones((1,73,144)),'meter / second')
    args.append(uwnd)
uwndTot = np.vstack(args)
print(uwndTot.shape)
for element in args:
   print(type(element)

I am using Pint and when I print the shape uwndTot I get
(17,73,144).

When I print the values of element it turns out to be

<class 'pint.quantity.build_quantity_class..Quantity'>

However if I iterate through uwndTot I get

for element in uwndTot:
    print(type(element))

I get

<class 'numpy.ndarray'>

I want to be able to use numpy's concatenate with Pint. Is that not possible ? I need the units of meters /second in the 3d dimensional array uwndTot. How do I do that ?

@hgrecco
Copy link
Owner

hgrecco commented Mar 23, 2018

Vstack is casting to a numpy array.

You can create your own wrapped version of vstack See here

@bors bors bot closed this as completed in 43fbae2 Dec 11, 2019
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

Successfully merging a pull request may close this issue.

2 participants