痴情

文章 评论 浏览 30

痴情 2025-01-24 10:44:49
pip install -r requirements.txt  

文件requirements.txt如:

Flask==1.1.2  
Flask-Cors==3.0.8  
Flask-RESTful==0.3.8  
Jinja2==2.11.2 
MarkupSafe==1.1.1  
itsdangerous==1.1.0  
Werkzeug==1.0.1

->我认为Flask版本> 2.0有这个错误!

pip install -r requirements.txt  

file requirements.txt such as:

Flask==1.1.2  
Flask-Cors==3.0.8  
Flask-RESTful==0.3.8  
Jinja2==2.11.2 
MarkupSafe==1.1.1  
itsdangerous==1.1.0  
Werkzeug==1.0.1

-> I think Flask version > 2.0 has this error!

Importerror:无法导入名称' markup'从jinja2'

痴情 2025-01-24 02:36:58

使用以下步骤解决了问题:

  1. 注销注册状态失败的设备
  2. 将键盘和显示器连接到相机,并使用我在初始注册尝试期间创建的密码登录(如果您尚未设置该密码,则使用默认密码)应该是 aws-cam)
  3. 在相机上打开 cmd 并运行以下命令来更新它:

sudo apt-get update
sudo apt-get install awscam

须藤重新启动

  1. 相机重新启动后,我将一根大头针插入相机的重置孔中,
  2. 重新进行了注册过程,成功了

