import numpy as np
from pint import UnitRegistry
unit = UnitRegistry()
Q_ = unit.Quantity
a = 1.0*unit.meter
b = 2.0*unit.meter
# some calculations that change a and b
x=np.array([a.magnitude,b.magnitude])*Q_(1.0,a.units)
will make a numpy array from variables a and b which are Pint quantities. It is somewhat crude as there is no guarantee that a and b have the same units. Is there a cleaner way to do it? Do I need to write a function?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)