我不在是我

文章 评论 浏览 28

我不在是我 2025-02-20 15:48:46

您只需要cbind()base。使用do.call()因为d是列表。

d2 <- do.call(cbind, setNames(d, paste0('t', 1:length(d))))
输出
                 t1         t2         t3          t4         t5
Feb 2019         NA   3.598138         NA          NA         NA
Mar 2019         NA   4.007715         NA          NA  -2.416898
Apr 2019         NA   1.106827         NA          NA  -4.682005
May 2019         NA  -5.558411  -8.185157          NA  -7.729782
Jun 2019         NA  17.869131   6.849361          NA  21.499193
Jul 2019         NA   4.978505  -3.200564          NA -13.343536
Aug 2019         NA -19.666172 -13.115224          NA   4.958705
Sep 2019         NA   7.013559  -5.996083          NA  12.339762
Oct 2019   8.005543  -4.727914  -1.294107          NA   6.343621
Nov 2019  11.902066 -10.678237   8.867361 -12.6539635   4.120223
Dec 2019 -16.895557  -2.179749  -1.513960  21.6895597   7.935853
Jan 2020  12.394959 -10.260044   3.297912  12.0796200  -1.524106
Feb 2020  -1.089660  -7.288912 -32.273228 -11.2310858  -2.288958
Mar 2020  -1.172420  -6.250393  -7.717918  -4.0288484  -9.007918
Apr 2020   1.830826 -16.866933   2.865486  -4.6665535         NA
May 2020  12.805549         NA -12.205120   7.7996512         NA
Jun 2020 -17.272706         NA         NA  -0.8336907         NA
Jul 2020         NA         NA         NA   2.5331851         NA
Aug 2020         NA         NA         NA  -0.2854676         NA
Sep 2020         NA         NA         NA  -0.4287046         NA
Oct 2020         NA         NA         NA  13.6860228         NA
Nov 2020         NA         NA         NA  -2.2577099         NA
Dec 2020         NA         NA         NA  15.1647060         NA
Jan 2021         NA         NA         NA -15.4875280         NA
Feb 2021         NA         NA         NA   5.8461375         NA

输出仍然是ts对象。

class(d2)
# [1] "mts"    "ts"     "matrix"

You just need cbind() from base. Use do.call() because d is a list.

d2 <- do.call(cbind, setNames(d, paste0('t', 1:length(d))))
Output
                 t1         t2         t3          t4         t5
Feb 2019         NA   3.598138         NA          NA         NA
Mar 2019         NA   4.007715         NA          NA  -2.416898
Apr 2019         NA   1.106827         NA          NA  -4.682005
May 2019         NA  -5.558411  -8.185157          NA  -7.729782
Jun 2019         NA  17.869131   6.849361          NA  21.499193
Jul 2019         NA   4.978505  -3.200564          NA -13.343536
Aug 2019         NA -19.666172 -13.115224          NA   4.958705
Sep 2019         NA   7.013559  -5.996083          NA  12.339762
Oct 2019   8.005543  -4.727914  -1.294107          NA   6.343621
Nov 2019  11.902066 -10.678237   8.867361 -12.6539635   4.120223
Dec 2019 -16.895557  -2.179749  -1.513960  21.6895597   7.935853
Jan 2020  12.394959 -10.260044   3.297912  12.0796200  -1.524106
Feb 2020  -1.089660  -7.288912 -32.273228 -11.2310858  -2.288958
Mar 2020  -1.172420  -6.250393  -7.717918  -4.0288484  -9.007918
Apr 2020   1.830826 -16.866933   2.865486  -4.6665535         NA
May 2020  12.805549         NA -12.205120   7.7996512         NA
Jun 2020 -17.272706         NA         NA  -0.8336907         NA
Jul 2020         NA         NA         NA   2.5331851         NA
Aug 2020         NA         NA         NA  -0.2854676         NA
Sep 2020         NA         NA         NA  -0.4287046         NA
Oct 2020         NA         NA         NA  13.6860228         NA
Nov 2020         NA         NA         NA  -2.2577099         NA
Dec 2020         NA         NA         NA  15.1647060         NA
Jan 2021         NA         NA         NA -15.4875280         NA
Feb 2021         NA         NA         NA   5.8461375         NA

The output is still a ts object.