Solved the problem using the below steps:

  1. de-registered the device with failed registration status
  2. attached a keyboard and monitor to the camera and logged in using the password I created during the initial registration attempt (if you haven't set that password then the default should be aws-cam)
  3. opened cmd on the camera and ran the below commands to update it:

sudo apt-get update
sudo apt-get install awscam

sudo reboot

  1. Once the camera was rebooted, I inserted a pin in the reset hole in the camera
  2. did the registration process all over again and it was successful

Deeplens v1 注册失败

痴情 2025-01-23 19:15:19
require('dotenv').config();

const LocalStrategy = require('passport-local').Strategy;

const mysql = require('mysql');
const bcrypt = require('bcrypt');
const db = require('../models/database');

// this method keeps the server connected to db
mysql.createConnection({
   host: "hostname", // localhost or remote hostname
   username: "your_username",
   password: "your_password",
   port: "port_number_used_for_db"
});
require('dotenv').config();

const LocalStrategy = require('passport-local').Strategy;

const mysql = require('mysql');
const bcrypt = require('bcrypt');
const db = require('../models/database');

// this method keeps the server connected to db
mysql.createConnection({
   host: "hostname", // localhost or remote hostname
   username: "your_username",
   password: "your_password",
   port: "port_number_used_for_db"
});

MySQL Node.js PROTOCOL_CONNECTION_LOST 错误

痴情 2025-01-23 16:22:32

这里需要注意的是,模糊背景是图像本身的延伸。因此,如果屏幕的左侧具有紫色色调,则左上角的模糊区域也将是紫色的。

您可以使用像 Blurry 这样的库,它会模糊屏幕内容,然后将其设置为背景。您可以控制所需的模糊量。

一旦获得模糊图像,请将其设置为容器布局的背景并将图片设置在前面,

例如:

val bitmap = Blurry.with(this)
  .radius(10) // make it more if you want the lue to be more
  .sampling(8)
  .capture(findViewById(R.id.right_bottom)).get() // get the view you want to blur
imageView.setImageDrawable(BitmapDrawable(resources, bitmap)) // set the value to the background

The point to note here is the blurred background is an extension of the image itself. So if the left side of the screen has a purple hue the blurred region at the top left will be purple as well.

YOu can use a library like Blurry where it blurs the contents of the screen and then set that as a background. You can control the amount of blur you want.

Once you get the blurred image set it as the background of the container layout and set the picture in front

eg:

val bitmap = Blurry.with(this)
  .radius(10) // make it more if you want the lue to be more
  .sampling(8)
  .capture(findViewById(R.id.right_bottom)).get() // get the view you want to blur
imageView.setImageDrawable(BitmapDrawable(resources, bitmap)) // set the value to the background

在 Android 中使图像视图的垂直边缘变得模糊

痴情 2025-01-23 13:58:44

正如内置异常中提到的,你不能有第二个参数为 0。您要循环的变量 bolenler 以 0 开头。将变量初始化为 bolenler = range(1,sayi-1) 应该可以修复 它。

As mentioned in the built-in exceptions, you can't have the second argument as 0. the variable bolenler that you're looping over begins with 0. Initiating the variable as bolenler = range(1,sayi-1) should fix it.

关于“for 循环”的错误;在蟒蛇上

痴情 2025-01-23 12:44:13

也许他不是您想要的解决方案,而是一种方法。如果您只是将 ul 扩展几个像素并隐藏溢出内容,您将能够滚动并且根本看不到任何滚动条。

正如我所说,也许不是解决方案,但我有时在我的项目中应用过并且效果很好。你总是可以使用一些滚动条插件,但如果你想在平面CSS中使用它,我认为这是更接近的解决方案。希望对您有帮助。

.parent {
  display: flex;
  flex-flow: row warp;
  justify-content: flex-start;
}

.content {
  flex: 1 0 0%;
  background: brown;
}

.sidebar {
  flex: 0 0 20%;
  height: 200px;
  overflow: hidden;
}

.sidebar ul {
  width: calc(100% + 25px);
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0 10px;
  background: red;
  overflow: hidden;
  overflow-y: scroll;
}

.sidebar ul li {
  padding: 5px 10px;
  padding-right: 35px;
}

.sidebar ul li a {
  display: inline-block;
}
<div class='parent'>
  <div class='sidebar'>
    <ul>
      <li>
        <a href="">ELEMENT 1</a>
      </li>
      <li>
        <a href="">ELEMENT 2</a>
      </li>
      <li>
        <a href="">ELEMENT 3</a>
      </li>
      <li>
        <a href="">ELEMENT 4</a>
      </li>
      <li>
        <a href="">ELEMENT 5</a>
      </li>
      <li>
        <a href="">ELEMENT 6</a>
      </li>
      <li>
        <a href="">ELEMENT 7</a>
      </li>
      <li>
        <a href="">ELEMENT 8</a>
      </li>
      <li>
        <a href="">ELEMENT 9</a>
      </li>
    </ul>
  </div>
  <div class='content'>
    hello
  </div>
</div>

我还清理了你的代码,因为你有一些不必要的 DOM 元素,至少对于这个例子来说是这样。

Perhaps is not he solution you want, but is an aproach. If you just extend the ul several pixels and hide the overflow content you will be able to scroll and won't see any scrollbar at all.

As I said, perhaps is not the solution, but I've applied sometimes in my projects and it works fine. You can always use some scrollbar plugin, but if you want it in plane css, I think this is the closer solution. Hope it helps to you.

.parent {
  display: flex;
  flex-flow: row warp;
  justify-content: flex-start;
}

.content {
  flex: 1 0 0%;
  background: brown;
}

.sidebar {
  flex: 0 0 20%;
  height: 200px;
  overflow: hidden;
}

.sidebar ul {
  width: calc(100% + 25px);
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0 10px;
  background: red;
  overflow: hidden;
  overflow-y: scroll;
}

.sidebar ul li {
  padding: 5px 10px;
  padding-right: 35px;
}

.sidebar ul li a {
  display: inline-block;
}
<div class='parent'>
  <div class='sidebar'>
    <ul>
      <li>
        <a href="">ELEMENT 1</a>
      </li>
      <li>
        <a href="">ELEMENT 2</a>
      </li>
      <li>
        <a href="">ELEMENT 3</a>
      </li>
      <li>
        <a href="">ELEMENT 4</a>
      </li>
      <li>
        <a href="">ELEMENT 5</a>
      </li>
      <li>
        <a href="">ELEMENT 6</a>
      </li>
      <li>
        <a href="">ELEMENT 7</a>
      </li>
      <li>
        <a href="">ELEMENT 8</a>
      </li>
      <li>
        <a href="">ELEMENT 9</a>
      </li>
    </ul>
  </div>
  <div class='content'>
    hello
  </div>
</div>

Also I have clean up your code because you have some unnecessary DOM elements, at least for this example.

为什么 Firefox 的滚动条外观不同?

痴情 2025-01-23 11:29:31

我的非常相似,但我宁愿以不同的方式使用 Suspense

<Suspense fallback={null}>
  <Model src={src} containerRef={containerRef.current} />
</Suspense>

另外,我添加了一个错误边界以防止由于渲染而导致任何崩溃

import { withErrorBoundary } from 'react-error-boundary';

// ...

export default withErrorBoundary(ModelViewer, {
  FallbackComponent: () => (<div>An error occured</div>),
  onError: (err: Error, info: {componentStack: string}) => console.error(err, info),
});

mine is quite similar but I rather use Suspense differently

<Suspense fallback={null}>
  <Model src={src} containerRef={containerRef.current} />
</Suspense>

Also I added an error boundary to prevent any crash due to rendering

import { withErrorBoundary } from 'react-error-boundary';

// ...

export default withErrorBoundary(ModelViewer, {
  FallbackComponent: () => (<div>An error occured</div>),
  onError: (err: Error, info: {componentStack: string}) => console.error(err, info),
});

如何正确使用 drei useGLTF

痴情 2025-01-23 05:33:49

发生的情况是,您生成了构建的应用程序,但没有捆绑它(使用 --directory 标志)。

因此,您的文件结构中有额外的 JS 文件。

在您的尝试中,它们与您的 Meteor 项目结构混合在 build 文件夹中(当您使用命令 meteor build build --directory 时)或直接合并(>meteor build .. --directory)。

因此,在下一次构建运行时,Meteor 会选择这些额外的 JS 文件,就好像它们是源代码的一部分(热切加载)一样,但会失败,如警告消息中所示:

输出目录位于源代码树下。
您生成的文件可能会被解释为源代码!
考虑构建到不同的目录中
流星构建../输出

如果您指定了显式同级构建文件夹,而不仅仅是父文件夹(因此将文件直接放在 Meteor 项目根目录中),例如 meteor build ,那么它会在您的下一次尝试中起作用。 ./siblingFolder

另一种可能的解决方法是使用以点 . 开头的构建文件夹名称,以便 Meteor 在下次运行时查找源代码时忽略它,例如 流星建造./.build

请参阅特殊目录文档:

以下目录也不会作为应用代码的一部分加载:

  • 名称以点开头的文件/目录,例如 .meteor.git

What happens is that you produce your built app but not bundle it (using the --directory flag).

Therefore you have extra JS files in your file structure.

And in your attempts, they are mixed with your Meteor project structure, in a build folder (when you use command meteor build build --directory) or directly merged (meteor build .. --directory).

Therefore, on the next build run, Meteor picks these extra JS files as if they were part of your source code (eager loading), and fails, as suggested in the warning message:

The output directory is under your source tree.
Your generated files may get interpreted as source code!
Consider building into a different directory instead
meteor build ../output

It would have worked in your next attempt if you had specified an explicit sibling build folder, instead of just the parent folder (which therefore puts files directly in your Meteor project root), e.g. meteor build ../siblingFolder

Another possible workaround is to use a build folder name starting with a dot ., so that Meteor ignores it on the next runs when it looks for source code, e.g. meteor build ./.build

See special directories docs:

The following directories are also not loaded as part of your app code:

  • Files/directories whose names start with a dot, like .meteor and .git

背靠背运行时 Meteor 构建失败

痴情 2025-01-23 04:41:51

此问题已在谷歌地图最新版本 18 或更高版本中解决

implementation 'com.google.android.gms:play-services-maps:18.1.0'

try {
    MapsInitializer.initialize(getApplicationContext(), MapsInitializer.Renderer.LATEST, this);
} catch (Exception e) {
    Log.e(TAG, "onCreate: " + e.getMessage(), e);
}

This issue was resolved in google maps latest version 18 or above

implementation 'com.google.android.gms:play-services-maps:18.1.0'

try {
    MapsInitializer.initialize(getApplicationContext(), MapsInitializer.Renderer.LATEST, this);
} catch (Exception e) {
    Log.e(TAG, "onCreate: " + e.getMessage(), e);
}

谷歌地图在驾驶安卓时不渲染

痴情 2025-01-23 00:48:45

正如 Felix 评论的那样,最好的方法可能是首先使用正则表达式提取数字,然后将它们解析为浮点数:

var x = ".175\" x 2.5\" x 144\""; // .175" x 2.5" x 144"

let numbers = x.match(/(\d*\.)?\d+/g).map(n => parseFloat(n))

var thickness = numbers[0]
var width = numbers[1]
var length = numbers[2]

console.log('thickness: ' + thickness)
console.log('width: ' + width)
console.log('length: ' + length)

As Felix commented, best way may be to extract your numbers using regex first and then parse them as floats:

var x = ".175\" x 2.5\" x 144\""; // .175" x 2.5" x 144"

let numbers = x.match(/(\d*\.)?\d+/g).map(n => parseFloat(n))

var thickness = numbers[0]
var width = numbers[1]
var length = numbers[2]

console.log('thickness: ' + thickness)
console.log('width: ' + width)
console.log('length: ' + length)

如何使用正则表达式替换字符串中的句点?

痴情 2025-01-22 19:42:59

请注意为什么要混合使用 jQueryjavascript,但请尝试以下方式:

$(function() {
  const focusInputs = $("input.focusbox");

  focusInputs.change(function() {
    var checked = focusInputs.filter(function() {
      return $(this).is(":checked")
    })
    var colors = checked.map(function() {
      return $(this).parent().text()
    }).get()

    if (colors.length == 0) {
      $('#colors tr').show();
    } else {
      $('#colors tr').hide();
      $('#colors tr').filter(function() {
        return $.inArray($(this).find(".entry4").text(), colors) > -1
      }).show();
    }

  });
});

演示

$(function() {
  const focusInputs = $("input.focusbox");

  focusInputs.change(function() {
    var checked = focusInputs.filter(function() {
      return $(this).is(":checked")
    })
    var colors = checked.map(function() {
      return $(this).parent().text()
    }).get()

    if (colors.length == 0) {
      $('#colors tr').show();
    } else {
      $('#colors tr').hide();
      $('#colors tr').filter(function() {
        return $.inArray($(this).find(".entry4").text(), colors) > -1
      }).show();
    }

  });
});
body {
  font-size: 10px;
}

ul,
li {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

table#colors {
  margin-top: 5px;
}

table#colors tbody tr td.entry2 {
  width: 200px;
}

