Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2701 closed Bug (Fixed)

_ArrayTranspose() - Bug in Func or in Doc

Reported by: mLipok Owned by: Jpm
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:


in section: Return Value

@error: 1 - $aArray is not a 2D array 


#include <Array.au3>

Local $aArray[10]

ConsoleWrite('@error = ' & @error & @CRLF)

Au3 Console output: @error = 1

Au3 Console output: @error = 0

Attachments (0)

Change History (8)

comment:1 Changed 10 years ago by BrewManNH

There's definitely a bug in the new version. If the array is empty it returns 1 which is supposed to signify success, and also it appears that the documentation needs to be updated to indicate that it works with 1D arrays now as well as 2D arrays.

comment:2 Changed 10 years ago by mLipok

but is it a bug in UDF or in HelpFile ?

comment:3 Changed 10 years ago by BrewManNH

Both. They're unrelated to each other, but there are problems with the function and the help file.

One is that the function doesn't return an error for an empty array, second is the help file doesn't explain that it works with 1D arrays now and not just 2D arrays.

comment:4 Changed 10 years ago by jchd18

The function has no bug here.

First $aArray above is not an empty array: it is an uninitialized 1D array, that is a 10-dimensional column vector. Then its transpose is correctly made a 10-dimensional row vector, which in AutoIt has the form $aArray[1][10] and is displayed accordingly.

Transposing really empty arrays shouldn't produce an error either and the function correctly works as well: the result displays as $aArray[2][0], which is exactly what is expected.

Local $aArray[0][2]

ConsoleWrite('@error = ' & @error & @CRLF)

OTOH the beta help file could indeed be made clearer about the behavior.

comment:5 Changed 10 years ago by BrewManNH

I never said the example posted was an empty array, what I said was that the function doesn't return an error on an empty array. It just returns with a return value of 1 and does nothing, that is the bug.

Func _ArrayTranspose(ByRef $avArray)
	Switch UBound($avArray, 0)
		Case 0
			Return 1
		Case 1

Unless someone else thinks that not returning an error on an empty array is a good idea, this is the bug I'm talking about.

The example posted is demonstrating that in older versions of _ArrayTranspose the function would return an error if sent a 1D array. In investigating this I found the code above that showed me that there was a bug in the code, unrelated to 1D array handling. Also that the function now handles 1D arrays but there's no mention of it in the help file.

comment:6 Changed 10 years ago by Jpm

  • Milestone set to
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [10098] in version:

comment:7 Changed 10 years ago by Jpm

some doc precision was needed ...

comment:8 Changed 10 years ago by jchd18

My example showed that the function is working correctly with an empty array, which is what $aArray[0][2] is.

The test UBound($avArray, 0) being zero denotes that the variable is zero-dimensional, which means it is a flat variable (not an array). Transposing a flat variable should leave it unchanged and should definitely not raise an error, which the function again does correctly.

To see why this behavior is the mathematically correct one, see a flat variable as $vVar[1] and transpose this "vector". There is no point at all in raising an error when a sensible answer is possible.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Jpm.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.