class(d2)
# [1] "mts"    "ts"     "matrix"

绑定时间序列数据与列表不同长度

我不在是我 2025-02-20 14:00:44

B部分中不应集成,您可以使用A部分中的结果来计算每个点的能量。

    x,y,vx,vy = z_vec.T
    r = np.hypot(x,y)
    E_kin = 0.5*m*(vx**2+vy**2)
    E_pot = -G*M*m/r
    E = E_kin+E_pot
    plt.plot(t,E)

There should be no integration in part b), you use the result from part a) to compute the energies at each point.

    x,y,vx,vy = z_vec.T
    r = np.hypot(x,y)
    E_kin = 0.5*m*(vx**2+vy**2)
    E_pot = -G*M*m/r
    E = E_kin+E_pot
    plt.plot(t,E)

地球的轨道 - 数值方法跨越

我不在是我 2025-02-20 07:46:48

该页面上没有真正的内容。尝试“查看页面源”以查看我的意思。该页面只是一个用于布局的模板 /包装器,然后将 javascript生成的< / em>发布到Web服务中,以获取想要显示的数据,然后将其接收,格式和显示。

There is no real content on that page. Try 'View page source' to see what I mean. That page is just a template / wrapper for layout, which then makes a javascript-generated POST to a web service to get the data that it wants to display, which it then receives, formats and displays.

python从网页中提取全部数据以获取上述日期

我不在是我 2025-02-20 01:07:10

不幸的是,目前尚无API支持,用于创建一个模板,该模板登录为HQ-5023,并且创建以愿望清单项目Acsadmin-2707记录的ACC项目。请继续关注我们。

Unfortunately, there is currently no API support for creating a project with a template that is logged as HQ-5023, and creating ACC projects logged as the wishlist item, ACSADMIN-2707. Please stay tuned with us.

伪造:创建项目模板

我不在是我 2025-02-20 00:54:22

常数1.js

module.exports = Object.freeze({
    DOUBLE: 1,
    FLOAT: 2
});

constant2.js

module.exports = Object.freeze({
    TRIPLE: 3,
});

mymodules.js

const getUser = ()=> console.log("Something");
const getId = ()=>console.log("Something2");

const type1 = require("./constants1.cjs");
const type2 = require("./constants2.cjs");

const udb = Object.assign(Object.create(null), type1, type2);
udb.getUser = getUser;
udb.getId = getId;
module.exports = Object.freeze( udb );

consumer.js

const udb = require("./mymodule.cjs");
console.log(udb.DOUBLE);

// udb.getUser();                    
// udb.getId();                    

edit:添加完整的示例

编辑2:更简单

constant1.js

module.exports = Object.freeze({
    DOUBLE: 1,
    FLOAT: 2
});

constant2.js

module.exports = Object.freeze({
    TRIPLE: 3,
});

mymodules.js

const getUser = ()=> console.log("Something");
const getId = ()=>console.log("Something2");

const type1 = require("./constants1.cjs");
const type2 = require("./constants2.cjs");

const udb = Object.assign(Object.create(null), type1, type2);
udb.getUser = getUser;
udb.getId = getId;
module.exports = Object.freeze( udb );

consumer.js

const udb = require("./mymodule.cjs");
console.log(udb.DOUBLE);

// udb.getUser();                    
// udb.getId();                    

EDIT: Added a complete example

EDIT 2: Simpler

我们如何从JavaScript模块导出常数列表和函数

我不在是我 2025-02-19 21:04:32

错误没有运行的Web进程非常清楚;您是否没有 web> web> web process < /a>在您的procfile 意味着没有服务器可以响应传入的请求,或者您的Web> Web进程缩放到0

您需要创建或更新procfile才能包含启动Discord Bot服务器的Web进程。

web: <command to start server> -p $PORT

如果已经配置出来,则需要ps:scale使用 Heroku Cli

heroku ps:scale web=1

The error No web processes running is pretty clear; you either do not have a web process defined in your Procfile meaning there is no server that can respond to incoming requests, OR you have your web processes scaled to 0.

You will need to create or update your Procfile to contain a web process that starts your Discord bot server.

web: <command to start server> -p $PORT

If that is already configured, you will need to ps:scale your process using the Heroku CLI.

heroku ps:scale web=1

可以在Heroku上上传并运行(Discord Bot)

