Skip to content

Commit b2b15a5

Browse files
committed
Updating comments and avoiding asfortranarray call for tenrand. Partially addresses sandialabs#368.
1 parent deca97d commit b2b15a5

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

pyttb/tensor.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def __init__(
138138
See Also
139139
--------
140140
* :doc:`/tutorial/class_tensor` - Getting started with the tensor class
141-
* :meth:`pyttb.tensor.from_function` - Create a tensor from a function
141+
* :meth:`from_function` - Create a tensor from a function
142142
such as :meth:`numpy.ones`
143-
* :meth:`pyttb.tensor.copy` - Make a deep copy of a tensor
143+
* :meth:`copy` - Make a deep copy of a tensor
144144
* :meth:`pyttb.sptensor.to_tensor` - Convert a sparse tensor to a dense tensor
145145
* :meth:`pyttb.ktensor.to_tensor` - Convert a Kruskal tensor to a dense tensor
146146
* :meth:`pyttb.ttensor.to_tensor` - Convert a Tucker tensor to a dense tensor
@@ -2876,8 +2876,9 @@ def tenones(shape: Shape, order: Union[Literal["F"], Literal["C"]] = "F") -> ten
28762876
----------
28772877
shape:
28782878
Shape of resulting tensor.
2879-
order:
2880-
Memory layout for resulting tensor.
2879+
order: optional
2880+
Memory layout for resulting tensor (default: F).
2881+
*Note: C order is not recommended.*
28812882
28822883
Returns
28832884
-------
@@ -2897,6 +2898,10 @@ def tenones(shape: Shape, order: Union[Literal["F"], Literal["C"]] = "F") -> ten
28972898
[[1. 1. 1.]
28982899
[1. 1. 1.]
28992900
[1. 1. 1.]]
2901+
2902+
See Also
2903+
--------
2904+
* :meth:`pyttb.tensor.from_function` - Create a tensor from a function.
29002905
"""
29012906

29022907
def ones(shape: Tuple[int, ...]) -> np.ndarray:
@@ -2912,8 +2917,9 @@ def tenzeros(shape: Shape, order: Union[Literal["F"], Literal["C"]] = "F") -> te
29122917
----------
29132918
shape:
29142919
Shape of resulting tensor.
2915-
order:
2916-
Memory layout for resulting tensor.
2920+
order: optional
2921+
Memory layout for resulting tensor (default: F).
2922+
*Note: C order is not recommended.*
29172923
29182924
Returns
29192925
-------
@@ -2948,8 +2954,9 @@ def tenrand(shape: Shape, order: Union[Literal["F"], Literal["C"]] = "F") -> ten
29482954
----------
29492955
shape:
29502956
Shape of resulting tensor.
2951-
order:
2952-
Memory layout for resulting tensor.
2957+
order: optional
2958+
Memory layout for resulting tensor (default: F).
2959+
*Note: C order is not recommended.*
29532960
29542961
Returns
29552962
-------
@@ -2968,9 +2975,7 @@ def tenrand(shape: Shape, order: Union[Literal["F"], Literal["C"]] = "F") -> ten
29682975
# Typing doesn't play nice with partial
29692976
# mypy issue: 1484
29702977
def unit_uniform(pass_through_shape: Tuple[int, ...]) -> np.ndarray:
2971-
data = np.random.uniform(low=0, high=1, size=pass_through_shape)
2972-
if order == "F":
2973-
return np.asfortranarray(data)
2978+
data = np.random.uniform(low=0, high=1, size=np.prod(pass_through_shape))
29742979
return data
29752980

29762981
return tensor.from_function(unit_uniform, shape)

0 commit comments

Comments
 (0)