小编Ste*_*han的帖子

Windows 10中的内存泄漏Delphi Seattle中的TNotification?

我正在我的应用程序中实现Windows 10通知.但是,下面的代码(运行正常)显然会给出1个TNotification对象和2个字符串的备忘录泄漏,但我在块的末尾释放了对象:

aNotification := NotificationCenter.CreateNotification;

//-- If not assigned then must be Win 8.1 or below
if not assigned(aNotification) then
  exit;

try
  aNotification.Title := AlignMixVersionName + ' License';
  aNotification.AlertBody := aText;

  NotificationCenter.PresentNotification(aNotification);

finally
  aNotification.Free;
end;
Run Code Online (Sandbox Code Playgroud)

我做了一些愚蠢的事情,或者在通知的实施中是否存在内存泄漏?

  • 史蒂夫

delphi notifications windows-10 delphi-10-seattle

8
推荐指数
1
解决办法
662
查看次数

如何在Python Pandas回归模型中使用滞后时间序列变量?

我正在创建时间序列计量经济学回归模型.数据存储在Pandas数据帧中.

如何使用Python进行滞后的时间序列计量经济分析?我过去使用过Eviews(这是一个独立的计量经济学程序,即不是Python包).要使用Eviews估算OLS方程式,您可以编写如下内容:

equation eq1.ls log(usales) c log(usales(-1)) log(price(-1)) tv_spend radio_spend
Run Code Online (Sandbox Code Playgroud)

请注意滞后的依赖和滞后价格条款.这些滞后变量似乎很难用Python来处理,例如使用scikit或statmodels(除非我错过了什么).

一旦我创建了一个模型,我就想执行测试并使用模型进行预测.

我对做ARIMA,指数平滑或Holt Winters时间序列预测不感兴趣 - 我主要对时间序列OLS感兴趣.

python regression time-series pandas

7
推荐指数
1
解决办法
2万
查看次数

使用Delphi XE7并行库

我有一个耗时的例程,我想使用Delphi XE7的新并行库并行处理.

这是单线程版本:

procedure TTerritoryList.SetUpdating(const Value: boolean);
var
  i, n: Integer;
begin
  if (fUpdating <> Value) or not Value then
  begin
    fUpdating := Value;

    for i := 0 to Count - 1 do
    begin
      Territory[i].Updating := Value; // <<<<<< Time consuming routine
      if assigned(fOnCreateShapesProgress) then
        fOnCreateShapesProgress(Self, 'Reconfiguring ' + Territory[i].Name, i / (Count - 1));
    end;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

实际上并没有什么复杂的事情发生.如果区域列表变量已更改或设置为false,则例程将循环遍历所有销售区域并重新创建区域边界(这是一项耗时的任务).

所以这是我试图让它平行:

procedure TTerritoryList.SetUpdating(const Value: boolean);
var
  i, n: Integer;
begin
  if (fUpdating <> Value) or not Value then
  begin
    fUpdating := …
Run Code Online (Sandbox Code Playgroud)

delphi parallel-processing multithreading tthread

5
推荐指数
1
解决办法
5000
查看次数

如何使用Delphi为Microsoft的Surface触控笔编程?

我想将表面笔功能集成到我的应用程序中.它是用Delphi 10 Seattle编写的.我在网上搜索过,找不到任何东西.

有谁知道如何为笔编程?具体来说,要捕捉压力水平,笔下,笔和笔移动事件.

delphi surface pen pixelsense

5
推荐指数
1
解决办法
413
查看次数

Python负二项回归 - 结果与R匹配

我正在尝试使用Python进行负二项回归.我发现这个例子使用R和一个数据集:

http://www.karlin.mff.cuni.cz/~pesta/NMFM404/NB.html

我尝试使用以下代码在网页上复制结果:

import pandas as pd
import statsmodels.formula.api as smf 
import statsmodels.api as sm

df = pd.read_stata("http://www.karlin.mff.cuni.cz/~pesta/prednasky/NMFM404/Data/nb_data.dta")

model = smf.glm(formula = "daysabs ~ math + prog", data=df, family=sm.families.NegativeBinomial()).fit()

model.summary()
Run Code Online (Sandbox Code Playgroud)

不幸的是,这并没有给出相同的系数.它给出了以下内容:

coef        std err     z       P>|z|   [95.0% Conf. Int.]
Intercept    3.4875     0.236   14.808  0.000    3.026  3.949
math        -0.0067     0.003   -2.600  0.009   -0.012 -0.002
prog        -0.6781     0.101   -6.683  0.000   -0.877 -0.479
Run Code Online (Sandbox Code Playgroud)

