問題タブ [mandelbug]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
540 参照

android - WakeLock-related Mandelbug: does WakeLock.acquire() always succeed?

The Problem

I've been developing for Android for quite some time now. One of the programs I've developed makes heavy use of WakeLocks. It usually perfectly (often for days or weeks at a time, a requirement of the program), but very rarely I notice peculiar behaviour in this code:

Where hasWakeLock() simply returns the result of (wakeLock != null && wakeLock.isHeld()) and wakeLockManager.newPartialWakeLock(DEBUG_TAG) encapsulates the standard "get the PowerManager and then return a wake lock" code. For the purposes of testing, the assert statements are JUnit assert methods so I think we can assume that they are correct.

The problem with the code is this: the final assertion - assertTrue(hasWakeLock()) - seems to fail every few weeks with very little explanation. It means that I have three possible issues here: (1) the wake lock is never retrieved at all from the PowerManager (2) that I have a concurrency issue that on rare occasions takes effect just before the postcondition but after the call to acquire(), or that (3) acquire() is sometimes faulty.

Investigation of the Problem

As stated above, I have three potential issues that may be occurring that I am investigating / have investigated:

Hypothesis 1: Wake Lock not returned:

Were this the case then I would see a null pointer exception. It can't be that.

Hypothesis 2: I have a concurrency issue:

A just-conducted formal verification proof of all places involved in acquiring and releasing wakeLock strongly leads me to believe that this is not the case. In the case that my proof is faulty then I may have a concurrency issue, but it is then truly insidious and difficult to find.

Hypothesis 3: WakeLock.acquire() is faulty, and despite what the documentation says it sometimes can fail to acquire the lock:

I dislike this hypothesis because with all of the Android users our there someone aside from myself must have noticed this by now and it is almost always the developer's code, not the library or OS code, that is faulty. Then again, stranger things have happened and this might be a genuine Android bug, albeit a rarely exhibited one. If this hypothesis is true then acquire() is simply not acquiring the wake lock and this would explain the behaviour I'm seeing.

So StackOverflow, what could be causing this problem? What do you think is wrong? Am I missing something obvious, or could this be a genuine problem with Android's wake locks?

0 投票する
1 に答える
307 参照

python - NumPy と Pillow を使用してマンデルブローをプロットすると、プログラムが見かけのノイズを出力する

以前、turtle を使用して Python でマンデルブロー生成器を作成しました。現在、速度を上げて画像サイズの制限を減らすために、Python Imaging Library を使用するようにプログラムを書き直しています。

ただし、以下のプログラムはRGBナンセンスのみを出力し、ほとんどノイズです。NumPy と PIL が配列を処理する方法の違いと関係があると思います。なぜなら、とが実行されたときにl[x,y] = [1,1,1]whereが1 ピクセルを白くするだけでl = np.zeros((height,width,3)) はないからです。img = Image.fromarray(l)img.show()

更新 1:

このプログラムの主なエラーの 1 つ (間違いなくたくさんあると思います) は、複素係数として x,y 座標を使用していたことに気付きました! つまり、-1.25 から 1.25 ではなく、0 から 100 です! これを変更して、コードが変数 a,b を使用してそれらを記述し、タートル バージョンのコードの一部から盗んだ方法でインクリメントします。上記のコードはそれに応じて更新されています。Smooth Coloring Algorithm コードは現在、デバッグ用にコメントアウトされているため、inf変数2のサイズが縮小されています。

更新 2:

優れたユーザーの助けを借りて、numpy インデックスを編集しました。200 x 200 に設定すると、プログラムはこれを出力します。

失敗したマンデルブロ

ご覧のとおり、間違いなく数学的な形状を示していますが、これらすべての奇妙な赤、緑、青のピクセルで満たされています! なぜこれらがここにあるのでしょうか?[1,1,1]私のプログラムでは、RGB 値をdefault に設定するか、そのままにしておくことしかできません[0,0,0]。そんなはずない[1,0,0]- これは重大な欠陥に違いない.

更新 3:

NumPy と PIL の統合にエラーがあると思います。makel = np.zeros((100, 100, 3))を記述l[0,0,:] = 1して最後にimg = Image.fromarray(l)&を指定すると、次のimg.show()ようになります。

1 つの白いピクセルだけではありません。

ここでは、一連の色付きのピクセルを取得します。これには別の質問が必要です。

更新 4:

以前に何が起こっていたのかわかりませんが、np.uint8配列のようで、0 ~ Image.fromarray()255 の色の値を使用しています。この知恵のおかげで、私はこのマンデルバグの理解に一歩近づきました!

今、私漠然と数学的なものを手に入れましたが、それでも奇妙なものを出力します。

白い背景の黒い円。

このドットだけがすべてです... に変更するとnp.uint16、さらに奇妙なことがわかります。これは、バイト形状とエンコード方式が異なるためだと思います。

0 投票する
1 に答える
193 参照

python - NumPy の配列システムは PIL の Image.fromarray() とは異なりますか?

これはより大きなマンデルバグに関連していますが、これはその主要な部分です。

私がこれを行う場合:

私はこれを得る:

間違ったピクセル。

これは明らかに、私が画像に対して実行した操作ではありません。左上を見ると、緑、青、赤などで作られたピクセルの束が表示されますが、1 ピクセル (左上) が白/灰色になると予想されます。

何が起こっている?