test_vector


Modeling and Simulation in Python

Copyright 2017 Allen Downey

License: Creative Commons Attribution 4.0 International


In [16]:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline

# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'

# import functions from the modsim.py module
from modsim import *

In [17]:
x = 1 * UNITS.meter


Out[17]:
1 meter

In [18]:
v = Vector(2,3).hat()


Out[18]:
[0.5547002 0.83205029] dimensionless

In [19]:
vp = x * v


Out[19]:
[0.5547002 0.83205029] meter

In [20]:
type(v)


Out[20]:
modsim._Vector

In [21]:
type(v * 3)


Out[21]:
modsim._Vector

In [22]:
type(v * x)


Out[22]:
modsim._Vector

In [23]:
type(x * v)


Out[23]:
pint.unit.build_quantity_class.<locals>.Quantity