Concatenating two Arrays #572
-
First of all thanks for the project. I think is a very cool idea, but I am struggling in with a very simple case: Goal: I want to concatenate to FieldArraysI have two arrays Put it in code: A = F([[1, 2], [3, 4]])
B = F([[5, 6], [7, 8]])
C = F([[1, 2], [3, 4], [5, 6], [7, 8]]) Failed Approaches:I have tried a couple approaches before comming here, and all have failed:
C = np.concatenate(A, B)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alv/.local/share/virtualenvs/binius-uW3OI3G1/lib/python3.12/site-pack
ages/galois/_domains/_function.py", line 373, in __array_function__
output = super().__array_function__(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: only integer scalar arrays can be converted to a scalar index
C = A.append(B)
^^^^^^^^^^^^
AttributeError: 'FieldArray_101_2' object has no attribute 'append'
I am missing something? If I could go out of my way, to get it work. But I also think that if the purpose of the library is to provide a seamless experience with np, scipy, ... such an elementary operation should provide a simple interface. SolutionAfter a couple more trials I made it work by calling: C = np.append(A, B, axis=0) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is this your goal? I think import galois
F = galois.GF(101)
A = F([[1, 2], [3, 4]])
B = F([[5, 6], [7, 8]])
C = np.vstack((A, B))
print(C)
|
Beta Was this translation helpful? Give feedback.
Is this your goal? I think
np.vstack()
andnp.hstack()
may be what you're looking for.