这些甚至都不在网站上.假设R代码是正确的,我做错了什么?

python statistics r statsmodels

5
推荐指数
1
解决办法
3106
查看次数

Python-将邮政编码作为字符串加载到DataFrame中?

我正在使用Pandas加载包含邮政编码(例如32771)的Excel电子表格。邮政编码以5位数字的字符串存储在电子表格中。使用命令将它们拉入DataFrame时...

xls = pd.ExcelFile("5-Digit-Zip-Codes.xlsx")
dfz = xls.parse('Zip Codes')
Run Code Online (Sandbox Code Playgroud)

它们被转换成数字。因此,“ 00501”变为501。

所以我的问题是,我该如何:

一种。加载DataFrame并保留存储在Excel文件中的邮政编码的字符串类型?

b。将DataFrame中的数字转换为五位数的字符串,例如“ 501”变成“ 00501”?

python excel zipcode pandas

3
推荐指数
2
解决办法
3005
查看次数

Pandas - 如何在DataFrame系列中用零值替换字符串?

我正在将一些csv数据导入Pandas DataFrame(在Python中).一个系列意味着所有数值.但是,它还包含一些虚假的"$ - "元素,表示为字符串.这些都是以前的格式化遗留下来的.如果我只导入该系列,Pandas会将其报告为一系列"对象".

用零替换这些"$ - "字符串的最佳方法是什么?或者更一般地说,如何用数值替换一系列中的所有字符串(主要是数字),并将系列转换为浮点类型?

  • 史蒂夫

python dataframe pandas

3
推荐指数
2
解决办法
8841
查看次数

Delphi - 绘制一个 Unicode 字符?

我正在尝试在画布上绘制字体图标。我正在使用Ionicons字体。我得到的只是屏幕上的一个矩形。

var
  x1, y1: integer;
  xChr: WideChar;
begin

  x1 := 10;
  y1 := 10;

  fMaleIcon := $f202;
  fFemailIcon := $f25d;

  if xRep.Male then
    xChr := Char(fMaleIcon)
  else
    xChr := Char(fFemaleIcon);

  xCanvas.TextOut(x1, y1, xChr);
end;
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

谢谢 - 史蒂夫

delphi unicode

3
推荐指数
1
解决办法
2337
查看次数

如何从具有受保护数据类型的类继承?

我有一个带有内部受保护类的基本泛型类.如何从基类继承并访问受保护的内部类?

作为示例,此代码将无法编译:

unit uFoo;

interface

type

  TFoo<T> = class
  protected
    type
      TFooProtected = class

      end;
  end;

  TFoo2<T> = class(TFoo<T>)
  protected
    item: TFooProtected;
  end;
Run Code Online (Sandbox Code Playgroud)

delphi inheritance protected

3
推荐指数
1
解决办法
105
查看次数

将自定义编译器传递给Delphi中的通用创建过程

我正在尝试使用Delphi 10 Seattle并尝试创建我的第一个Generic Container类.我需要有关Generic Comparer的帮助

这是我创建的一个简单的Hash对象:

type
  TsmHeap<T> = class
  private
    fList: TList<T>;
    Comparer: TComparer<T>;
    procedure GetChildren(ParentIndex: integer; var Child1, Child2: integer);
    function GetParent(ChildIndex: integer): integer;
    function GetCapacity: integer;
    function GetCount: integer;
    function MustSwap(iParent, iChild: integer): boolean;
    procedure SetCapacity(const Value: integer);
  public
    constructor Create(aComparer: TComparer<T>); overload;
    constructor Create(aComparer: TCOmparer<T>; aCapacity: integer); overload;

    destructor Destroy; override;

    //-- Methods & Functions
    function Dequeue: T;
    procedure Enqueue(Item: T);
    function IsEmpty: boolean;

    //-- Properties
    property Count: integer read GetCount;
    property Capacity: integer read GetCapacity …
Run Code Online (Sandbox Code Playgroud)

delphi generics delphi-10-seattle

2
推荐指数
1
解决办法
401
查看次数

如何访问作为列表的 Pandas 系列的元素

我有一个 Dataframe 系列,其中包含每行的字符串列表。我想创建另一个系列,它是该行列表中的最后一个字符串。

所以一行可能有一个列表,例如

['a', 'b', 'c', 'd']
Run Code Online (Sandbox Code Playgroud)

我想创建另一个由该行的最后一个元素组成的 Pandas 系列,通常作为 -1 引用访问,在这个 'd' 中。每个观察(即行)的列表长度不同。如何才能做到这一点?

python pandas

2
推荐指数
1
解决办法
1968
查看次数