我不在是我 2025-02-19 19:31:23

这是由于用[[0.0]*cols]*行初始化2D列表的结果。它创建一个1D列表[0.0] * cols,然后制作rows副本。您可以看到此问题进行更多讨论。

解决方案很简单,您可以更改初始化2D列表的方式:

T = [[0.0] * size for i in range(size)]

This happened as a result of initializing 2D list with [[0.0]*cols]*rows. It creates a 1D list [0.0] * cols, and makes rows copies. You can see this problem for more discussion.

The solution is simple, you can change the way to initialize your 2D list:

T = [[0.0] * size for i in range(size)]

Python:返回的2D数组似乎返回最后一行多次重复

我不在是我 2025-02-19 14:40:23

我使用@Harre解决方案,并以更一般的功能也实现了负面的解决方案。

有关以后的问题,请提供一个较小的数据集,您的不需要1000行数据框架。

a <- seq(-14, 14, by = 4)

text_number <- function(x){
  
  neg <- x < 0
  x <- abs(x)

  res <- ifelse(x < 10, paste0("0", x), x)
  res <- ifelse(neg, paste0("-", res), res)

  return(res)
}

text_number(a)

I used @harre solution and implemented it in a more general function that take negative too.

For future questions please provide a smaller dataset, your's don't need 1000 lines dataframe.

a <- seq(-14, 14, by = 4)

text_number <- function(x){
  
  neg <- x < 0
  x <- abs(x)

  res <- ifelse(x < 10, paste0("0", x), x)
  res <- ifelse(neg, paste0("-", res), res)

  return(res)
}

text_number(a)

r中有条件的糊剂

我不在是我 2025-02-19 03:07:56

作为最佳实践,最好不要将日期保存在数据库中,而无需时区域将日期保存在UTC中,并使用必要的逻辑直接从应用程序中应用。
这使您可以管理时区,并始终知道哪个是标准。

As best practices it would be better to have the dates saved in the database as utc without time zone and apply it directly from the application, with the necessary logic.
This allows you to manage the time zone and always know which is the standard.

总是插入UTC DateTime

我不在是我 2025-02-18 20:32:18

是的,可以将ClearScantype(FD1428390-Identity-H)更改为常规字体,此处更改为11pter times Roman Italic。还弄乱了颜色,尺寸和大胆以表现出效果,但是您只需要使用一种组合即可。

在Tracker PDF-Xchange编辑器的免费版本中允许此更改,但是如果没有谨慎地进行文本编辑,请当心可以触发演示水印。

仅从按钮中选择编辑文本,然后选择文本,并在属性窗格(右图)中选择文本,并进行更改,如果您看到演示横幅显示出现,则CTRL-Z,然后尝试其他方法。

Yes it is possible to change the ClearScanType (Fd1428390-Identity-H) to conventional font here changed to 11pt Times Roman Italic. Also messed with colour, size and bold to demonstrate effects, but you just need to use one combination.

enter image description here

This change is allowed in the Free version of Tracker PDF-XChange Editor but beware if not done cautiously text edits could trigger demo watermarks.

Select the edit text only from buttons then select text, with properties pane active (on the right) and make changes, if you see the demo banner appear then Ctrl-Z and try a different approach.

