小编Isa*_*and的帖子

SciPy创建2D多边形蒙版

我需要使用标准的Python包创建一个numpy 2D数组,它表示多边形的二进制掩码.

  • 输入:多边形顶点,图像尺寸
  • 输出:多边形的二进制掩码(numpy 2D数组)

(更大的上下文:我想使用scipy.ndimage.morphology.distance_transform_edt获取此多边形的距离变换.)

谁能告诉我怎么做?

python polygon scipy sage point-in-polygon

37
推荐指数
4
解决办法
3万
查看次数

将稀疏的json对象解码为php数组

我可以使用以下命令创建稀疏的php数组(或map):

$myarray = array(10=>'hi','test20'=>'howdy');
Run Code Online (Sandbox Code Playgroud)

我想将其序列化/反序列化为JSON.我可以使用以下命令序列化它:

$json = json_encode($myarray);
Run Code Online (Sandbox Code Playgroud)

这导致了字符串{"10":"hi","test20":"howdy"}.但是,当我反序列化它并使用以下命令将其强制转换为数组时:

$mynewarray = (array)json_decode($json);
Run Code Online (Sandbox Code Playgroud)

我似乎失去了任何与无效的php标识符密钥的映射.也就是说,mynewarray具有映射'test20'=>'howdy',但不能10=>'hi'也不'10'=>'hi'.

有没有办法在使用标准json_encode/ json_decode函数转换为json和从json返回时保留php地图中的数字键?

(我使用的是PHP版本5.2.10-2ubuntu6.4.)

php json map sparse-array

22
推荐指数
1
解决办法
4万
查看次数

覆盖log4j.properties

我的java应用程序引用了一个使用log4j日志记录的第三方jar文件.问题是这个jar包含自己的log4j.properties文件,该文件导致我的机器上的访问被拒绝异常,但我无法控制jar文件来更改其内容.

我已经尝试在我的应用程序的类路径中添加我自己的log4j.properties文件,但它似乎没有效果.如果我尝试使用PropertyConfigurator以编程方式导入我自己的设置,log4j似乎首先加载jar文件的属性文件(导致异常).

如何将log4j短路以忽略第三方jar文件的log4j.properties文件并使用我自己的文件?

java log4j jar properties propertyconfigurator

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

Ogg Vorbis标题规格

我正在寻找ogg vorbis标头包格式的规范.我在互联网上搜索得不太成功.我在哪里可以找到一个?

oggvorbis

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

subversion:没有工作副本的合并

我想从命令行svn恢复一个错误的提交.通常的建议是将提交反向合并到工作副本中,然后提交更改.在我的情况下,错误的提交是一个错误的类型svn import,它破坏了我的存储库的一部分,我没有在其他任何地方检查.我可以查看受影响的目录,然后按照通常的建议,但如果我可以完全使用URL反向合并,而没有工作副本,那将更加优雅.这可能吗?

svn merge

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

在Python中将wav转换为ogg vorbis

如何使用Python将wav文件转码为ogg vorbis格式?

我可以使用PyMedia 1.3.7.3转换为mp3,但是当我将输出流类型设置为'ogg'时,我收到错误:oggvorbis_encode_init: init_encoder failed脚本死了.

python mp3 oggvorbis transcoding ogg

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

iOS4.1 SDK中单个库中的重复符号

我正在开发一个iPhone应用程序.我对Xcode不熟悉,所以请耐心等待.我有iOS 4.1 Device SDK.当我在"Active ..."下拉框中选择"Simulator"时,我的应用程序编译没有错误并在iPhone模拟器中运行.

但是,当我在下拉框中选择"设备"时,我收到有关重复符号的以下链接器错误:

Ld build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone normal armv6
cd /Users/isaacsutherland/fydp/PineCone/PineCone
setenv IPHONEOS_DEPLOYMENT_TARGET 4.1
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -L/Users/isaacsutherland/fydp/PineCone/PineCone/../3rd/libGHUnitIPhone -F/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -filelist /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone.LinkFileList -dead_strip -all_load -ObjC -miphoneos-version-min=4.1 -framework Foundation -framework UIKit -framework CoreGraphics /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Core.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Network.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Style.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UI.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework QuartzCore -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -lz.1.2.3 /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a -lGHUnitIPhone4_0 -o /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone

ld: duplicate symbol _RedirectionLimit in /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o) and /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o)
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

错误是奇怪的,因为它抱怨_RedirectionLimit被发现两次 …

xcode xcodebuild ios4 ios

0
推荐指数
1
解决办法
4772
查看次数

python:事后更改属性getter

是否可以在创建python属性后更改其getter?

class A:
    _lookup_str = 'hi'
    @property
    def thing():
        value = some_dictionary[_lookup_str]
        # overwrite self.thing so that it is just value, not a special getter
        return value
Run Code Online (Sandbox Code Playgroud)

我的想法是,一旦我查了一次,我就不必再查一遍了(字典永远不会改变).我可以:

class A:
     _lookup_str = 'hi'
     _thing = None
     @property
     def thing():
         if not value:
             value = some_dictionary[_lookup_str]
         return value
Run Code Online (Sandbox Code Playgroud)

但即使在那里,我正在测试一个条件 - 这比我完全删除吸气剂并用一个值替换它更有效.

python performance properties

0
推荐指数
1
解决办法
1599
查看次数