Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions test/TorchSharpTest/TestTorchTensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6881,25 +6881,25 @@ public void Float64FFT()
[TestOf(nameof(fft.hfft))]
public void Float32HFFT()
{
var input = torch.arange(4);
var input = torch.arange(4, complex64);
var output = fft.hfft(input);
Assert.Equal(6, output.shape[0]);
Assert.Equal(ScalarType.Float32, output.dtype);

var inverted = fft.ifft(output);
var inverted = fft.ihfft(output);
Assert.Equal(ScalarType.ComplexFloat32, inverted.dtype);
Comment on lines +6884 to 6890
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Float32HFFT now uses complex input and is functionally identical to the existing ComplexFloat32HFFT test (and similarly Float64HFFT duplicates ComplexFloat64HFFT later in this file). This introduces redundant coverage and makes the intent of the “Float32/Float64” naming unclear. Consider removing the duplicate tests or renaming/adjusting them so each case covers a distinct scenario (e.g., only keep the Complex* variants, or have one set validate round-trip/value behavior).

Copilot uses AI. Check for mistakes.
}

[Fact]
[TestOf(nameof(fft.hfft))]
public void Float64HFFT()
{
var input = torch.arange(4, float64);
var input = torch.arange(4, complex128);
var output = fft.hfft(input);
Assert.Equal(6, output.shape[0]);
Assert.Equal(ScalarType.Float64, output.dtype);

var inverted = fft.ifft(output);
var inverted = fft.ihfft(output);
Assert.Equal(ScalarType.ComplexFloat64, inverted.dtype);
}

Expand Down Expand Up @@ -7142,10 +7142,10 @@ public void Float64RFFTN()
[TestOf(nameof(fft.hfft2))]
public void Float32HFFT2()
{
var input = torch.rand(new long[] { 5, 5, 5, 5 });
var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex64);
var output = fft.hfft2(input);
Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape);
Assert.Equal(input.dtype, output.dtype);
Assert.Equal(ScalarType.Float32, output.dtype);

var inverted = fft.ihfft2(output);
Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape);
Expand All @@ -7156,26 +7156,26 @@ public void Float32HFFT2()
[TestOf(nameof(fft.hfft2))]
public void Float64HFFT2()
{
var input = torch.rand(new long[] { 5, 5, 5, 5 }, float64);
var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex128);
var output = fft.hfft2(input);
Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape);
Assert.Equal(input.dtype, output.dtype);
Assert.Equal(ScalarType.Float64, output.dtype);

var inverted = fft.ihfft2(output);
Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape);
Assert.Equal(ScalarType.ComplexFloat64, inverted.dtype);
}

[Fact]
[TestOf(nameof(fft.hfft2))]
[TestOf(nameof(fft.hfftn))]
public void Float32HFFTN()
{
var input = torch.rand(new long[] { 5, 5, 5, 5 });
var output = fft.hfft2(input);
var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex64);
var output = fft.hfftn(input);
Comment on lines 7145 to 7174
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests (Float32HFFT2/Float64HFFT2/Float32HFFTN/Float64HFFTN) now pass complex inputs (complex64/complex128). In this file, other FFT tests use the “Float32/Float64” prefix to indicate the input dtype (e.g., Float32FFT2, Float32RFFTN). To avoid confusion, consider renaming these to reflect the complex input type (or otherwise aligning the naming scheme).

Copilot uses AI. Check for mistakes.
Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape);
Assert.Equal(input.dtype, output.dtype);
Assert.Equal(ScalarType.Float32, output.dtype);

var inverted = fft.ihfft2(output);
var inverted = fft.ihfftn(output);
Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape);
Assert.Equal(ScalarType.ComplexFloat32, inverted.dtype);
}
Expand All @@ -7188,10 +7188,10 @@ public void Float64HFFTN()

// TODO: Something in this test makes if fail on Windows / Release and MacOS / Release

var input = torch.rand(new long[] { 5, 5, 5, 5 }, float64);
var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex128);
var output = fft.hfftn(input);
Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape);
Assert.Equal(input.dtype, output.dtype);
Assert.Equal(ScalarType.Float64, output.dtype);

var inverted = fft.ihfftn(output);
Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape);
Expand Down
Loading