.cf-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #C8C8C8;
  -webkit-transition: border-radius 1s, width 1s, height 1s;
  transition: border-radius 1s, width 1s, height 1s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<ul>
  <li><label class="focusbox-label"><input class="focusbox" type="checkbox" checked />White</label>
  </li>
  <li>
    <label class="focusbox-label"><input class="focusbox" type="checkbox" />Red</label>
  </li>
  <li>
    <label class="focusbox-label"><input class="focusbox" type="checkbox" />Orange</label>
  </li>
</ul>

<table id="colors">
  <tbody>
    <tr class="head-row">
      <th class="table-cell cYellow c1 entry1">Color</th>
      <th class="table-cell cYellow c1 entry2">Name</th>
      <th class="table-cell cYellow c1 entry3">HTML Color Code</th>
      <th class="table-cell cYellow c1 entry4">Shade Group</th>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FFFFFF;"></div>
      </td>
      <td class="table-cell entry2">White</td>
      <td class="table-cell entry3">#FFFFFF</td>
      <td class="table-cell entry4">White</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #F7E7CE;"></div>
      </td>
      <td class="table-cell entry2">Champagne</td>
      <td class="table-cell entry3">#F7E7CE</td>
      <td class="table-cell entry4">White</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #ED2839;"></div>
      </td>
      <td class="table-cell entry2">Red (Pantone)</td>
      <td class="table-cell entry3">#ED2839</td>
      <td class="table-cell entry4">Red</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #ED1B24;"></div>
      </td>
      <td class="table-cell entry2">Red (CMYK) (pigment red)</td>
      <td class="table-cell entry3">#ED1B24</td>
      <td class="table-cell entry4">Red</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FF8200;"></div>
      </td>
      <td class="table-cell entry2">UT orange</td>
      <td class="table-cell entry3">#FF8200</td>
      <td class="table-cell entry4">Orange</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FF8000;"></div>
      </td>
      <td class="table-cell entry2">Orange (wheel)</td>
      <td class="table-cell entry3">#FF8000</td>
      <td class="table-cell entry4">Orange</td>
    </tr>
  </tbody>
