Modify

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: 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 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

hmm...
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]

_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 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 3.3.11.6
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [10098] in version: 3.3.11.6

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

Action
as closed The owner will remain Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.