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

import quaternion as, e.g., quat? #37

Closed
calocedrus opened this issue Mar 10, 2017 · 1 comment
Closed

import quaternion as, e.g., quat? #37

calocedrus opened this issue Mar 10, 2017 · 1 comment

Comments

@calocedrus
Copy link

Hi, I'm currently exploring your quaternion module. This is more of a curiosity question that I have rather than an issue, likely arising from to my limited knowledge in python rather than a limitation in your module.
When I try:

import numpy as np
import quaternion as quat
myq = np.quat(0,1,0,0)

I get
AttributeError: module 'numpy' has no attribute 'quat'
but

import numpy as np
import quaternion as quaternion
myq = np.quaternion(0,1,0,0)

is fine.
Why can't I import quaternion as whatever_name_I_chose?

@moble
Copy link
Owner

moble commented Mar 10, 2017

There are two separate things going on here. There's the quaternion module, which you've successfully imported as quat in the first case. Then there's the np.quaternion submodule that gets inserted into numpy (under whatever name you've imported it; in this case np). You can't change the name of the submodule because you didn't directly create it; it's hard-coded in the quaternion.__init__.py file.

So you could do

import numpy as np
import quaternion as quat
myq = np.quaternion(0,1,0,0)
myq2 = quat.quaternion(0,1,0,0)

You could also do

import numpy
import quaternion as quat
myq = numpy.quaternion(0,1,0,0)
myq2 = quat.quaternion(0,1,0,0)

@moble moble closed this as completed Mar 10, 2017
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