adding api doc and cleanup of Shape and related concepts#94
Conversation
marcelluethi
commented
Apr 21, 2026
- Add API doc to all classes
- Reorder concepts in Axis
- Add Label instance to axis
- Make Axis a concrete class
- Add API doc to all classes - Reorder concepts in Axis - Add Label instance to axis - Make Axis a concrete class
| * @param args A tuple of AxisExtents from which to create the shape. | ||
| * @return A shape with dimensions corresponding to the sizes of the AxisExtents in the | ||
| */ | ||
| def apply[A <: Tuple](args: A)(using ev: Union[A] <:< AxisExtent[?], n: Labels[ExtractLabels[A]]): Shape[ExtractLabels[A]] = |
There was a problem hiding this comment.
Is definition change intended? Seems like Union[A] evidence was added.
There was a problem hiding this comment.
Yes that was by purpose. The idea was to make it clear that it needs to be a subtype of AxisExtent and not just an arbitrary tuple. Not sure if it helps - no strong opinion.
| * @param args A tuple of AxisExtents from which to create the shape. | ||
| * @return A shape with dimensions corresponding to the sizes of the AxisExtents in the tuple. | ||
| */ | ||
| def fromTuple[A <: Tuple](args: A)(using ev: Union[A] <:< AxisExtent[?], n: Labels[ExtractLabels[A]]): Shape[ExtractLabels[A]] = |
| case _ => jaxValue.toString() | ||
|
|
||
| def extent[L](axis: Axis[L])(using ev: AxisIndex[T, L]): AxisExtent[L] = | ||
| def extent[L: Label](axis: Axis[L])(using ev: AxisIndex[T, L]): AxisExtent[L] = |
There was a problem hiding this comment.
Was label evidence added on purpose. I suggest removing it if not necessary in the method.
There was a problem hiding this comment.
Also here I thought that adding a label for documentation could help. It is not really needed but in most other method when we have this type parameter it also needs to be a label. so why not adding it here? Again, I have no strong opinion.
| import scala.annotation.publicInBinary | ||
| import ShapeTypeHelpers.AxisIndex | ||
| import dimwit.tensor.{Labels, Label} | ||
| import scala.Tuple.Union |
| * @param axis The axis for which to retrieve the extent. | ||
| * @return The extent of the specified axis. | ||
| */ | ||
| def extent[L: Label](axis: Axis[L])(using ev: AxisIndex[T, L]): AxisExtent[L] = AxisExtent(axis, this(axis)) |
There was a problem hiding this comment.
L Label evidence added. See other comment.
|
Please check comments. If changes are intended and make sense I will accept PR. |
Co-authored-by: Copilot <copilot@github.com>
|
The issues have been resolved by using better names for the type parameters and arguments. |