</table>

Note sure why the mix between jQuery and javascript, but try this way:

$(function() {
  const focusInputs = $("input.focusbox");

  focusInputs.change(function() {
    var checked = focusInputs.filter(function() {
      return $(this).is(":checked")
    })
    var colors = checked.map(function() {
      return $(this).parent().text()
    }).get()

    if (colors.length == 0) {
      $('#colors tr').show();
    } else {
      $('#colors tr').hide();
      $('#colors tr').filter(function() {
        return $.inArray($(this).find(".entry4").text(), colors) > -1
      }).show();
    }

  });
});

Demo

$(function() {
  const focusInputs = $("input.focusbox");

  focusInputs.change(function() {
    var checked = focusInputs.filter(function() {
      return $(this).is(":checked")
    })
    var colors = checked.map(function() {
      return $(this).parent().text()
    }).get()

    if (colors.length == 0) {
      $('#colors tr').show();
    } else {
      $('#colors tr').hide();
      $('#colors tr').filter(function() {
        return $.inArray($(this).find(".entry4").text(), colors) > -1
      }).show();
    }

  });
});
body {
  font-size: 10px;
}

ul,
li {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

table#colors {
  margin-top: 5px;
}

table#colors tbody tr td.entry2 {
  width: 200px;
}

.cf-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #C8C8C8;
  -webkit-transition: border-radius 1s, width 1s, height 1s;
  transition: border-radius 1s, width 1s, height 1s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<ul>
  <li><label class="focusbox-label"><input class="focusbox" type="checkbox" checked />White</label>
  </li>
  <li>
    <label class="focusbox-label"><input class="focusbox" type="checkbox" />Red</label>
  </li>
  <li>
    <label class="focusbox-label"><input class="focusbox" type="checkbox" />Orange</label>
  </li>