如何在PDF中更改字体,单个字形会使错误(使用Adobe Acrobat Pro XI创建的PDF,并带有文本识别;

我不在是我 2025-02-18 19:09:38

我不确定为什么obj类型[keyOf obj typeof obj]模式实际上无法与工会合作。不过,使用映射类型可以解决问题。

type ObjValue = {
  [K in keyof typeof obj]: typeof obj[K][keyof (typeof obj[K])]  
}[keyof typeof obj]

// type ObjValue = "A" | "C" | "B"

I am not sure why the typeof obj[keyof typeof obj] pattern does not really work with unions. Using mapped types solves the problem though.

type ObjValue = {
  [K in keyof typeof obj]: typeof obj[K][keyof (typeof obj[K])]  
}[keyof typeof obj]

// type ObjValue = "A" | "C" | "B"

Playground

如何在不使用“字符串”索引的情况下将对象值转换为tumpecript联合?

我不在是我 2025-02-18 05:54:12

这是参数化灯具的预期行为。可以将固定装置直接进行参数化(通过夹具装饰器中的params参数)或通过测试间接参数(如问题所示)。两种情况在语义上都是等效的,意味着将以不同的参数调用固定装置并产生不同的结果。因此,必须分别评估每个参数的固定装置 - 您可以将其视为每个参数而不是单个夹具的单独固定装置。

如果固定设备(示例中的some_fixture)是从参数化的固定装置“派生”的,则也将被参数化,因为每个参数都会为每个参数计算一个单独的结果,也将是相同的。为了说明这一点,您可以将参数添加到输出中的固定装置中。这是一个稍有变化的示例来证明这一点:

ITERATIONS = 2

@pytest.fixture(scope='class')
def some_fixture(request, iteration):
    print(f'-some_fixture-{request.scope}-{iteration}-start')
    yield
    print(f'-some_fixture-{request.scope}-{iteration}-end')

@pytest.fixture(scope='class')
def iteration(request):
    print(f'-iteration-{request.scope}-{request.param}-start')
    yield request.param
    print(f'-iteration-{request.scope}-{request.param}-end')

@pytest.mark.parametrize('iteration', range(1, ITERATIONS + 1),
                         indirect=True)
class TestSomething:
    def test_something(self, some_fixture):
        print("test_something")

    def test_something_else(self, some_fixture):
        print("test_something_else")

我删除了异步部分,因为它与问题无关,因此将参数添加到固定装置输出中,并在类中添加了第二个测试(还对测试名称进行了调整以识别。由pytest)。

输出的是:

-iteration-class-1-start
-some_fixture-class-1-start
PASSED test_something
PASSED test_something_else
-some_fixture-class-1-end
-iteration-class-1-end
-iteration-class-2-start
-some_fixture-class-2-start
PASSED test_something
PASSED test_something_else
-some_fixture-class-2-end
-iteration-class-2-end

请注意,即使多次使用(在两次测试中,在这种情况下两次),每个参数仅适用于每个参数一次。如您所见,它的确表现得像类固定装置,如果具有不同参数的固定装置被视为不同的固定装置(如应该)。

This is the expected behavior for parametrized fixtures. A fixture can be directly parametrized (via the params argument in the fixture decorator) or indirectly parametrized by a test (as shown in the question). Both cases are semantically equivalent, and mean that a fixture will be called with different parameters and yield different outcomes. Therefore the fixture has to be evaluated for each parameter separately - you can think of this as a separate fixture for each parameter instead of a single fixture.

The same is true if a fixture (as some_fixture in your example) is "derived" from a parametrized fixture - it will also be parametrized, as a separate outcome is calculated for each parameter. To illustrate this, you can add the parameter to the fixture in the output. Here is a slightly changed example to demonstrate this:

ITERATIONS = 2

@pytest.fixture(scope='class')
def some_fixture(request, iteration):
    print(f'-some_fixture-{request.scope}-{iteration}-start')
    yield
    print(f'-some_fixture-{request.scope}-{iteration}-end')

@pytest.fixture(scope='class')
def iteration(request):
    print(f'-iteration-{request.scope}-{request.param}-start')
    yield request.param
    print(f'-iteration-{request.scope}-{request.param}-end')

@pytest.mark.parametrize('iteration', range(1, ITERATIONS + 1),
                         indirect=True)
class TestSomething:
    def test_something(self, some_fixture):
        print("test_something")

    def test_something_else(self, some_fixture):
        print("test_something_else")

I have removed the async part, as it is not relevant for the question, added the parameter to the fixture output and added a second test in the class (also adapted the test names to be recognized by pytest).

The output for this is:

-iteration-class-1-start
-some_fixture-class-1-start
PASSED test_something
PASSED test_something_else
-some_fixture-class-1-end
-iteration-class-1-end
-iteration-class-2-start
-some_fixture-class-2-start
PASSED test_something
PASSED test_something_else
-some_fixture-class-2-end
-iteration-class-2-end

Note that the fixture is called only once for each parameter, even if it is used multiple times (in this case twice in the 2 tests). As you can see, it indeed behaves like a class fixture, if fixtures with different parameters are seen as different fixtures (as they should).

当调用pytest中的班级参数化固定装置时,类固定固定装置的意外行为

我不在是我 2025-02-18 02:56:28

一种更好的方法是使用window.innerwidth

您可以制作一个检查视口宽度的on load功能。

window.onload = () => {
   if (window.innerWidth <= 800) {
   document.body.innerHTML = 'Page not accessible on small screens.'
   } else {
    loadDOM(); /* maybe put [display: none] on body as default and remove it here */
   }
}

此方法对用户更好。他们至少会知道他们必须从较大的设备访问网站

A better way to do this is using window.innerWidth.

You can make an onload function that checks the viewport width.

window.onload = () => {
   if (window.innerWidth <= 800) {
   document.body.innerHTML = 'Page not accessible on small screens.'
   } else {
    loadDOM(); /* maybe put [display: none] on body as default and remove it here */
   }
}

This method is better for the user. Atleast they'll know that they have to access the site from a larger device

防止在小屏幕上访问页面

我不在是我 2025-02-18 02:23:11

没关系弄清楚了。显然,我可以使用此三元运算符来生成不同类型,对象,尺寸等的列表。

pca_sizes = np.array([10,50,100,250,500])
pca_comp = [PCA(n_components = i) for i in (pca_sizes)]

显然,这也可用于存储具有不同尺寸的多维阵列。

无论如何,我几乎可以很好地理解这一点,以便正确解释其工作原理。

但这将解决我在这里看到的问题。

Nevermind figured it out. Apparently, I can use this ternary operator to generate lists of different types, objects, sizes etc etc.

pca_sizes = np.array([10,50,100,250,500])
pca_comp = [PCA(n_components = i) for i in (pca_sizes)]

This apparently can be used to store multi dimensional arrays with varying sizes too.

Anyways, I donot understand this nearly well enough to make proper explanation of how this works.

But this will fix the issue I see here.

在Python中创建一系列PCA对象?

我不在是我 2025-02-17 15:06:29

只是在左侧添加自动利润,认为课程可能会起作用。

.boom {
  position: relative;
  padding-left: 5px;
  bottom: 112px;
}

.think p {
  display: inline;
}

.think {
  width: 90%;
  text-align: center;
  padding: 5px;
  background-color: black;
  color: #F2F2F2;
  margin-top: 20px;
  margin-left: auto; 
  margin-right: auto;
}

.xit button {
  color: white;
  padding: 5px 70px;
  background-color: forestgreen;
  border-radius: 12px;
  font-family: istok-web;
}

.xit button:hover {
  background-color: white;
  color: green;
}
<div class="holdon">
  <a href="www.hotmail.com" class="boom">
    <img src="IMAGES/GOOOOOOOO.png" alt="dummy" height="100px" width="100px">
  </a>
</div>


<div class="rapper">
  <div class="commun">
    <div class="think">
      <p>eipuriepauip uipeojiupeiurqiewp uipeuiepuirepw uirepqrueiqp ufiepfipeiwp euipuqieupriqewp</p>
      <div class="xitf">
        <a class="xit" href="https://www.freecodecamp.org/">
          <button type="button">SIGN UP</button>
        </a>
      </div>
    </div>
  </div>
</div>

Just adding auto margins on left an right of think class might work.

.boom {
  position: relative;
  padding-left: 5px;
  bottom: 112px;
}

.think p {
  display: inline;
}

.think {
  width: 90%;
  text-align: center;
  padding: 5px;
  background-color: black;
  color: #F2F2F2;
  margin-top: 20px;
  margin-left: auto; 
  margin-right: auto;
}

.xit button {
  color: white;
  padding: 5px 70px;
  background-color: forestgreen;
  border-radius: 12px;
  font-family: istok-web;
}

.xit button:hover {
  background-color: white;
  color: green;
}
<div class="holdon">
  <a href="www.hotmail.com" class="boom">
    <img src="IMAGES/GOOOOOOOO.png" alt="dummy" height="100px" width="100px">
  </a>
</div>


<div class="rapper">
  <div class="commun">
    <div class="think">
      <p>eipuriepauip uipeojiupeiurqiewp uipeuiepuirepw uirepqrueiqp ufiepfipeiwp euipuqieupriqewp</p>
      <div class="xitf">
        <a class="xit" href="https://www.freecodecamp.org/">
          <button type="button">SIGN UP</button>
        </a>
      </div>
    </div>
  </div>
</div>

选定的DIV不会居中

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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