小编dcx*_*xst的帖子

在带有 m1 芯片的 Mac 上导入 jax 失败

对于 python 3.8.8 并在 jupyter 笔记本和 python 终端中使用新的 mac air(带有 m1 芯片),import jax会引发此错误

Python 3.8.8 (default, Apr 13 2021, 12:59:45)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/steve/Documents/code/jax/jax/__init__.py", line 37, in <module>
    from . import config as _config_module
  File "/Users/steve/Documents/code/jax/jax/config.py", line 18, in <module>
    from jax._src.config import config
  File "/Users/steve/Documents/code/jax/jax/_src/config.py", line 26, in …
Run Code Online (Sandbox Code Playgroud)

python python-3.8 jax apple-m1

8
推荐指数
3
解决办法
9800
查看次数

for 循环中奇怪的匹配行为

Rust菜鸟在这里。我很困惑为什么当我在一个范围内迭代的变量与该范围的最大值匹配时会出现这种奇怪的行为。它不是只匹配最后一项,而是匹配所有内容!有人可以解释一下我从这段代码中得到的输出和编译器警告吗:

fn main() {
  let maxi = 2;
  for i in 0..=maxi {
    match i {
      maxi => {
        println!("i={} matched maxi={}",i,maxi);
      }
      _ => {
        println!("i={} matched with _",i);
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

编译器输出如下

warning: unreachable pattern
 --> se_match_loop.rs:7:15
  |
5 |             maxi => {
  |             ---- matches any value
6 |                 println!("i={} matched maxi={}",i,maxi);
7 |             } _ => {
  |               ^ unreachable pattern
  |
  = note: `#[warn(unreachable_patterns)]` on by default

warning: 1 warning emitted
Run Code Online (Sandbox Code Playgroud)

当我执行编译的脚本时,这是输出

i=0 matched …
Run Code Online (Sandbox Code Playgroud)

rust

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

标签 统计

apple-m1 ×1

jax ×1

python ×1

python-3.8 ×1

rust ×1