</ul>

<table id="colors">
  <tbody>
    <tr class="head-row">
      <th class="table-cell cYellow c1 entry1">Color</th>
      <th class="table-cell cYellow c1 entry2">Name</th>
      <th class="table-cell cYellow c1 entry3">HTML Color Code</th>
      <th class="table-cell cYellow c1 entry4">Shade Group</th>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FFFFFF;"></div>
      </td>
      <td class="table-cell entry2">White</td>
      <td class="table-cell entry3">#FFFFFF</td>
      <td class="table-cell entry4">White</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #F7E7CE;"></div>
      </td>
      <td class="table-cell entry2">Champagne</td>
      <td class="table-cell entry3">#F7E7CE</td>
      <td class="table-cell entry4">White</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #ED2839;"></div>
      </td>
      <td class="table-cell entry2">Red (Pantone)</td>
      <td class="table-cell entry3">#ED2839</td>
      <td class="table-cell entry4">Red</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #ED1B24;"></div>
      </td>
      <td class="table-cell entry2">Red (CMYK) (pigment red)</td>
      <td class="table-cell entry3">#ED1B24</td>
      <td class="table-cell entry4">Red</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FF8200;"></div>
      </td>
      <td class="table-cell entry2">UT orange</td>
      <td class="table-cell entry3">#FF8200</td>
      <td class="table-cell entry4">Orange</td>
    </tr>
    <tr class="s1">
      <td class="table-cell entry1">
        <div class="color-field cf-default cf-circle" style="background-color: #FF8000;"></div>
      </td>
      <td class="table-cell entry2">Orange (wheel)</td>
      <td class="table-cell entry3">#FF8000</td>
      <td class="table-cell entry4">Orange</td>
    </tr>
  </tbody>
