Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2701 closed Bug (Fixed)

_ArrayTranspose() - Bug in Func or in Doc

Reported by: mLipok Owned by: J-Paul Mesnage
Milestone: 3.3.11.6 Component: Standard UDFs
Version: 3.3.11.5 Severity: None
Keywords: Cc:

Description

in section: Return Value

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

REPRO:

#include <Array.au3>

Local $aArray[10]

_ArrayDisplay($aArray)
_ArrayTranspose($aArray)
ConsoleWrite('@error = ' & @error & @CRLF)
_ArrayDisplay($aArray)

Au3 3.3.10.2 Console output: @error = 1

Au3 3.3.11.5 Console output: @error = 0

Attachments (0)

Change History (8)

comment:1 by BrewManNH, 12 years ago

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 by mLipok, 12 years ago

hmm...
but is it a bug in UDF or in HelpFile ?

comment:3 by BrewManNH, 12 years ago

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 by jchd18, 12 years ago

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]

_ArrayDisplay($aArray)
_ArrayTranspose($aArray)
ConsoleWrite('@error = ' & @error & @CRLF)
_ArrayDisplay($aArray)

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

comment:5 by BrewManNH, 12 years ago

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 by J-Paul Mesnage, 12 years ago

Milestone: 3.3.11.6
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [10098] in version: 3.3.11.6

comment:7 by J-Paul Mesnage, 12 years ago

some doc precision was needed ...

comment:8 by jchd18, 12 years ago

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.

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.