Skip to content

Vector tensor product - #681

Merged
argerlt merged 11 commits into
pyxem:developfrom
argerlt:vector_tensor_product
Oct 16, 2026
Merged

argerlt merged 11 commits into
pyxem:developfrom
argerlt:vector_tensor_product

Conversation

@argerlt

@argerlt argerlt commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description of the change

  1. Adds Vector3d.tensor and Vector3d.tensor_outer
  2. Updates test_vector3d.py to better match the class-level organization of other test files and increases overage.

NOTE: this looks like a large update, but 300+ lines are just reformatting existing tests.

I would like to add this to the 0.16 release if possible.

Progress of the PR

Minimal example of the bug fix or new feature

# Using the definition of the tensor product as verification:
a = Vector3d.random()
b = Vector3d.random()
c = Vector3d.random()
abc = np.dot((a.tensor(b)[0]), c.data[0])
bca = (b.dot(c) * a).data
abc_outer = np.dot((a.tensor_outer(b)[0]), c.data[0])

# printing an example
print(a,'\n\n',b,'\n\n',a.tensor(b)[0])

>>> Vector3d (1,)
          [[ 0.8429 -0.3101  0.4398]] 
>>> Vector3d (1,)
           [[0.4767 0.1299 0.8694]] 
>>>  [[ 0.40181049  0.10951157  0.73277669]
          [-0.14782216 -0.04028824 -0.26958139]
          [ 0.20967513  0.05714598  0.38238187]]

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • Contributor(s) are listed correctly in __credits__ in orix/__init__.py and in
    .zenodo.json.

@argerlt argerlt mentioned this pull request Sep 4, 2026
@argerlt argerlt linked an issue Sep 4, 2026 that may be closed by this pull request
@argerlt argerlt added the status: needs-review This pull request needs a maintainer's review label Sep 15, 2026
… available functionality

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes

Copy link
Copy Markdown
Member

Going over this now. Seems like a great addition to vector arithmetics!

@argerlt, is it OK if I add an example with vector arithmetics to the gallery, including a section on vector tensor products? This requires a new vector examples section, with vector arithmetics as the first example (and, for now, only).

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes

Copy link
Copy Markdown
Member

I got the go-ahead off GitHub, so I've added the example. I've also touched up the docstrings and fixed the return type hint.

Just have to go over the tests, then we can merge.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes

Copy link
Copy Markdown
Member

@argerlt, feel free to merge this! I may do so within a couple days if you don't.

@hakonanes hakonanes removed the status: needs-review This pull request needs a maintainer's review label Oct 14, 2026
@hakonanes hakonanes added this to the v0.16.0 milestone Oct 14, 2026
@argerlt

argerlt commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

I like these additions, and I also really like the new example. Merging now.

@argerlt
argerlt merged commit a35d4a0 into pyxem:develop Oct 16, 2026
11 checks passed
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 this pull request may close these issues.

Vector tensor product?

2 participants