</table>

选中多个复选框以过滤与每个输入标签文本匹配的表行

痴情 2025-01-22 19:23:54

首先,我们需要编辑我们想要从 makeData 函数返回的内容,为此,我们应该编辑 newPerson 并添加 url、firstNameUrl 和 lastNameUrl。这为我们设置了三个新的访问器

const newPerson = () => {
  const statusChance = Math.random();
  return {
    firstName: namor.generate({ words: 1, numbers: 0 }),
    lastName: namor.generate({ words: 1, numbers: 0 }),
    age: Math.floor(Math.random() * 30),
    visits: Math.floor(Math.random() * 100),
    progress: Math.floor(Math.random() * 100),
    url: " www.google.com",
    firstNameUrl: namor.generate({ words: 1, numbers: 0 }),
    lastNameUrl: namor.generate({ words: 1, numbers: 0 }),
    status:
      statusChance > 0.66
        ? "relationship"
        : statusChance > 0.33
        ? "complicated"
        : "single"
  };
};

现在我们有了新的数据键,我们可以简单地告诉react-table通过编辑列useMemo来渲染什么

const columns = React.useMemo(
    () => [
      {
        Header: "Name",
        columns: [
          {
            Header: "First Name",
            accessor: "firstName"
          },
          {
            Header: "Last Name",
            accessor: "lastName"
          }
        ]
      },
      {
        Header: "Info",
        columns: [
          {
            Header: "Age",
            accessor: "age"
          },
          {
            Header: "Visits",
            accessor: "visits"
          },
          {
            Header: "Status",
            accessor: "status"
          },
          {
            Header: "Profile Progress",
            accessor: "progress"
          }
        ]
      },
      {
        Header: "Url",
        columns: [
          {
            Header: "First Name",
            accessor: "firstNameUrl"
          },
          {
            Header: "Last Name",
            accessor: "lastNameUrl"
          },
          {
            Header: "Url",
            accessor: "url"
          }
        ]
      }
    ],
    []
  );

我已经编辑了codepen,你可以找到它这里

@Edit

如果你想渲染一个自定义组件,那么你可以像下面这样做:

      {
        Header: "Last Name",
        accessor: "lastNameUrl",
        Cell: (e) => <a href="https://google.com"> {e.value} </a>
      }

这将渲染为链接元素与accessor 值 - 我还更新了 codepen

First of all we need to edit what we want to return from makeData function, to do that we should edit newPerson and add url, firstNameUrl and lastNameUrl. This sets us three new accessors

const newPerson = () => {
  const statusChance = Math.random();
  return {
    firstName: namor.generate({ words: 1, numbers: 0 }),
    lastName: namor.generate({ words: 1, numbers: 0 }),
    age: Math.floor(Math.random() * 30),
    visits: Math.floor(Math.random() * 100),
    progress: Math.floor(Math.random() * 100),
    url: " www.google.com",
    firstNameUrl: namor.generate({ words: 1, numbers: 0 }),
    lastNameUrl: namor.generate({ words: 1, numbers: 0 }),
    status:
      statusChance > 0.66
        ? "relationship"
        : statusChance > 0.33
        ? "complicated"
        : "single"
  };
};

Now that we have new data keys we can simply tell react-table what to render out by editing column useMemo

const columns = React.useMemo(
    () => [
      {
        Header: "Name",
        columns: [
          {
            Header: "First Name",
            accessor: "firstName"
          },
          {
            Header: "Last Name",
            accessor: "lastName"
          }
        ]
      },
      {
        Header: "Info",
        columns: [
          {
            Header: "Age",
            accessor: "age"
          },
          {
            Header: "Visits",
            accessor: "visits"
          },
          {
            Header: "Status",
            accessor: "status"
          },
          {
            Header: "Profile Progress",
            accessor: "progress"
          }
        ]
      },
      {
        Header: "Url",
        columns: [
          {
            Header: "First Name",
            accessor: "firstNameUrl"
          },
          {
            Header: "Last Name",
            accessor: "lastNameUrl"
          },
          {
            Header: "Url",
            accessor: "url"
          }
        ]
      }
    ],
    []
  );

