-
Content Count
3586 -
Joined
-
Last visited
-
Days Won
176
Everything posted by David Heffernan
-
Your program is 32 or 64 bit? There are fast third party components. You didn't say which ones you were using.
-
The form isn't destroyed until Self is. But once ShowModal has returned the form can never be seen again. That's a leak.
-
This leaks the instance
-
Dalija explained why. So that there's no scope for essential arguments not to be set. To make it clear to the caller what must be provided by them.
-
Easy to fix and 100% this is what you should do
-
Why is it confusing?
-
That sounds more like an argument to the constructor
-
Do you mean for properties?
-
if i changed the P4D DLLPath how to reload DLLs ?
David Heffernan replied to tomye's topic in Python4Delphi
For a Python extension module. But a pure Python module isn't a DLL. -
if i changed the P4D DLLPath how to reload DLLs ?
David Heffernan replied to tomye's topic in Python4Delphi
Thanks, this helps. None of this would be necessary if python modules unloaded their DLLs so I'm guessing that Python itself doesn't provide hooks to modules to let them do that. Or perhaps is it just that modules aren't in the habit of unloading their DLLs. I think it would be easy to do for extension modules. But I'm not sure how a Python module that loaded DLLs with ctypes would get a hook to unload them. Certainly it sounds like what OP is trying to do is not very viable. Especially if the Python code that is executed can be specified at runtime. -
if i changed the P4D DLLPath how to reload DLLs ?
David Heffernan replied to tomye's topic in Python4Delphi
How do you find out which DLLs to unload? -
if i changed the P4D DLLPath how to reload DLLs ?
David Heffernan replied to tomye's topic in Python4Delphi
Has this changed? I remember failing to do this, unload and reload the dll in my own wrapper of embedded Python. But that was very many years ago so things likely have changed. -
if i changed the P4D DLLPath how to reload DLLs ?
David Heffernan replied to tomye's topic in Python4Delphi
I don't think embedded Python supports this scenario -
HELP ,can not run torch scipt but can be run in Python environment
David Heffernan replied to tomye's topic in Python4Delphi
This kind of error is all too familiar when embedding Anaconda. I never have such troubles with vanilla Python. -
Stop trolling, that's my job!
-
An array is a container, but that TArray isn't an array, it's a class containing a lot of static methods.
-
Yes, nested types. Really just a type declared in the lexical scope of the containing type. Delphi syntax for anonymous methods.
-
I don't really see anything that is what I would describe as a container / collection.
-
From my code base I find this: TThreadsafe<T> = class private FLock: TCriticalSection; FValue: T; function GetValue: T; procedure SetValue(const NewValue: T); public constructor Create; destructor Destroy; override; property Value: T read GetValue write SetValue; end; And this: Enum<T: record> = class strict private class function TypeInfo: PTypeInfo; static; class function TypeData: PTypeData; static; public class function IsEnum: Boolean; static; class function Count: Integer; static; class function ToOrdinal(Value: T): Integer; static; class function FromOrdinal(Value: Integer): T; static; class function TryFromOrdinal(Value: Integer; out Enum: T): Boolean; static; class function ToString(Value: T): string; static; class function FromString(const Value: string): T; static; class function MinValue: Integer; static; class function MaxValue: Integer; static; class function InRange(Value: Integer): Boolean; static; class function EnsureRange(Value: Integer): Integer; static; class function FromName(const Name: string): T; static; class function TryFromName(const Name: string; out Enum: T): Boolean; static; class function ToName(Item: T): string; static; class function ToNewSentenceName(Item: T): string; static; class function ToMidSentenceName(Item: T): string; static; class function ToUpperCaseName(Item: T): string; static; class function ToPascalCaseName(Item: T): string; static; end; And this: TArray = class public type TWriteItem<T> = reference to procedure(const TaggedFile: ITaggedFile; const Item: T); TReadItem<T> = reference to procedure(const TaggedFile: ITaggedFile; out Item: T); strict private const SortOrderFactor: array [TSortOrder] of Integer = (1, -1); public class procedure Swap<T>(var Left, Right: T); static; class procedure Reverse<T>(var Values: array of T; Index, Count: Integer); overload; static; class procedure Reverse<T>(var Values: array of T); overload; static; class function Reversed<T>(const Values: array of T): TArray<T>; static; class procedure Shuffle<T>(var Values: array of T; const Random: TFunc<Integer, Integer>; Index, Count: Integer); overload; static; class procedure Shuffle<T>(var Values: array of T; const Random: TFunc<Integer, Integer>); overload; static; class function Contains<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>; Index, Count: Integer; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>; Index, Count: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>; Index, Count: Integer; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>; Index, Count: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; Index, Count: Integer; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; out ItemIndex: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T; Index, Count: Integer): Boolean; overload; static; class function Contains<T>(const Values: array of T; const Item: T): Boolean; overload; static; class function Matches<T>(const Values: array of T; const Predicate: TPredicate<T>; out ItemIndex: Integer): Boolean; overload; static; class function Matches<T>(const Values: array of T; const Predicate: TPredicate<T>): Boolean; overload; static; class function Matches<T>(const Values: array of T; const Predicate: TPredicateOfObj<T>; out ItemIndex: Integer): Boolean; overload; static; class function Matches<T>(const Values: array of T; const Predicate: TPredicateOfObj<T>): Boolean; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>; Index, Count: Integer): Integer; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T; const Comparer: IEqualityComparer<T>): Integer; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>; Index, Count: Integer): Integer; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T; EqualOp: TEqualOp<T>): Integer; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T; Index, Count: Integer): Integer; overload; static; class function IndexOf<T>(const Values: array of T; const Item: T): Integer; overload; static; class function Equal<T>(const lhs, rhs: array of T; const Comparer: IEqualityComparer<T>): Boolean; overload; static; class function Equal<T>(const lhs, rhs: array of T; EqualOp: TEqualOp<T>): Boolean; overload; static; class function Equal<T>(const lhs, rhs: array of T): Boolean; overload; static; class function Ordered<T>(const Values: array of T; const Comparer: IComparer<T>; Index, Count: Integer): Boolean; overload; static; class function Ordered<T>(const Values: array of T; const Comparer: IComparer<T>): Boolean; overload; static; class function Ordered<T>(const Values: array of T; const Comparison: TComparison<T>; Index, Count: Integer): Boolean; overload; static; class function Ordered<T>(const Values: array of T; const Comparison: TComparison<T>): Boolean; overload; static; class function Ordered<T>(const Values: array of T; Index, Count: Integer): Boolean; overload; static; class function Ordered<T>(const Values: array of T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparer: IEqualityComparer<T>; out Value: T; Index, Count: Integer): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparer: IEqualityComparer<T>; out Value: T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; EqualOp: TEqualOp<T>; out Value: T; Index, Count: Integer): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; EqualOp: TEqualOp<T>; out Value: T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; out Value: T; Index, Count: Integer): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; out Value: T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparer: IComparer<T>; out Value: T; Index, Count: Integer): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparer: IComparer<T>; out Value: T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparison: TComparison<T>; out Value: T; Index, Count: Integer): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparison: TComparison<T>; out Value: T): Boolean; overload; static; class function HasDuplicates<T>(const Values: array of T; const Comparison: TComparison<T>): Boolean; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IEqualityComparer<T>; Index, Count: Integer; const Dispose: TProcOfObj<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IEqualityComparer<T>; Index, Count: Integer): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IEqualityComparer<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; EqualOp: TEqualOp<T>; Index, Count: Integer; const Dispose: TProcOfObj<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; EqualOp: TEqualOp<T>; Index, Count: Integer): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; EqualOp: TEqualOp<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IComparer<T>; Index, Count: Integer; const Dispose: TProcOfObj<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IComparer<T>; Index, Count: Integer): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparer: IComparer<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparison: TComparison<T>; Index, Count: Integer): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; const Comparison: TComparison<T>): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T; Index, Count: Integer): Integer; overload; static; class function RemoveDuplicates<T>(var Values: array of T): Integer; overload; static; class function Sorted<T>(const Values: array of T; const Comparer: IComparer<T>; Order: TSortOrder; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparer: IComparer<T>; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparer: IComparer<T>; Order: TSortOrder): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparer: IComparer<T>): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparison: TComparison<T>; Order: TSortOrder; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparison: TComparison<T>; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparison: TComparison<T>; Order: TSortOrder): Boolean; overload; static; class function Sorted<T>(const Values: array of T; const Comparison: TComparison<T>): Boolean; overload; static; class function Sorted<T>(const Values: array of T; Order: TSortOrder; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; Index, Count: Integer): Boolean; overload; static; class function Sorted<T>(const Values: array of T; Order: TSortOrder): Boolean; overload; static; class function Sorted<T>(const Values: array of T): Boolean; overload; static; class procedure Sort<T>(var Values: array of T; const Comparer: IComparer<T>; Order: TSortOrder; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; const Comparer: IComparer<T>; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; const Comparer: IComparer<T>; Order: TSortOrder); overload; static; class procedure Sort<T>(var Values: array of T; const Comparer: IComparer<T>); overload; static; class procedure Sort<T>(var Values: array of T; const Comparison: TComparison<T>; Order: TSortOrder; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; const Comparison: TComparison<T>; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; const Comparison: TComparison<T>; Order: TSortOrder); overload; static; class procedure Sort<T>(var Values: array of T; const Comparison: TComparison<T>); overload; static; class procedure Sort<T>(var Values: array of T; Order: TSortOrder; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; Index, Count: Integer); overload; static; class procedure Sort<T>(var Values: array of T; Order: TSortOrder); overload; static; class procedure Sort<T>(var Values: array of T); overload; static; class function Copy<T>(const Source: array of T; Index, Count: Integer): TArray<T>; overload; static; class function Copy<T>(const Source: array of T): TArray<T>; overload; static; class procedure Move<T>(const Source: array of T; var Dest: array of T; Index, Count: Integer); overload; static; class procedure Move<T>(const Source: array of T; var Dest: array of T); overload; static; class function Concatenated<T>(const Source1, Source2: array of T): TArray<T>; overload; static; class function Concatenated<T>(const Source: array of TArray<T>): TArray<T>; overload; static; class procedure Initialise<T>(var Values: array of T; const Value: T); static; class function New<T>(Count: Integer; const Value: T): TArray<T>; static; class function Zero<T>(Count: Integer): TArray<T>; static; class procedure Zeroise<T>(var Values: array of T); static; class procedure Free<T: class>(const Values: array of T); static; class procedure FreeAndNil<T: class>(var Values: array of T); static; class function GetHashCode<T>(const Values: array of T; const Comparer: IEqualityComparer<T>): Integer; overload; static; class function GetHashCode<T>(const Values: array of T): Integer; overload; static; class function GetHashCode<T>(Values: Pointer; Count: Integer; const Comparer: IEqualityComparer<T>): Integer; overload; static; class function GetHashCode<T>(Values: Pointer; Count: Integer): Integer; overload; static; class procedure Write<T>(const TaggedFile: ITaggedFile; const WriteItem: TWriteItem<T>; const Values: TArray<T>); overload; static; class procedure Write<T>(const TaggedFile: ITaggedFile; const Values: TArray<T>); overload; static; class procedure Read<T>(const TaggedFile: ITaggedFile; const ReadItem: TReadItem<T>; out Values: TArray<T>); overload; static; class procedure Read<T>(const TaggedFile: ITaggedFile; out Values: TArray<T>); overload; static; class procedure Skip(const TaggedFile: ITaggedFile); static; end; And this: NDArray<T> = record public type {$POINTERMATH ON} P = ^T; {$POINTERMATH OFF} private type TEnumerator = record private FOwner: ^NDArray<T>; FCurrentIndices: TArray<Integer>; function GetCurrent: T; public class function New(const Owner: NDArray<T>): TEnumerator; static; property Current: T read GetCurrent; function MoveNext: Boolean; end; private FBase: P; FValues: TArray<T>; FRank: Integer; FShape: TArray<Integer>; FStride: TArray<NativeInt>; function LinearIndex(const Indices: array of Integer): NativeInt; function GetCount: NativeInt; function GetItem(const Indices: array of Integer): T; procedure SetItem(const Indices: array of Integer; const Value: T); function GetSlice(const Indices: array of Integer): NDArray<T>; procedure SetSlice(const Indices: array of Integer; const Value: NDArray<T>); function GetIsEmpty: Boolean; function GetHasZeroDimension: Boolean; public class function New(const Shape: array of Integer): NDArray<T>; overload; static; class function New(const Shape: array of Integer; const Values: TArray<T>): NDArray<T>; overload; static; class function New(const Shape: array of Integer; const Value: T): NDArray<T>; overload; static; class function Zero(const Shape: array of Integer): NDArray<T>; static; class function Diagonal(const Values: array of T): NDArray<T>; overload; static; class function Diagonal(Size: Integer; const Value: T): NDArray<T>; overload; static; class function Empty: NDArray<T>; static; class operator Explicit(const arr: TArray<T>): NDArray<T>; property IsEmpty: Boolean read GetIsEmpty; property HasZeroDimension: Boolean read GetHasZeroDimension; property Rank: Integer read FRank; property Shape: TArray<Integer> read FShape; property Stride: TArray<NativeInt> read FStride; property Count: NativeInt read GetCount; property DataPtr: P read FBase; property Items[const Indices: array of Integer]: T read GetItem write SetItem; default; function ItemPtr(const Indices: array of Integer): P; property Slice[const Indices: array of Integer]: NDArray<T> read GetSlice write SetSlice; procedure CopyTo(Dest: P; Count: NativeInt); function Clone: NDArray<T>; function ToFlattenedArray: TArray<T>; class procedure Write(const TaggedFile: ITaggedFile; const WriteItem: TArray.TWriteItem<T>; const Value: NDArray<T>); overload; static; class procedure Write(const TaggedFile: ITaggedFile; const Value: NDArray<T>); overload; static; class procedure Read(const TaggedFile: ITaggedFile; const ReadItem: TArray.TReadItem<T>; out Value: NDArray<T>); overload; static; class procedure Read(const TaggedFile: ITaggedFile; out Value: NDArray<T>); overload; static; public function GetEnumerator: TEnumerator; end; And this: TIterativeSolver<T> = class public type P = ^T; protected class procedure AGSIterate(A, b, x, work: P; N: Integer; Storage: TMatrixStorage); static; class procedure AGSCalcResidual(A, b, x, r: P; N: Integer; Storage: TMatrixStorage); static; class function AGSIsZero(b: P; N: Integer): Boolean; static; class function AGSSqrMag(x: P; N: Integer): Double; static; class function AGSAccel(r, x: P; work: Pointer; iter, N: Integer): Boolean; static; public class function SolveAGS(const A: NDArray<T>; var b: NDArray<T>; maxiter: Integer; tol: Double; out iter: Integer): Boolean; static; end; And this: type TLUSolver<T> = class public type P = ^T; TWorkspace = record public ipiv: TArray<Integer>; public procedure Update(N: Integer); end; protected //protected to avoid spurious compiler warning class procedure DecomposeDense(A: P; ipiv: PInteger; N: Integer); overload; static; class procedure SubstituteDense(A: P; ipiv: PInteger; N: Integer; b: P; Storage: TMatrixStorage); static; class procedure DecomposeBanded(A: P; ipiv: PInteger; N, Bandwidth, ldab: Integer); overload; static; class procedure SubstituteBanded(A: P; ipiv: PInteger; N, Bandwidth, ldab: Integer; b: P; Storage: TMatrixStorage); static; class procedure DecomposeDense(A: P; N: Integer; var Workspace: TWorkspace); overload; static; class procedure DecomposeBanded(A: P; N, Bandwidth, ldab: Integer; var Workspace: TWorkspace); overload; static; public class procedure Decompose(var A: NDArray<T>; var Workspace: TWorkspace); static; class procedure Substitute(var A, b: NDArray<T>; const Workspace: TWorkspace); static; class procedure Solve(var A, b: NDArray<T>); static; end; And this: TData<T> = record x: T; xPrime: TArray<T>; xPrimePrime: TArray<TArray<T>>; xPrimePrimePrime: TArray<TArray<TArray<T>>>; end; And this: TTableItem<T: TModelObject> = record public ModelObject: T; ObjectIndex: Integer; ItemIndex: Integer; public class function New(ModelObject: T; ObjectIndex, ItemIndex: Integer): TTableItem<T>; static; class function DisplayName(ModelObject: TModelObject; const ItemName: string; ItemIndex: Integer): string; overload; static; function DisplayName(const ItemName: string): string; overload; procedure RedirectDataAccess(var Handler: TDataObject; var Index: Integer); end; I could go on, but it's pretty boring. And these are just some examples from one particular code base. Other code bases will have different use cases. As Stefan said, generics are used for generic programming. So yeah, a myriad.
-
Apart from the myriad of other applications that aren't about containers
-
ExtractFilePath v TDirectory.GetCurrentDirectory
David Heffernan replied to Ian Branch's topic in General Help
This can only be true if you are the only person ever to run your program. These two things, the directory containing the executable and the working directory are completely different and unrelated things. Generally you don't want to use the working directory in a GUI program. It's really only useful in a console app where you can think of the working directory as one of the inputs to the process. What problem are you actually trying to solve? -
Percent Calculations
David Heffernan replied to andyf2022's topic in Algorithms, Data Structures and Class Design
But why? If you are mapping 0..255 to 0.100 why not have the scroll bar range 0..100? -
Percent Calculations
David Heffernan replied to andyf2022's topic in Algorithms, Data Structures and Class Design
Why did you decide to have the scrollbar be ranged between 0 and 255? -
Yes
-
What part of the code or the software on your machine results in this behaviour. Remember that all we know is what you wrote above.