小编Max*_*ier的帖子

npx babel 不从 babel.config.js 读取配置

npx babel index.js从命令行运行时,我希望能看到从 babel.config.js 应用我的 babel 配置

但事实似乎并非如此,因为我想知道为什么会这样?

// babel.config.js
module.exports = function babel(api) {
 api.cache(true);
   return {
     presets: ['module:metro-react-native-babel-preset'],
     plugins: [
       [
         'babel-plugin-root-import',
         {
           rootPathSuffix: './src',
           rootPathPrefix: '~/',
         },
       ],
     ],
   };
 };

// index.js
import { AppRegistry } from 'react-native';
import App from '~/App';
AppRegistry.registerComponent("App Name", () => App)

// Expected output from npx babel index.js
import { AppRegistry } from 'react-native';
import App from './src/App'; // Note the change from '~' to './src' using babel-plugin-root-import
AppRegistry.registerComponent("App …
Run Code Online (Sandbox Code Playgroud)

javascript babeljs react-native babel-cli npx

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

根据条件将 numpy 数组值设置为 NaN

我正在使用一个数据集,其中不存在的值显示为负数。我想将这些值转换为 np.nan 值,但我不知道如何转换。这样做的条件是(array < 0)

数组会发生什么的一个例子是:

import numpy as np

array = np.array([[-1,  1, -1,  1],
                  [ 1, -1, -1,  1],
                  [ 1, -1, -1, -1]])
Run Code Online (Sandbox Code Playgroud)

然后转换为:

np.array([[np.nan,      1, np.nan,      1],
          [     1, np.nan, np.nan,      1],
          [     1, np.nan, np.nan, np.nan]])
Run Code Online (Sandbox Code Playgroud)

干杯

python arrays numpy python-3.x

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