I have edited the codepen, you can find it here

@Edit

If you want to render a custom component then you can do this like below:

      {
        Header: "Last Name",
        accessor: "lastNameUrl",
        Cell: (e) => <a href="https://google.com"> {e.value} </a>
      }

This will render as link element with accessor value - I've also updated the codepen

在表中显示新列

痴情 2025-01-22 12:03:50

这应该有效:

A = [[0, 0, 0],
 [0, 0, 1],
 [0, 0, 2],
 [0, 0, 3],
 [0, 0, 4],
 [0, 0, 5],
 [0, 1, 0],
 [0, 1, 1],
 [0, 1, 2],
 [0, 1, 3],
 [0, 1, 4],
 [0, 1, 5],
 [0, 1, 6],
 [0, 1, 7],
 [0, 1, 8],
 [0, 1, 9],
 [0, 2, 0],
 [0, 2, 1],
 [0, 2, 2]] 
B = [[1, 1, 2],
 [0, 0, 2],
 [0, 0, 1],
 [4, 2, 2],
 [3, 1, 2],
 [1, 0, 1],
 [1, 1, 2],
 [0, 1, 2],
 [0, 0, 0],
 [2, 2, 3],
 [1, 2, 1],
 [0, 2, 1],
 [0, 2, 0],
 [0, 2, 1],
 [0, 1, 3],
 [0, 0, 0],
 [1, 2, 5],
 [0, 4, 3],
 [0, 1, 3]]
nums = []
for i in A:
    for j in B:
        if i in B:
            nums.append(str(i))
nums_freq = {}
nums = list(dict.fromkeys(nums))
for i in nums:
    count = 0
    for j in B:
        if i == str(j):
            if i in nums_freq.keys():
                nums_freq[i] += 1
            else:
                nums_freq[i] = 1

num_freq 的值:

{'[0, 0, 0]': 2,
 '[0, 0, 1]': 1,
 '[0, 0, 2]': 1,
 '[0, 1, 2]': 1,
 '[0, 1, 3]': 2,
 '[0, 2, 0]': 1,
 '[0, 2, 1]': 2}

This should work:

A = [[0, 0, 0],
 [0, 0, 1],
 [0, 0, 2],
 [0, 0, 3],
 [0, 0, 4],
 [0, 0, 5],
 [0, 1, 0],
 [0, 1, 1],
 [0, 1, 2],
 [0, 1, 3],
 [0, 1, 4],
 [0, 1, 5],
 [0, 1, 6],
 [0, 1, 7],
 [0, 1, 8],
 [0, 1, 9],
 [0, 2, 0],
 [0, 2, 1],
 [0, 2, 2]] 
B = [[1, 1, 2],
 [0, 0, 2],
 [0, 0, 1],
 [4, 2, 2],
 [3, 1, 2],
 [1, 0, 1],
 [1, 1, 2],
 [0, 1, 2],
 [0, 0, 0],
 [2, 2, 3],
 [1, 2, 1],
 [0, 2, 1],
 [0, 2, 0],
 [0, 2, 1],
 [0, 1, 3],
 [0, 0, 0],
 [1, 2, 5],
 [0, 4, 3],
 [0, 1, 3]]
nums = []
for i in A:
    for j in B:
        if i in B:
            nums.append(str(i))
nums_freq = {}
nums = list(dict.fromkeys(nums))
for i in nums:
    count = 0
    for j in B:
        if i == str(j):
            if i in nums_freq.keys():
                nums_freq[i] += 1
            else:
                nums_freq[i] = 1

Value for num_freq:

{'[0, 0, 0]': 2,
 '[0, 0, 1]': 1,
 '[0, 0, 2]': 1,
 '[0, 1, 2]': 1,
 '[0, 1, 3]': 2,
 '[0, 2, 0]': 1,
 '[0, 2, 1]': 2}

如何比较和计算两个列表中出现的次数?

痴情 2025-01-22 10:09:34

你的意思是直接读取文件?

因为您始终可以在读取文件后执行此操作:

ds = ds.sel(band = 1)

它应该返回仅包含 x 和 y 作为坐标的数据集。

You mean directly when reading the file?

Because you can always do this after reading the file:

ds = ds.sel(band = 1)

It should return a dataset with only x and y as coords.

使用 xarray 读取栅格时不使用 band 作为维度

痴情 2025-01-22 07:10:32

我肯定希望能够看到您在第二张图片中显示的内容。您首先必须了解多处理池的工作原理:

List_NumberOfFiles 中有 N 个元素(因此需要提交 N 个任务)基于块的单个任务队列,该队列将根据池的大小 (20) 和 N 进行计算,因为您没有在调用时显式指定 chunksize 参数地图。池中的每个进程在空闲时将从任务队列中池化队列中的下一个任务“块”并执行这些任务直到完成,然后获取下一个块,直到队列中没有更多块为止。如果所有 20 个进程同时执行完它们的最后一个块,那将是一个奇迹。相反,我希望看到一个最终进程继续执行最后一个块。

例如,假设 List_NumberOfFiles 中有 302 个元素 (N = 300)。计算出的 chunksize 值为 4。这将产生 75 个大小为 4 的块,其中一个块大小为 2。即使假设每个任务花费大约相同的时间来处理,在 20 个进程完成其任务后前 3 个块,将留下 15 个全尺寸块和一个小块。这 16 个块将被 16 个进程获取,并且 4 个进程现在将永久空闲。获取小块的进程(即只有 2 个任务的进程)很快就会永久空闲。其余 15 个进程在完成全尺寸块的处理后将永久空闲。最有可能的情况是它们都将在不同的时间结束。

现在假设您已提交 20 个任务(List_NumberOfFiles 作为 20 个元素)。计算出的块大小将为 1,这使得分析变得更加简单。池中的每个进程只有一个任务需要处理,然后才会永久空闲。如果其中一项任务的处理时间恰好比其他任务长得多怎么办?花费的时间越长,您看到除一个进程之外的所有进程空闲的时间就越长。

I would definitely expect to be able to see what you show in the second image. You first must understand how the multiprocessing pool works:

There are N elements (and thus N tasks to be submitted) in List_NumberOfFiles that will be placed on a single task queue in chunks that will be computed based on the size of the pool (20) and N since you did not explicitly specify the chunksize argument on your call to map. Each process in the pool when idle will pool from the task queue the next "chunk" of tasks from the queue and execute those tasks until completion and then get the next chunk until there are no more chunks on the queue left. It would be a miracle if all 20 processes completed executing their final chunk at the same time. Instead, I would expect to see a single final process left executing the last final chunk.

As an example, supposed there were 302 elements in List_NumberOfFiles (N = 300). The computed chunksize value would be 4. That would produce 75 chunks of size 4 with one chunk of size 2. Even assuming each task took approximately the same amount of time to process, after the 20 processes completed their first 3 chunks, that would leave 15 full-sized chunks and one small chunk left. These 16 chunks would be grabbed by 16 of the processes and 4 processes would now be permanently idle. The process that grabbed the small chunk (that is, the one with only 2 tasks) will soon go permanently idle. The remaining 15 processes will go permanently idle as they complete the processing of their full-sized chunks. The most likely scenario is that they will all end at different times.

Now imagine that you have submitted 20 tasks (List_NumberOfFiles as 20 elements). The chunksize computed will be 1, which makes the analysis far simpler. Each process in the pool only has one task to process before it becomes permanently idle. What if one of these tasks just happens to take quite a bit longer to process than the others? The longer it takes then the longer you will see all the processes idle except for one.

仅在单核上运行的 python 多处理池问题

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文