问:
Plot box plot using data from dictionary with frequency of occurrence
I have a dictionary in which key is the length of a particular column and value is the number of times the column value had that particular length. Can anyone tell me how do I plot a boxplot with this data? Do I have to convert it to a list and then call the plot?

from collections import defaultdict
sample_data = [1, 2, 3, 1, 1, 2, 4, 5]

sample_dict = defaultdict(int)
for i in sample_data:
    sample_dict[i] += 1

print(sample_dict)

defaultdict(<class 'int'>, {1: 3, 2: 2, 3: 1, 4: 1, 5: 1})
```
<p>The above dictionary is how I have my data currently. My dataset size is huge so I used this way of representation. Is converting the dictionary into a list is the way to plot boxplot i.e., do I need to make a list that contains ? TIA!</p>
<p>My dataframe looks like below, (just showing the head here)</p>
```|    |   len      |num_occurrence| dt.                 |
|---:|-----------:|-------------:|:--------------------|
|  0 |        183 |        599   | 2022-11-24 00:00:00 |
|  1 |        176 |       1029   | 2022-12-15 00:00:00 |
|  2 |          2 |         24   | 2022-12-02 00:00:00 |
|  3 |         18 |     449343   | 2022-12-09 00:00:00 |
|  4 |         45 |     640937   | 2022-12-09 00:00:00 |
```
<p>Currently I plot like below,</p>
```sns.boxplot(x='dt_formatted', y='subd_len', data=subd_pdf);
plt.title('Distribution of length');
plt.xticks(rotation=90);
```

But it does not take frequency of occurrence into consideration.

Body:
I have a dictionary in which key is the length of a particular column and value is the number of times the column value had that particular length. Can anyone tell me how do I plot a boxplot with this data? Do I have to convert it to a list and then call the plot?

from collections import defaultdict
sample_data = [1, 2, 3, 1, 1, 2, 4, 5]

sample_dict = defaultdict(int)
for i in sample_data:
    sample_dict[i] += 1

print(sample_dict)

defaultdict(<class 'int'>, {1: 3, 2: 2, 3: 1, 4: 1, 5: 1})

The above dictionary is how I have my data currently. My dataset size is huge so I used this way of representation. Is converting the dictionary into a list is the way to plot boxplot i.e., do I need to make a list that contains ? TIA!

My dataframe looks like below, (just showing the head here)

|    |   len      |num_occurrence| dt.                 |
|---:|-----------:|-------------:|:--------------------|
|  0 |        183 |        599   | 2022-11-24 00:00:00 |
|  1 |        176 |       1029   | 2022-12-15 00:00:00 |
|  2 |          2 |         24   | 2022-12-02 00:00:00 |
|  3 |         18 |     449343   | 2022-12-09 00:00:00 |
|  4 |         45 |     640937   | 2022-12-09 00:00:00 |

Currently I plot like below,

sns.boxplot(x='dt_formatted', y='subd_len', data=subd_pdf);
plt.title('Distribution of length');
plt.xticks(rotation=90);

But it does not take frequency of occurrence into consideration.


来源: stackexchange

问:
How to manually shrink distance between xticks
Using a pyplot scatterplot to graph some data with exponentially-changing x-values, the range of my xticks is so vast that it causes the smaller-value xticks to be squished together. how can I adjust the spacing between the ticks so that they are equally apart, yet maintain the same values?

```<code>ads = plt.figure()
ads, axs = plt.subplots(2, sharex=True)
axs[0].scatter(x='fold_dil', y='foci', data=rep1)
axs[1].scatter(x='fold_dil', y='foci', data=rep2)
plt.show()
</code>```

I've tried googling, but I'm new to Python and I could use as much help as I can get.

ContentLicense: CC BY-SA 4.0

Body:
Using a pyplot scatterplot to graph some data with exponentially-changing x-values, the range of my xticks is so vast that it causes the smaller-value xticks to be squished together. how can I adjust the spacing between the ticks so that they are equally apart, yet maintain the same values?

ads = plt.figure()
ads, axs = plt.subplots(2, sharex=True)
axs[0].scatter(x='fold_dil', y='foci', data=rep1)
axs[1].scatter(x='fold_dil', y='foci', data=rep2)
plt.show()

I've tried googling, but I'm new to Python and I could use as much help as I can get.


问:
Angular Programaticly Change Select Value Inside ngModelChange Does Not Work Without SetTimeout
This is my html:

```<code>  <select #sslConfigurationSelect  type="text"  [name]="'resolutionHeight'" (ngModelChange)="sslConfigurationChanged($event)" [(ngModel)]="newSslSettings.configurationType"
                                                             class="dropdown-toggle form-control" required>

                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.SUBDOMAIN_AUTO)}}">{{ sslConfigurationType.SUBDOMAIN_AUTO }}</option>
                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.CUSTOM_DOMAIN_AUTO)}}">{{ sslConfigurationType.CUSTOM_DOMAIN_AUTO }}</option>
                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.CUSTOM_CERTIFICATE)}}">{{ sslConfigurationType.CUSTOM_CERTIFICATE }}</option>
                                                        <option *ngIf ="currentSslSettings.configurationType != 'NO_SSL'" value="{{getSslConfigurationTypeName(sslConfigurationType.NO_SSL)}}">Remove ssl</option>

                                                    </select>
</code>```

When user selects first option, i check it with an if condition and try to set it back to some other option by changing model. But if i dont use setTimeout it doesnt update the select correctly.

```<code>sslConfigurationChanged(event:any){
        if(event == this.getSslConfigurationTypeName(SSLConfigurationType.SUBDOMAIN_AUTO)){
            alert("some warning")
            setTimeout(()=> this.newSslSettings.configurationType =this.getSslConfigurationTypeName(SSLConfigurationType.CUSTOM_DOMAIN_AUTO),1) // if i do like that it is working.
            this.newSslSettings.configurationType =this.getSslConfigurationTypeName(SSLConfigurationType.CUSTOM_DOMAIN_AUTO) // this should be the correct way but doesnt update dom correctly.
            return;
        }

    }
</code>```

Looks like when i choose this option on select with mouse it updates the model but then i try to change it back inside sslConfigurationChanged function and there is some kind of race condition.

how to solve this problem ?

Body:
This is my html:

  <select #sslConfigurationSelect  type="text"  [name]="'resolutionHeight'" (ngModelChange)="sslConfigurationChanged($event)" [(ngModel)]="newSslSettings.configurationType"
                                                             class="dropdown-toggle form-control" required>

                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.SUBDOMAIN_AUTO)}}">{{ sslConfigurationType.SUBDOMAIN_AUTO }}</option>
                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.CUSTOM_DOMAIN_AUTO)}}">{{ sslConfigurationType.CUSTOM_DOMAIN_AUTO }}</option>
                                                        <option value="{{getSslConfigurationTypeName(sslConfigurationType.CUSTOM_CERTIFICATE)}}">{{ sslConfigurationType.CUSTOM_CERTIFICATE }}</option>
                                                        <option *ngIf ="currentSslSettings.configurationType != 'NO_SSL'" value="{{getSslConfigurationTypeName(sslConfigurationType.NO_SSL)}}">Remove ssl</option>

                                                    </select>

When user selects first option, i check it with an if condition and try to set it back to some other option by changing model. But if i dont use setTimeout it doesnt update the select correctly.

sslConfigurationChanged(event:any){
        if(event == this.getSslConfigurationTypeName(SSLConfigurationType.SUBDOMAIN_AUTO)){
            alert("some warning")
            setTimeout(()=> this.newSslSettings.configurationType =this.getSslConfigurationTypeName(SSLConfigurationType.CUSTOM_DOMAIN_AUTO),1) // if i do like that it is working.
            this.newSslSettings.configurationType =this.getSslConfigurationTypeName(SSLConfigurationType.CUSTOM_DOMAIN_AUTO) // this should be the correct way but doesnt update dom correctly.
            return;
        }

    }

Looks like when i choose this option on select with mouse it updates the model but then i try to change it back inside sslConfigurationChanged function and there is some kind of race condition.

how to solve this problem ?


问:
Authentification issue with ckfinder Laravel 9
I have a problem with authentification ckfinder integrated in ckeditor 5 in Laravel 9. For ckfinder I added the follow code into config.php:

```<code>$config['authentication'] = function () {
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
$app = require_once  $_SERVER['DOCUMENT_ROOT']. '/bootstrap/app.php';
$response = $app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
$cookie = $_COOKIE[$app['config']['session']['cookie']] ?? false;
if ($cookie) {
    $id = $app['encrypter']->decrypt($cookie, false);
    $session = $app['session']->driver();
    $session->setId($id);
    $session->start();
}
if (!$app['auth']->check() || !$app['auth']->user()->is_admin){
    header('HTTP/1.0 403 Forbidden'); exit();
}
return true;
</code>```

but I have error - Invalid request
enter image description here

I tried to insert dd($app) after require_once and also I inserted dd(1) after require. dd(1) - was printed and I deleted dd(1) but dd($app) didn't work. Instead of it I have error - invalid request

Body:
I have a problem with authentification ckfinder integrated in ckeditor 5 in Laravel 9. For ckfinder I added the follow code into config.php:

$config['authentication'] = function () {
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
$app = require_once  $_SERVER['DOCUMENT_ROOT']. '/bootstrap/app.php';
$response = $app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
$cookie = $_COOKIE[$app['config']['session']['cookie']] ?? false;
if ($cookie) {
    $id = $app['encrypter']->decrypt($cookie, false);
    $session = $app['session']->driver();
    $session->setId($id);
    $session->start();
}
if (!$app['auth']->check() || !$app['auth']->user()->is_admin){
    header('HTTP/1.0 403 Forbidden'); exit();
}
return true;

but I have error - Invalid request
enter image description here

I tried to insert dd($app) after require_once and also I inserted dd(1) after require. dd(1) - was printed and I deleted dd(1) but dd($app) didn't work. Instead of it I have error - invalid request


问:
Spark Dataframe - java.lang.ArrayIndexOutOfBoundsException: 26 while writing to S3
I am trying to read some data from a snowflake table using Spark-Snowflake connector and write the data to S3 after performing some transformations. But I am seeing the error java.lang.ArrayIndexOutOfBoundsException: 26 when the line df.write.partitionBy(partitionColumn).mode(SaveMode.Append).parquet(s3Destination) is encountered.

Below is the full stacktrace:

```<code>java.lang.ArrayIndexOutOfBoundsException: 26
    at org.apache.spark.sql.types.StructType.apply(StructType.scala:414)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.$anonfun$applyOrElse$3(objects.scala:224)
    at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
    at scala.collection.immutable.List.foreach(List.scala:392)
    at scala.collection.TraversableLike.map(TraversableLike.scala:238)
    at scala.collection.TraversableLike.map$(TraversableLike.scala:231)
    at scala.collection.immutable.List.map(List.scala:298)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.applyOrElse(objects.scala:223)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.applyOrElse(objects.scala:211)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$1(TreeNode.scala:328)
    at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:74)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:328)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$3(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.trees.TreeNode.applyFunctionIfChanged$1(TreeNode.scala:387)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$mapChildren$1(TreeNode.scala:423)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapProductIterator(TreeNode.scala:255)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:421)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:369)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$3(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.trees.TreeNode.applyFunctionIfChanged$1(TreeNode.scala:387)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$mapChildren$1(TreeNode.scala:423)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapProductIterator(TreeNode.scala:255)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:421)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:369)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transform(TreeNode.scala:317)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$.apply(objects.scala:211)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$.apply(objects.scala:121)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$2(RuleExecutor.scala:216)
    at scala.collection.IndexedSeqOptimized.foldLeft(IndexedSeqOptimized.scala:60)
    at scala.collection.IndexedSeqOptimized.foldLeft$(IndexedSeqOptimized.scala:68)
    at scala.collection.mutable.WrappedArray.foldLeft(WrappedArray.scala:38)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1(RuleExecutor.scala:213)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1$adapted(RuleExecutor.scala:205)
    at scala.collection.immutable.List.foreach(List.scala:392)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.execute(RuleExecutor.scala:205)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$executeAndTrack$1(RuleExecutor.scala:183)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.executeAndTrack(RuleExecutor.scala:183)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$optimizedPlan$1(QueryExecution.scala:87)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:192)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$executePhase$1(QueryExecution.scala:163)
    at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:772)
    at org.apache.spark.sql.execution.QueryExecution.executePhase(QueryExecution.scala:163)
    at org.apache.spark.sql.execution.QueryExecution.optimizedPlan$lzycompute(QueryExecution.scala:84)
    at org.apache.spark.sql.execution.QueryExecution.optimizedPlan(QueryExecution.scala:84)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$writePlans$4(QueryExecution.scala:243)
    at org.apache.spark.sql.catalyst.plans.QueryPlan$.append(QueryPlan.scala:487)
    at org.apache.spark.sql.execution.QueryExecution.writePlans(QueryExecution.scala:243)
    at org.apache.spark.sql.execution.QueryExecution.toString(QueryExecution.scala:260)
    at org.apache.spark.sql.execution.QueryExecution.org$apache$spark$sql$execution$QueryExecution$$explainString(QueryExecution.scala:216)
    at org.apache.spark.sql.execution.QueryExecution.explainString(QueryExecution.scala:195)
    at org.apache.spark.sql.execution.SQLExecution$.executeQuery$1(SQLExecution.scala:102)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:135)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
    at org.apache.spark.sql.execution.SQLExecution$.withTracker(SQLExecution.scala:232)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:135)
    at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:253)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:134)
    at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:772)
    at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:68)
    at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:989)
    at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:438)
    at org.apache.spark.sql.DataFrameWriter.saveInternal(DataFrameWriter.scala:415)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:293)
    at org.apache.spark.sql.DataFrameWriter.parquet(DataFrameWriter.scala:874)
    at spark.ExportEvents$.writeToS3(ExportEvents.scala:315)
    at spark.ExportEvents$.$anonfun$processIncrementalLoad$1(ExportEvents.scala:257)
    at scala.collection.immutable.List.map(List.scala:286)
    at spark.ExportEvents$.processIncrementalLoad(ExportEvents.scala:185)
    at spark.ExportEvents$.main(ExportEvents.scala:75)
    at spark.ExportEvents.main(ExportEvents.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
    at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:959)
    at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)
    at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)
    at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)
    at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1038)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1047)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
</code>```

I am not sure why this is happening and how to resolve this. As a part of my transformations I am modifying a column name and it's changed into lower case where as all other columns are in uppercase. I am not sure if this is causing the issue as I believe parquet and spark are case insensitive by default.

I am using Spark 3.1.1 and spark-snowflake_2.12. Any help would be appreciated, thank you.

Body:
I am trying to read some data from a snowflake table using Spark-Snowflake connector and write the data to S3 after performing some transformations. But I am seeing the error java.lang.ArrayIndexOutOfBoundsException: 26 when the line df.write.partitionBy(partitionColumn).mode(SaveMode.Append).parquet(s3Destination) is encountered.

Below is the full stacktrace:

java.lang.ArrayIndexOutOfBoundsException: 26
    at org.apache.spark.sql.types.StructType.apply(StructType.scala:414)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.$anonfun$applyOrElse$3(objects.scala:224)
    at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
    at scala.collection.immutable.List.foreach(List.scala:392)
    at scala.collection.TraversableLike.map(TraversableLike.scala:238)
    at scala.collection.TraversableLike.map$(TraversableLike.scala:231)
    at scala.collection.immutable.List.map(List.scala:298)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.applyOrElse(objects.scala:223)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$$anonfun$apply$4.applyOrElse(objects.scala:211)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$1(TreeNode.scala:328)
    at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:74)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:328)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$3(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.trees.TreeNode.applyFunctionIfChanged$1(TreeNode.scala:387)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$mapChildren$1(TreeNode.scala:423)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapProductIterator(TreeNode.scala:255)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:421)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:369)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$3(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.trees.TreeNode.applyFunctionIfChanged$1(TreeNode.scala:387)
    at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$mapChildren$1(TreeNode.scala:423)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapProductIterator(TreeNode.scala:255)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:421)
    at org.apache.spark.sql.catalyst.trees.TreeNode.mapChildren(TreeNode.scala:369)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:333)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org$apache$spark$sql$catalyst$plans$logical$AnalysisHelper$$super$transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown(AnalysisHelper.scala:171)
    at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDown$(AnalysisHelper.scala:169)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDown(LogicalPlan.scala:29)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transform(TreeNode.scala:317)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$.apply(objects.scala:211)
    at org.apache.spark.sql.catalyst.optimizer.ObjectSerializerPruning$.apply(objects.scala:121)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$2(RuleExecutor.scala:216)
    at scala.collection.IndexedSeqOptimized.foldLeft(IndexedSeqOptimized.scala:60)
    at scala.collection.IndexedSeqOptimized.foldLeft$(IndexedSeqOptimized.scala:68)
    at scala.collection.mutable.WrappedArray.foldLeft(WrappedArray.scala:38)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1(RuleExecutor.scala:213)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1$adapted(RuleExecutor.scala:205)
    at scala.collection.immutable.List.foreach(List.scala:392)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.execute(RuleExecutor.scala:205)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$executeAndTrack$1(RuleExecutor.scala:183)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
    at org.apache.spark.sql.catalyst.rules.RuleExecutor.executeAndTrack(RuleExecutor.scala:183)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$optimizedPlan$1(QueryExecution.scala:87)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:192)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$executePhase$1(QueryExecution.scala:163)
    at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:772)
    at org.apache.spark.sql.execution.QueryExecution.executePhase(QueryExecution.scala:163)
    at org.apache.spark.sql.execution.QueryExecution.optimizedPlan$lzycompute(QueryExecution.scala:84)
    at org.apache.spark.sql.execution.QueryExecution.optimizedPlan(QueryExecution.scala:84)
    at org.apache.spark.sql.execution.QueryExecution.$anonfun$writePlans$4(QueryExecution.scala:243)
    at org.apache.spark.sql.catalyst.plans.QueryPlan$.append(QueryPlan.scala:487)
    at org.apache.spark.sql.execution.QueryExecution.writePlans(QueryExecution.scala:243)
    at org.apache.spark.sql.execution.QueryExecution.toString(QueryExecution.scala:260)
    at org.apache.spark.sql.execution.QueryExecution.org$apache$spark$sql$execution$QueryExecution$$explainString(QueryExecution.scala:216)
    at org.apache.spark.sql.execution.QueryExecution.explainString(QueryExecution.scala:195)
    at org.apache.spark.sql.execution.SQLExecution$.executeQuery$1(SQLExecution.scala:102)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:135)
    at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
    at org.apache.spark.sql.execution.SQLExecution$.withTracker(SQLExecution.scala:232)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:135)
    at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:253)
    at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:134)
    at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:772)
    at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:68)
    at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:989)
    at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:438)
    at org.apache.spark.sql.DataFrameWriter.saveInternal(DataFrameWriter.scala:415)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:293)
    at org.apache.spark.sql.DataFrameWriter.parquet(DataFrameWriter.scala:874)
    at spark.ExportEvents$.writeToS3(ExportEvents.scala:315)
    at spark.ExportEvents$.$anonfun$processIncrementalLoad$1(ExportEvents.scala:257)
    at scala.collection.immutable.List.map(List.scala:286)
    at spark.ExportEvents$.processIncrementalLoad(ExportEvents.scala:185)
    at spark.ExportEvents$.main(ExportEvents.scala:75)
    at spark.ExportEvents.main(ExportEvents.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
    at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:959)
    at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)
    at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)
    at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)
    at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1038)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1047)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

I am not sure why this is happening and how to resolve this. As a part of my transformations I am modifying a column name and it's changed into lower case where as all other columns are in uppercase. I am not sure if this is causing the issue as I believe parquet and spark are case insensitive by default.

I am using Spark 3.1.1 and spark-snowflake_2.12. Any help would be appreciated, thank you.


问:
Android database application with admin and guest login
I need to know how I can create a database that can also accessible with a desktop application?

I'm trying to create and android application that has admin and guest login and a database that can access via a desktop application


问:
new Thread and React Native. Add Mapsforge library
Try to add library mapsforge as module to React Native for generating bmp tiles.
But have problem with render of map.
Render tiles runing from new Thread
If i understand correct, this shouldn't work since RN blocked all threads for self work?

Library is very useful, but modules not exist by mapforge in free access =)

Do variants exist for realisations of  render in other thread?

Ty for anwser

org/mapsforge/map/layer/renderer/TileRendererLayer.java
file TileRendererLayer.java

first step

second step

```<code>public void setXmlRenderTheme(XmlRenderTheme xmlRenderTheme) {
        this.xmlRenderTheme = xmlRenderTheme;
        compileRenderTheme();
    }

    protected void compileRenderTheme() {
        this.renderThemeFuture = new RenderThemeFuture(this.graphicFactory, this.xmlRenderTheme, this.displayModel);
        new Thread(this.renderThemeFuture).start();
    }
</code>```

For test i created additional activity and try run render. But doesnt work too
Reading doc by ReactNative about thread and to clarify about info. Next step is to check status of thread after running application and search info about running map in other Activity with render in another thread or as service. Mb idea is bad.

Body:
Try to add library mapsforge as module to React Native for generating bmp tiles.
But have problem with render of map.
Render tiles runing from new Thread
If i understand correct, this shouldn't work since RN blocked all threads for self work?

Library is very useful, but modules not exist by mapforge in free access =)

Do variants exist for realisations of  render in other thread?

Ty for anwser

org/mapsforge/map/layer/renderer/TileRendererLayer.java
file TileRendererLayer.java

first step

second step

public void setXmlRenderTheme(XmlRenderTheme xmlRenderTheme) {
        this.xmlRenderTheme = xmlRenderTheme;
        compileRenderTheme();
    }

    protected void compileRenderTheme() {
        this.renderThemeFuture = new RenderThemeFuture(this.graphicFactory, this.xmlRenderTheme, this.displayModel);
        new Thread(this.renderThemeFuture).start();
    }

For test i created additional activity and try run render. But doesnt work too
Reading doc by ReactNative about thread and to clarify about info. Next step is to check status of thread after running application and search info about running map in other Activity with render in another thread or as service. Mb idea is bad.


问:
React native is picky about android sdk version. I still don’t know what version doctor wants

what is the supported version number?

Body: what is the supported version number?


问:
scipy special beta function and integral
I have two values $a$ and $b$ where $a \ge 0$ and $b \ge 0$ and I have to calculate the formula below.

...
\frac{1}{2}\int_0^1\text{abs}\left[( \frac{p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)})}{\beta(a,b)} )- 1\right] dp_i

...

I have to calculate above value.
I am facing below error while doing that.
My equation is implemented as

...

```<code>import scipy.special as sc
import scipy.integrate as spi
integrand_np = lambda p_i:   abs(((p_i ** (a - 1)) * ((1 - p_i) ** (b - 1)) / (sc.beta(a,b)) - 1) / 2

result1, error = spi.quad(integrand_np, a, b)

<ipython-input-7-9c587cce0891>:35: IntegrationWarning: The occurrence of roundoff error is detected, which prevents
the requested tolerance from being achieved.  The error may be
underestimated.
result1, error = spi.quad(integrand_np, a, b)
</code>```

...

Beta value is coming as zero. so the equation fails. If i try to use betaln function by changing equation as below, I am getting different values for small computations

I am getting an error. I tried to use betaln by changing my equation. Still I am facing below issue

IntegrationWarning: The occurrence of roundoff error is detected,
which prevents    the requested tolerance from being achieved.  The
error may be    underestimated.

Sample a values = [1400, 440, 799]
Sample b values = [700,560, 1400]

To prevent error is there a way to use scipy.special.betaln.
I changed above formula as below to use betaln

$$
\frac{1}{2}\int_0^1 ( \frac{p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)})}{\beta(a,b)} ) dp_i - \frac{1}{2}\int_0^1 1 dp_i

\frac{1}{2*beta(a,b)}\int_0^1 ( p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)}) ) dp_i - \frac{1}{2}\int_0^1 1 dp_i

integralvalue = \int_0^1 ( p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)}) ) dp_i
$$

Then I am applying log to use betaln function. But still it is not working.
...

```<code>import scipy.special as sc
import scipy.integrate as spi
import numpy as np

integrand = lambda p_i: abs(((p_i ** (p_count - 1)) * ((1 - p_i) ** (n_count - 1))))

integral_second_term = lambda p_i: 1/2
result1, error = spi.quad(integrand, a, b)

result2, error1 = spi.quad(integral_second_term, a, b)
final_log = np.log(result1) - sc.betaln(p_count, n_count) - np.log(2)
final_output = abs((np.exp(final_log)) - result2)
</code>```

...

It is not giving correct values

I am getting an error saying roundoff error while integrating.

I tried log function also it is still not working

Body:
I have two values $a$ and $b$ where $a \ge 0$ and $b \ge 0$ and I have to calculate the formula below.

...
\frac{1}{2}\int_0^1\text{abs}\left[( \frac{p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)})}{\beta(a,b)} )- 1\right] dp_i

...

I have to calculate above value.
I am facing below error while doing that.
My equation is implemented as

...

import scipy.special as sc
import scipy.integrate as spi
integrand_np = lambda p_i:   abs(((p_i ** (a - 1)) * ((1 - p_i) ** (b - 1)) / (sc.beta(a,b)) - 1) / 2

result1, error = spi.quad(integrand_np, a, b)

<ipython-input-7-9c587cce0891>:35: IntegrationWarning: The occurrence of roundoff error is detected, which prevents
the requested tolerance from being achieved.  The error may be
underestimated.
result1, error = spi.quad(integrand_np, a, b)

...

Beta value is coming as zero. so the equation fails. If i try to use betaln function by changing equation as below, I am getting different values for small computations

I am getting an error. I tried to use betaln by changing my equation. Still I am facing below issue

IntegrationWarning: The occurrence of roundoff error is detected,
which prevents    the requested tolerance from being achieved.  The
error may be    underestimated.

Sample a values = [1400, 440, 799]
Sample b values = [700,560, 1400]

To prevent error is there a way to use scipy.special.betaln.
I changed above formula as below to use betaln

$$
\frac{1}{2}\int_0^1 ( \frac{p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)})}{\beta(a,b)} ) dp_i - \frac{1}{2}\int_0^1 1 dp_i

\frac{1}{2*beta(a,b)}\int_0^1 ( p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)}) ) dp_i - \frac{1}{2}\int_0^1 1 dp_i

integralvalue = \int_0^1 ( p_i^{(a - 1)} \times (1 - p_i)^{(b - 1)}) ) dp_i
$$

Then I am applying log to use betaln function. But still it is not working.
...

import scipy.special as sc
import scipy.integrate as spi
import numpy as np

integrand = lambda p_i: abs(((p_i ** (p_count - 1)) * ((1 - p_i) ** (n_count - 1))))

integral_second_term = lambda p_i: 1/2
result1, error = spi.quad(integrand, a, b)

result2, error1 = spi.quad(integral_second_term, a, b)
final_log = np.log(result1) - sc.betaln(p_count, n_count) - np.log(2)
final_output = abs((np.exp(final_log)) - result2)

...

It is not giving correct values

I am getting an error saying roundoff error while integrating.

I tried log function also it is still not working


问:
What are these Spring Cloud errors in AWS?
I have a Spring cloud deployment in AWS, consisting of Spring Cloud (Server), Spring Boot (client) that acts like all connections are there.  However the log files are full of these messages on each server:

INFO 1 --- [freshExecutor-0] o.apache.http.impl.execchain.RetryExec

: I/O exception (org.apache.http.NoHttpResponseException) caught when
processing request to
{}->http://xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010: The
target server failed to respond

INFO 1 --- [freshExecutor-0]  o.apache.http.impl.execchain.RetryExec

: Retrying request to
{}->http://xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010

INFO 1 --- [freshExecutor-0]  c.n.d.s.r.aws.ConfigClusterResolver

: Resolving eureka endpoints via configuration

2022-12-20 18:13:37.828  INFO 1 --- [tbeatExecutor-0]
c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error.
endpoint=DefaultEndpoint{
serviceUrl='http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/}
exception=I/O error on PUT request for
"http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/apps/DRUG-SERVICE/drug-service:9a1dda708e094daea4750f050402536c":
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to
respond; nested exception is org.apache.http.NoHttpResponseException:
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to respond
stacktrace=org.springframework.web.client.ResourceAccessException: I/O
error on PUT request for
"http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/apps/DRUG-SERVICE/drug-service:9a1dda708e094daea4750f050402536c":
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to
respond; nested exception is org.apache.http.NoHttpResponseException:
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to respond

at
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)

Again, I cannot tell that anything is wrong since these appear to be INFO level logging events.  However, before I set

```<code>logging.level.org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient=FATAL
</code>```

I would like to make sure I will not be masking an issue that I should not be.

** UPDATE **
Since these appear to be INFO level messages I thought I would mask these:

```<code>INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
INFO 1 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ ...
</code>```

With these in my application.properties file:

logging.level.org.springframework.cloud.netflix.eureka.http=FATAL
logging.level.com.netflix.discovery.shared.transport.decorator = FATAL
logging.level.com.netflix.discovery.shared.resolver.aws = ERROR

However, they are still filling up my log files.  Any idea what I might be doing wrong?

Body:
I have a Spring cloud deployment in AWS, consisting of Spring Cloud (Server), Spring Boot (client) that acts like all connections are there.  However the log files are full of these messages on each server:

INFO 1 --- [freshExecutor-0] o.apache.http.impl.execchain.RetryExec

: I/O exception (org.apache.http.NoHttpResponseException) caught when
processing request to
{}->http://xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010: The
target server failed to respond

INFO 1 --- [freshExecutor-0]  o.apache.http.impl.execchain.RetryExec

: Retrying request to
{}->http://xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010

INFO 1 --- [freshExecutor-0]  c.n.d.s.r.aws.ConfigClusterResolver

: Resolving eureka endpoints via configuration

2022-12-20 18:13:37.828  INFO 1 --- [tbeatExecutor-0]
c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error.
endpoint=DefaultEndpoint{
serviceUrl='http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/}
exception=I/O error on PUT request for
"http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/apps/DRUG-SERVICE/drug-service:9a1dda708e094daea4750f050402536c":
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to
respond; nested exception is org.apache.http.NoHttpResponseException:
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to respond
stacktrace=org.springframework.web.client.ResourceAccessException: I/O
error on PUT request for
"http://eureka:@xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010/eureka/apps/DRUG-SERVICE/drug-service:9a1dda708e094daea4750f050402536c":
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to
respond; nested exception is org.apache.http.NoHttpResponseException:
xxxxx-ALB-123456789.us-east-x.elb.amazonaws.com:8010 failed to respond

at
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)

Again, I cannot tell that anything is wrong since these appear to be INFO level logging events.  However, before I set

logging.level.org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient=FATAL

I would like to make sure I will not be masking an issue that I should not be.

** UPDATE **
Since these appear to be INFO level messages I thought I would mask these:

INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
INFO 1 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ ...

With these in my application.properties file:

logging.level.org.springframework.cloud.netflix.eureka.http=FATAL
logging.level.com.netflix.discovery.shared.transport.decorator = FATAL
logging.level.com.netflix.discovery.shared.resolver.aws = ERROR

However, they are still filling up my log files.  Any idea what I might be doing wrong?


问:
Why won't column names update in this function?
I occasionally want to export a dataset to Stata but I sometimes have variable names that exceed the 32 character limit that Stata allows, so I am trying to write a function that identifies those variables and then truncates them to 32 characters. The below code works in everything (i.e. displaying offending variable indices and names) except actually writing the truncated names back to the data frame.

```<code>short_var_names <- function(data.in){
  long_names_indices <- data.frame(long_name_indices = which(nchar(names(data.in)) > 32))
  long_names <- data.frame(long_names = names(data.in[which(nchar(names(data.in)) > 32)]))
  short_names <- data.frame(short_names = names(data.in[as.numeric(unlist(long_names_indices))]))
  print(long_names_indices)
  print(long_names)
  print(short_names)
  names(data.in) <- substring(names(data.in), 1, 32) # now do the actual operation on the df
}

short_var_names(dat_clin)
</code>```

When I use the following outside of the function, it works as expected:

```<code>names(dat_clin) <- substring(names(dat_clin), 1, 32)
</code>```

So, why isn't this command being returned in the function?

Body:
I occasionally want to export a dataset to Stata but I sometimes have variable names that exceed the 32 character limit that Stata allows, so I am trying to write a function that identifies those variables and then truncates them to 32 characters. The below code works in everything (i.e. displaying offending variable indices and names) except actually writing the truncated names back to the data frame.

short_var_names <- function(data.in){
  long_names_indices <- data.frame(long_name_indices = which(nchar(names(data.in)) > 32))
  long_names <- data.frame(long_names = names(data.in[which(nchar(names(data.in)) > 32)]))
  short_names <- data.frame(short_names = names(data.in[as.numeric(unlist(long_names_indices))]))
  print(long_names_indices)
  print(long_names)
  print(short_names)
  names(data.in) <- substring(names(data.in), 1, 32) # now do the actual operation on the df
}

short_var_names(dat_clin)

When I use the following outside of the function, it works as expected:

names(dat_clin) <- substring(names(dat_clin), 1, 32)

So, why isn't this command being returned in the function?


问:
Xamarin not displaying text from TextCell
My view looks like this

 <ListView ItemsSource="{Binding Guests}"
                                          Margin="0" HeightRequest="300"
                                          VerticalOptions="FillAndExpand"
                                          RowHeight="28"
                                          SelectionMode="None">
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <TextCell Text="{Binding .}" TextColor="{StaticResource BT-DarkGray}"/>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>
```
<p>My model has Guest as property what is deserialized using newtonsoft, I had to add the JsonProperty tag on the property otherwise the setter was not called. the list for this test case contains 12 items.</p>
<pre class="lang-cs prettyprint-override"><code>private ObservableCollection<string> _guest;

        [JsonProperty("guests")]
        public ObservableCollection<string> Guests
        {
            get => _guest;
            set => SetProperty(ref _guest, value);
        }

        private ObservableCollection<LocalShowFlight> _flights;
        [JsonProperty("flights")]
        public ObservableCollection<LocalShowFlight> Flights
        {
            get => _flights;
            set => SetProperty(ref _flights, value);
        }
        private ObservableCollection<LocalShowTiming> _timings;
        [JsonProperty("timings")]
        public ObservableCollection<LocalShowTiming> Timings
        {
            get => _timings;
            set => SetProperty(ref _timings, value);
        }

        public void RaisCollectionChanged()
        {
            OnPropertyChanged(nameof(Guests));
            OnPropertyChanged(nameof(Flights));
            OnPropertyChanged(nameof(TimingOther));
        }
</code>```

My viewmodel has a Model property where i'm calling RaisCollectionChanged to make sure the on property changes is called.

public ShowBandAppModelV2 Model
        {
            get { return _model; }
            set
            {
                SetProperty(ref _model, value);
                Model?.RaisCollectionChanged();
            }
        }
```
<p>the end result is showing
<img src="https://i.stack.imgur.com/HfSA7m.png" alt="enter image description here" /></p>
<p>Why is the text not displayed since the cells are generated, now the strange thing is with hot reload when I remove the <code>.</code> in the binding and save the view the text appears en when I put the <code>.</code> back the texts changes, so I think it has to do with binding put I don't see what I'm missing. same thing when changing color, It looks like the view has no correct binding on first load.</p>
<p>Anyone with an idea on how to solve this, ore using a different view then listviews if it can solve the issue.</p>
<hr />
<p>Found a fix, when I change the dataTemplete to viewcell with a label, the binding works.</p>
```<ListView.ItemTemplate>
                                        <DataTemplate x:DataType="x:String">
                                            <ViewCell>

                                            </ViewCell>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
```

Body:
My view looks like this

 <ListView ItemsSource="{Binding Guests}"
                                          Margin="0" HeightRequest="300"
                                          VerticalOptions="FillAndExpand"
                                          RowHeight="28"
                                          SelectionMode="None">
                                        <ListView.ItemTemplate>
                                            <DataTemplate>
                                                <TextCell Text="{Binding .}" TextColor="{StaticResource BT-DarkGray}"/>
                                            </DataTemplate>
                                        </ListView.ItemTemplate>
                                    </ListView>

My model has Guest as property what is deserialized using newtonsoft, I had to add the JsonProperty tag on the property otherwise the setter was not called. the list for this test case contains 12 items.

private ObservableCollection<string> _guest;

        [JsonProperty("guests")]
        public ObservableCollection<string> Guests
        {
            get => _guest;
            set => SetProperty(ref _guest, value);
        }

        private ObservableCollection<LocalShowFlight> _flights;
        [JsonProperty("flights")]
        public ObservableCollection<LocalShowFlight> Flights
        {
            get => _flights;
            set => SetProperty(ref _flights, value);
        }
        private ObservableCollection<LocalShowTiming> _timings;
        [JsonProperty("timings")]
        public ObservableCollection<LocalShowTiming> Timings
        {
            get => _timings;
            set => SetProperty(ref _timings, value);
        }

        public void RaisCollectionChanged()
        {
            OnPropertyChanged(nameof(Guests));
            OnPropertyChanged(nameof(Flights));
            OnPropertyChanged(nameof(TimingOther));
        }

My viewmodel has a Model property where i'm calling RaisCollectionChanged to make sure the on property changes is called.

public ShowBandAppModelV2 Model
        {
            get { return _model; }
            set
            {
                SetProperty(ref _model, value);
                Model?.RaisCollectionChanged();
            }
        }

the end result is showing

Why is the text not displayed since the cells are generated, now the strange thing is with hot reload when I remove the . in the binding and save the view the text appears en when I put the . back the texts changes, so I think it has to do with binding put I don't see what I'm missing. same thing when changing color, It looks like the view has no correct binding on first load.

Anyone with an idea on how to solve this, ore using a different view then listviews if it can solve the issue.

Found a fix, when I change the dataTemplete to viewcell with a label, the binding works.

<ListView.ItemTemplate>
                                        <DataTemplate x:DataType="x:String">
                                            <ViewCell>

                                            </ViewCell>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>


问:
Cocoa Collapsible Panel UI Design
I'm trying to develop an interface on XCode 3.2.6 with Interface Builder. I'm planing to design an UI with collapsible panels like image below:

http://i1-win.softpedia-static.com/screenshots/TexturePacker_1.png

In this sample, there is 3 panels seen on the UI (Geometry, Layout and Output). When user collapses the Geometry panel, it shrinks and Layout panel moves up with Output panel. You can expand and collapse each panel individually.

are there any special technique to do that or do I need to use a custom control to achieve this view? If so, do you know which component set has this feature?

ContentLicense: CC BY-SA 3.0

Title: Cocoa Collapsible Panel UI Design


问:
Pytest testing: celery timed event triggered by post_save signals
I use celery+sqs to perform timed tasks.

Flow is like this:

Object is created -> post_save signal received -> celery task executed based on the date

Here is the case:

I have a model

```<code>SmartStorage:
 ...
 execution_date: datetime
</code>```

And a signal:

```<code>@receiver(post_save, sender="storage.SmartStorage")
def _notify_smart_storage_execution(
sender: ModelBase, created: bool, instance: SmartStorage, **kwargs
) -> None:
     if created:
        buffer = instance.execution_date - timedelta(minutes=5)
        celery_notify_smart_storage_execution_task.apply_async(
            kwargs={"storage_id": instance.id}, eta=buffer
        )
</code>```

And a task:

```<code>@shared_task()
def celery_notify_smart_storage_execution_task(storage_id: uuid.UUID) -> None:

    instance = SmartStorage.objects.get(id=storage_id)
    SqsUtils.send_sqs_queue_message(
        sqs_queue_name=SqsUtils.SmartStorage,
        message_body=f"Storage {instance.name} is available in 5 minutes",
    )
</code>```

I want to perform endpoint testing via pytest, where only one instance sends a message to sqs:

```<code>@pytest.mark.django_db
class TestSmartStorageTasks:

    @pytest.fixture(autouse=True)
    def _setup(self) -> None:
        SqsUtils.delete_sqs_queue_messages("celery")

    def test_storage_is_starting(self):
        # This is the only one to send a message to sqs
        test_storage = test_smart_storage_factory(
            execution_date=timezone.now() + datetime.timedelta(minutes=5, seconds=1)
        )
        # Bunch of other storage models, those should not be sending messages to sqs
        for _ in range(10):
            test_smart_storage_factory()

        time.sleep(10)

        sqs_messages = SqsUtils.list_sqs_queue_messages("celery")
        received_messages = sqs_messages["Messages"]
        assert len(received_messages) == 1
</code>```

I always get 11, although if I do manual testing, which I am not a fan of, everything works fine. I would appreciate help guys!

Body:
I use celery+sqs to perform timed tasks.

Flow is like this:

Object is created -> post_save signal received -> celery task executed based on the date

Here is the case:

I have a model

SmartStorage:
 ...
 execution_date: datetime

And a signal:

@receiver(post_save, sender="storage.SmartStorage")
def _notify_smart_storage_execution(
sender: ModelBase, created: bool, instance: SmartStorage, **kwargs
) -> None:
     if created:
        buffer = instance.execution_date - timedelta(minutes=5)
        celery_notify_smart_storage_execution_task.apply_async(
            kwargs={"storage_id": instance.id}, eta=buffer
        )

And a task:

@shared_task()
def celery_notify_smart_storage_execution_task(storage_id: uuid.UUID) -> None:

    instance = SmartStorage.objects.get(id=storage_id)
    SqsUtils.send_sqs_queue_message(
        sqs_queue_name=SqsUtils.SmartStorage,
        message_body=f"Storage {instance.name} is available in 5 minutes",
    )

I want to perform endpoint testing via pytest, where only one instance sends a message to sqs:

@pytest.mark.django_db
class TestSmartStorageTasks:

    @pytest.fixture(autouse=True)
    def _setup(self) -> None:
        SqsUtils.delete_sqs_queue_messages("celery")

    def test_storage_is_starting(self):
        # This is the only one to send a message to sqs
        test_storage = test_smart_storage_factory(
            execution_date=timezone.now() + datetime.timedelta(minutes=5, seconds=1)
        )
        # Bunch of other storage models, those should not be sending messages to sqs
        for _ in range(10):
            test_smart_storage_factory()

        time.sleep(10)

        sqs_messages = SqsUtils.list_sqs_queue_messages("celery")
        received_messages = sqs_messages["Messages"]
        assert len(received_messages) == 1

I always get 11, although if I do manual testing, which I am not a fan of, everything works fine. I would appreciate help guys!


问:
N number of Sequelize connections to dynamically query via API calls
I'm looking to get some opinions on what the best approach is for the following scenario:

Our product requires connections to our users' Postgres databases via our Node Express server, they provide their credentials once and we store it in an encrypted way in our internal operations DB and can reference to it when access is needed. A user can do an action on our app UI like create a table, delete a table, etc. and view table sizes, min max values of a column, etc.

These actions comes to our server as authenticated API calls and we can query their databases via Sequelize as needed and return the results to frontend.

My question is, when there are N number of users with N number of databases from different SQL instances that need to be connected when an API is called to query the respective database, what is the best approach to maintain that?

Should we create a new Sequelize connection instance each time an API is called and run the query, return the response, and close the connection. Or create a new Sequelize connection instance for a DB when an API is called, and keep the instance for certain amount of time, and close the connection if it was inactive during that amount of time, and restart the instance next time?

If there are better and more efficient ways of doing this, I would love to hear about it. Thanks.

Currently, I've tried to do a new Sequelize instance each time at the beginning of the API request, and run the query, and then close the connection. Works ok, but that's just locally with 2 DBs so I can't tell what production would be like.

Edit: Anatoly suggested connection pool, in that case, what're the things that need to be considered for the config?


问:
Compare two string arrays in PostgreSQL
In a Postgres DB, I have 2 varchar[] columns in 2 tables with common ID that contain data as below:

I need to return rows where all values of t_col are present in f_col (with or without extra data).

Desired result:

I tried with the below as conditions in self join query.

```<code>select
from t1 a, t2 b
where a.id=b.id
not (a.f_col @> b.t_col)
</code>```

Title: Compare two string arrays in PostgreSQL

Body:
In a Postgres DB, I have 2 varchar[] columns in 2 tables with common ID that contain data as below:

I need to return rows where all values of t_col are present in f_col (with or without extra data).

Desired result:

I tried with the below as conditions in self join query.

select
from t1 a, t2 b
where a.id=b.id
not (a.f_col @> b.t_col)


问:
Race Condition in Sagemaker Batch Transform Job
We are facing this bug in our production environment. I have been looking for a solution for a while and I cannot seem to solve it. Any help would be appreciated.

We are using Sagemaker Batch Transform to perform inference on our machine learning models. Each job is supposed to create one instance using a docker image from our ECR container. This job then consumes a payload and starts processing it using a pytorch script. When the job is done, the script calls an API to store the results.

The issue is that when we check the cloud watch logs for a SINGLE job, we see that it is repeated. After the job is repeated multiple times, the individual instances of the same job may or may not finish and the whole operation returns with an error.

Basically, we see the following issue in our cloud watch logs and cannot seem to figure out what is causing this:

```<code>2022-04-24 19:41:47,865 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There is no error but the job doesn't seem to run anymore, the same job seems to roll back again]
...
2022-04-24 19:52:09,522 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There is no error but the job doesn't seem to run anymore, the same job seems to roll back again]
...
2022-04-24 20:12:11,834 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There are no errors but the cloud watch logs stop here. Sagemaker returns an error to the client.]
</code>```

The following sample code is what we are using to run the jobs:

```<code>def inference_batch(self):
    batch_input = f"s3://{self.cnf.SAGEMAKER_BUCKET}/batch-input/batch.csv"
    batch_output = f"s3://{self.cnf.SAGEMAKER_BUCKET}/batch-output/"
    job_name = f"{self.cnf.SAGEMAKER_MODEL}-{str(datetime.datetime.now().strftime('%Y-%m-%d-%H-%m-%S'))}"

    transform_input = {
        'DataSource': {
            'S3DataSource': {
                'S3DataType': 'S3Prefix',
                'S3Uri': batch_input
            }
        },
        'ContentType': 'text/csv',
        'SplitType': 'Line',
    }

    transform_output = {
        'S3OutputPath': batch_output
    }

    transform_resources = {
        'InstanceType': self.cnf.SAGEMAKER_BATCH_INSTANCE,
        'InstanceCount': 1
    }

    # self.sm_boto_client is an instance of boto3.Session(region_name="some-region).client("sagemaker")
    self.sm_boto_client.create_transform_job(
        TransformJobName=job_name,
        ModelName=self.cnf.SAGEMAKER_MODEL,
        TransformInput=transform_input,
        TransformOutput=transform_output,
        TransformResources=transform_resources
    )

    status = self.sm_boto_client.describe_transform_job(TransformJobName=job_name)
    print(f'Executing transform job {job_name}...')
    while status['TransformJobStatus'] == 'InProgress':
        time.sleep(5)
        status = self.sm_boto_client.describe_transform_job(TransformJobName=job_name)

    if status['TransformJobStatus'] == 'Completed':
        print(f'Batch transform job {job_name} successfully completed.')
    else:
        raise Exception(f'Batch transform job {job_name} failed.')
</code>```

Body:
We are facing this bug in our production environment. I have been looking for a solution for a while and I cannot seem to solve it. Any help would be appreciated.

We are using Sagemaker Batch Transform to perform inference on our machine learning models. Each job is supposed to create one instance using a docker image from our ECR container. This job then consumes a payload and starts processing it using a pytorch script. When the job is done, the script calls an API to store the results.

The issue is that when we check the cloud watch logs for a SINGLE job, we see that it is repeated. After the job is repeated multiple times, the individual instances of the same job may or may not finish and the whole operation returns with an error.

Basically, we see the following issue in our cloud watch logs and cannot seem to figure out what is causing this:

2022-04-24 19:41:47,865 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There is no error but the job doesn't seem to run anymore, the same job seems to roll back again]
...
2022-04-24 19:52:09,522 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There is no error but the job doesn't seem to run anymore, the same job seems to roll back again]
...
2022-04-24 20:12:11,834 [INFO ] W-model-1-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Starting to Process Task: 12345678-abcd-1234-efgh-123456ab12c3
...
[The job is running and printing logs]
...
[There are no errors but the cloud watch logs stop here. Sagemaker returns an error to the client.]

The following sample code is what we are using to run the jobs:

def inference_batch(self):
    batch_input = f"s3://{self.cnf.SAGEMAKER_BUCKET}/batch-input/batch.csv"
    batch_output = f"s3://{self.cnf.SAGEMAKER_BUCKET}/batch-output/"
    job_name = f"{self.cnf.SAGEMAKER_MODEL}-{str(datetime.datetime.now().strftime('%Y-%m-%d-%H-%m-%S'))}"

    transform_input = {
        'DataSource': {
            'S3DataSource': {
                'S3DataType': 'S3Prefix',
                'S3Uri': batch_input
            }
        },
        'ContentType': 'text/csv',
        'SplitType': 'Line',
    }

    transform_output = {
        'S3OutputPath': batch_output
    }

    transform_resources = {
        'InstanceType': self.cnf.SAGEMAKER_BATCH_INSTANCE,
        'InstanceCount': 1
    }

    # self.sm_boto_client is an instance of boto3.Session(region_name="some-region).client("sagemaker")
    self.sm_boto_client.create_transform_job(
        TransformJobName=job_name,
        ModelName=self.cnf.SAGEMAKER_MODEL,
        TransformInput=transform_input,
        TransformOutput=transform_output,
        TransformResources=transform_resources
    )

    status = self.sm_boto_client.describe_transform_job(TransformJobName=job_name)
    print(f'Executing transform job {job_name}...')
    while status['TransformJobStatus'] == 'InProgress':
        time.sleep(5)
        status = self.sm_boto_client.describe_transform_job(TransformJobName=job_name)

    if status['TransformJobStatus'] == 'Completed':
        print(f'Batch transform job {job_name} successfully completed.')
    else:
        raise Exception(f'Batch transform job {job_name} failed.')


问:
Python Pandas libs problem with filtering
I have written this search function for a dataframe:

def search_for_name(name, data):
    print(name)
    dogs_with_name = data[data["HundenameText"].str.contains(name)]
    return dogs_with_name[["HundenameText", "GebDatHundJahr", "SexHundLang"]]
```

Unfortunately, this returns more records than I want, e.g. Arina Luna when I'm looking for Luna. I'm only interested in exact matches. How do I achieve that?

Body:
I have written this search function for a dataframe:

def search_for_name(name, data):
    print(name)
    dogs_with_name = data[data["HundenameText"].str.contains(name)]
    return dogs_with_name[["HundenameText", "GebDatHundJahr", "SexHundLang"]]

Unfortunately, this returns more records than I want, e.g. Arina Luna when I'm looking for Luna. I'm only interested in exact matches. How do I achieve that?


问:
Edit minecraft pluggin from jar and
My friend asked me if I can make some changes to pluggins he send me. I tried googeling them to find the sorcecode somewhere. Sadly it seems that they are not open scource.

So I started decompiling the jar(s) and made the changes in the .class files with IntelliJ.
Now is my question how I can compile it back to a .jar file. Normaly I used maven to build the plugins. But because it isn't a maven project this doesn't work.

I tried creating the jar with:

```<code>jar cvf plugin.jar .
</code>```

but this gives me the error Cannot find main class

Title: Edit minecraft pluggin from jar and

Body:
My friend asked me if I can make some changes to pluggins he send me. I tried googeling them to find the sorcecode somewhere. Sadly it seems that they are not open scource.

So I started decompiling the jar(s) and made the changes in the .class files with IntelliJ.
Now is my question how I can compile it back to a .jar file. Normaly I used maven to build the plugins. But because it isn't a maven project this doesn't work.

I tried creating the jar with:

jar cvf plugin.jar .

but this gives me the error Cannot find main class


问:
"Permission denied collect2.exe: error: ld returned 1 exit status" Error when using #include<openssl/evp.h> in VSCode
So I installed OpenSSL directly following the instructions in the install.txt file you get when cloning the git repository. It installed it seemingly witout issues and is located in C:/Program Files/OpenSSL and C:/Program Files(x86)/OpenSSL. Inside each of those there are 4 folders: bin, html, include, lib.

In VSCode I'm using the code runner extension with the following command:
g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" "C:/Program Files/OpenSSL/include" simple_functions.cpp -o simple_functions
the "C:/Users/Batres/vcpkg/installed/x86-windows/include" is a different library called XTensor, which works completely fine as I have tested the code without OpenSSL and it outputs the correct results with no problem. This is the code I'm using, although I doubt it's relevant since it seems to be a complier issue.

```<code>#include <cmath>
#include <iomanip>
#include <cstddef>
#include "xtensor.hpp"
#include <functional>
#include <string>
#include <typeinfo>
#include <vector>
#include <regex>
#include <array>
#include <algorithm>
#include <openssl/sha.h>
#include <openssl/evp.h>

/*
def hash_string(string):
    # Truncating at 16 bytes for cleanliness
    hasher = hashlib.sha256(string.encode())
    return hasher.hexdigest()[:16]
    */
std::string hash_string(std::string string) {
    // Truncating at 16 bytes for cleanliness
    std::array<unsigned char, SHA256_DIGEST_LENGTH> hash;
    std::array<unsigned char, SHA256_DIGEST_LENGTH>::iterator it;

    EVP_MD_CTX* ctx = EVP_MD_CTX_new();
    EVP_DigestInit_ex(ctx, EVP_sha256(), NULL);
    EVP_DigestUpdate(ctx, string.c_str(), string.size());
    EVP_DigestFinal_ex(ctx, hash.data(), NULL);

    // Convert the hash to a hexadecimal string
    std::stringstream ss;
    for (it = hash.begin(); it != hash.end(); it++) {
        ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*it);
    }
    return ss.str().substr(0, 16);
}

int main(){
    double a = gen_choose(2,5);
    std::string input = "Hello, world!";
    std::string output = hash_string(input);
    std::cout << std::setprecision(16) << output << std::endl;
    return 0;
}
</code>```

Ignore all the other #includes, they are for different functions that work with no issue. As you can probably see I have some python code commented above my C++ code. Thats simply because it's a function I tried transalting using ChatGPT, but that's not relevant to the error.

This is the line for C++ settings in code-runner.executorMap:
"cpp": "cd $dir && g++ -I \"C:/Users/Batres/vcpkg/installed/x86-windows/include\" \"C:/Program Files/OpenSSL/lib\" $fileName -o $fileNameWithoutExt -lssl && $dir$fileNameWithoutExt"

My compiler is mingw and I'm on Windows 11. I also don't have any antivirus aside from Windows Defender and I've added the library to the exceptions list as well as ld.exe.

I have also tried these commands, all yeilding the same error. I have also tried running all the same commands through a terminal with admin priviliges and it gives the same error. I even copied the folder to a different directory inside my /Documents/ folder and it still didn't help.g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" "C:/Program Files (x86)/OpenSSL/include" simple_functions.cpp -o simple_functions
and
g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" -L "C:/Program Files/OpenSSL/lib" simple_functions.cpp -o simple_functions -lssl
This last one returns a different error. Insted of being acces denied it seems like none of the functions or variables that I call inside my code are recognised, so this is the type of error: undefined reference to 'EVP_MD_CTX_new', or any other functions or variables I call.

The weird thing is that even though it says access denied when compliling, Intellisense can acess the files just fine, I can right click on the functions and "Go to Definition" and it takes me to my C:/Program Files/OpenSSL/include/openssl/ folder.

If anyone knows how to fix the error I would be very thankful.

Body:
So I installed OpenSSL directly following the instructions in the install.txt file you get when cloning the git repository. It installed it seemingly witout issues and is located in C:/Program Files/OpenSSL and C:/Program Files(x86)/OpenSSL. Inside each of those there are 4 folders: bin, html, include, lib.

In VSCode I'm using the code runner extension with the following command:
g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" "C:/Program Files/OpenSSL/include" simple_functions.cpp -o simple_functions
the "C:/Users/Batres/vcpkg/installed/x86-windows/include" is a different library called XTensor, which works completely fine as I have tested the code without OpenSSL and it outputs the correct results with no problem. This is the code I'm using, although I doubt it's relevant since it seems to be a complier issue.

#include <cmath>
#include <iomanip>
#include <cstddef>
#include "xtensor.hpp"
#include <functional>
#include <string>
#include <typeinfo>
#include <vector>
#include <regex>
#include <array>
#include <algorithm>
#include <openssl/sha.h>
#include <openssl/evp.h>

/*
def hash_string(string):
    # Truncating at 16 bytes for cleanliness
    hasher = hashlib.sha256(string.encode())
    return hasher.hexdigest()[:16]
    */
std::string hash_string(std::string string) {
    // Truncating at 16 bytes for cleanliness
    std::array<unsigned char, SHA256_DIGEST_LENGTH> hash;
    std::array<unsigned char, SHA256_DIGEST_LENGTH>::iterator it;

    EVP_MD_CTX* ctx = EVP_MD_CTX_new();
    EVP_DigestInit_ex(ctx, EVP_sha256(), NULL);
    EVP_DigestUpdate(ctx, string.c_str(), string.size());
    EVP_DigestFinal_ex(ctx, hash.data(), NULL);

    // Convert the hash to a hexadecimal string
    std::stringstream ss;
    for (it = hash.begin(); it != hash.end(); it++) {
        ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*it);
    }
    return ss.str().substr(0, 16);
}

int main(){
    double a = gen_choose(2,5);
    std::string input = "Hello, world!";
    std::string output = hash_string(input);
    std::cout << std::setprecision(16) << output << std::endl;
    return 0;
}

Ignore all the other #includes, they are for different functions that work with no issue. As you can probably see I have some python code commented above my C++ code. Thats simply because it's a function I tried transalting using ChatGPT, but that's not relevant to the error.

This is the line for C++ settings in code-runner.executorMap:
"cpp": "cd $dir && g++ -I \"C:/Users/Batres/vcpkg/installed/x86-windows/include\" \"C:/Program Files/OpenSSL/lib\" $fileName -o $fileNameWithoutExt -lssl && $dir$fileNameWithoutExt"

My compiler is mingw and I'm on Windows 11. I also don't have any antivirus aside from Windows Defender and I've added the library to the exceptions list as well as ld.exe.

I have also tried these commands, all yeilding the same error. I have also tried running all the same commands through a terminal with admin priviliges and it gives the same error. I even copied the folder to a different directory inside my /Documents/ folder and it still didn't help.g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" "C:/Program Files (x86)/OpenSSL/include" simple_functions.cpp -o simple_functions
and
g++ -I "C:/Users/Batres/vcpkg/installed/x86-windows/include" -L "C:/Program Files/OpenSSL/lib" simple_functions.cpp -o simple_functions -lssl
This last one returns a different error. Insted of being acces denied it seems like none of the functions or variables that I call inside my code are recognised, so this is the type of error: undefined reference to 'EVP_MD_CTX_new', or any other functions or variables I call.

The weird thing is that even though it says access denied when compliling, Intellisense can acess the files just fine, I can right click on the functions and "Go to Definition" and it takes me to my C:/Program Files/OpenSSL/include/openssl/ folder.

If anyone knows how to fix the error I would be very thankful.


问:
undefined reference to raspicam
i have  faced some error in camera initialization in geany compiler</p>
```<code>g++ $(pkg-config opencv4 --cflags --libs) -o g++ $(pkg-config raspicam --cflags --libs) -o cameratest cameratest.cpp (in directory: /home/pi/Desktop)
/usr/bin/ld: /tmp/cc3JiNr2.o: in function `main':
cameratest.cpp:(.[text+0x14): undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x3c): undefined reference to `raspicam::RaspiCam_Cv::open()'
/usr/bin/ld: cameratest.cpp:(.text+0x9c): undefined reference to `raspicam::RaspiCam_Cv::getId[abi:cxx11]() const'
/usr/bin/ld: cameratest.cpp:(.text+0xd8): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x108): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
collect2: error: ld returned 1 exit status
Compilation failed.
</code>```

Title: undefined reference to raspicam

Body:
i have  faced some error in camera initialization in geany compiler

g++ $(pkg-config opencv4 --cflags --libs) -o g++ $(pkg-config raspicam --cflags --libs) -o cameratest cameratest.cpp (in directory: /home/pi/Desktop)
/usr/bin/ld: /tmp/cc3JiNr2.o: in function `main':
cameratest.cpp:(.[text+0x14): undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x3c): undefined reference to `raspicam::RaspiCam_Cv::open()'
/usr/bin/ld: cameratest.cpp:(.text+0x9c): undefined reference to `raspicam::RaspiCam_Cv::getId[abi:cxx11]() const'
/usr/bin/ld: cameratest.cpp:(.text+0xd8): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
/usr/bin/ld: cameratest.cpp:(.text+0x108): undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
collect2: error: ld returned 1 exit status
Compilation failed.


问:
Creating a directory in memory python
I am trying tp Create a directory in memory in python, zip it and return it as bytes.

I have used the following tools:

```<code>def some_func(data):
   some_large_number = 10000000000000000000000000
   f = tempfile.SpooledTemporaryFile(max_size = some_large_number, mode = 'w+b'. dir = 'temp/')

   with f as file:
      the_directory = data.to_directory()
      a = shutil.make_archive(file, 'zip', the_directory)
      return pickle.dumps(a)

</code>```

However, I get the following error message: TypeError: Expected str, bytes, or os.Pathlike object, not spooledTemporaryFile

I have also tries 'return io.BytesIO(a)' and 'io.StringIO(a)' yet get the same error message. Not sure how to return the object in the approptiate type instead of spooledTemporaryFile?

I also tried the following:

```<code>def some_func(data):
   some_large_number = 10000000000000000000000000
   f = tempfile.SpooledTemporaryFile(max_size = some_large_number, mode = 'w+b'. dir = 'temp/')

   with f as file:
      the_directory = data.to_directory()
      a = shutil.make_archive('final', 'zip', io.BytesIO(the_directory))
      return pickle.dumps(a)

</code>```

and got the following error: TypeError: A bytes-like object is required not zarr_store

Note: the_director is a Zarr_store type object but I thought calling io.BytesIO() converts that to bytes?

Title: Creating a directory in memory python

Body:
I am trying tp Create a directory in memory in python, zip it and return it as bytes.

I have used the following tools:

def some_func(data):
   some_large_number = 10000000000000000000000000
   f = tempfile.SpooledTemporaryFile(max_size = some_large_number, mode = 'w+b'. dir = 'temp/')

   with f as file:
      the_directory = data.to_directory()
      a = shutil.make_archive(file, 'zip', the_directory)
      return pickle.dumps(a)

However, I get the following error message: TypeError: Expected str, bytes, or os.Pathlike object, not spooledTemporaryFile

I have also tries 'return io.BytesIO(a)' and 'io.StringIO(a)' yet get the same error message. Not sure how to return the object in the approptiate type instead of spooledTemporaryFile?

I also tried the following:

def some_func(data):
   some_large_number = 10000000000000000000000000
   f = tempfile.SpooledTemporaryFile(max_size = some_large_number, mode = 'w+b'. dir = 'temp/')

   with f as file:
      the_directory = data.to_directory()
      a = shutil.make_archive('final', 'zip', io.BytesIO(the_directory))
      return pickle.dumps(a)

and got the following error: TypeError: A bytes-like object is required not zarr_store

Note: the_director is a Zarr_store type object but I thought calling io.BytesIO() converts that to bytes?


问:
vue-test-utils - Memory Leak with shallowMount / mount

Subject of the issue

Seeing a 2MB heap size increase after each test using shallowMount / mount.

Steps to reproduce

Run this command with the below setup:
./node_modules/.bin/jest -- "DummyTest-test.js"

Vue Version 2.7.10

Vue Test Utils Version 1.3.3

Jest Version 29.0.3

Node Version 14.20.0

vue/vue2-jest Version 28.1.0

DummyTest-test.js

```<code>import { shallowMount } from "@vue/test-utils";
import DummyComponent from "../DummyComponent.vue";

let iterations = [...Array(9999).keys()];
let wrapper;
let heap;

afterAll(() => {
  iterations = null;
});

afterEach(() => {
  wrapper.destroy();
  wrapper = null;
  heap = null;
});

it.each(iterations)(`Test`, () => {
  wrapper = shallowMount(DummyComponent);
  heap = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2);
  console.log(`Heap Size: ${heap} MB`);
  expect(true).toBe(true);
});

</code>```

DummyComponent.vue

```<code><template>
  <div>
    <p>Hi</p>
  </div>
</template>

<script>
export default {
  name: "DummyComponent",
};
</script>

</code>```

jest.config.js

```<code>module.exports = {
  testEnvironment: "jsdom",
  transform: {
    "^.+\\.js$": "babel-jest",
    "^.+\\.vue$": "@vue/vue2-jest",
  },
};
</code>```

Expected behavior

Heap Size should remain consistent after each iteration of the test.

Actual behavior

Seeing a 2MB memory leak.
0.2MB of the leak looks to be coming from the usage of console.log, but the rest of the leak is coming from the mounting step.

Attempted Solutions

I have posted this same question on the GitHub Issues page.

Changing node versions (12, 16, 18) did not resolve the issue.

This is a Vue 2 project, so I cannot use vue-test-utils v2. However, I did a brief test on Vue 3 with Vue Test Utils v2, and it looked the issue was still present.

Looking for help on what to try next, or if others are experiencing the same issue.

I did see this StackOverflow post from 4 years ago, but I am using wrapper.destroy() and wrapper = null after each test and the issue is still present.

To prevent CI from grinding to a halt, I'm using the workerIdleMemoryLimit option from the latest version of Jest as a band-aid.

Body:
Subject of the issue

Seeing a 2MB heap size increase after each test using shallowMount / mount.

Steps to reproduce

Run this command with the below setup:
./node_modules/.bin/jest -- "DummyTest-test.js"

Vue Version 2.7.10

Vue Test Utils Version 1.3.3

Jest Version 29.0.3

Node Version 14.20.0

vue/vue2-jest Version 28.1.0

DummyTest-test.js

import { shallowMount } from "@vue/test-utils";
import DummyComponent from "../DummyComponent.vue";

let iterations = [...Array(9999).keys()];
let wrapper;
let heap;

afterAll(() => {
  iterations = null;
});

afterEach(() => {
  wrapper.destroy();
  wrapper = null;
  heap = null;
});

it.each(iterations)(`Test`, () => {
  wrapper = shallowMount(DummyComponent);
  heap = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2);
  console.log(`Heap Size: ${heap} MB`);
  expect(true).toBe(true);
});

DummyComponent.vue

<template>

Hi

</template>

jest.config.js

module.exports = {
  testEnvironment: "jsdom",
  transform: {
    "^.+\\.js$": "babel-jest",
    "^.+\\.vue$": "@vue/vue2-jest",
  },
};

Expected behavior

Heap Size should remain consistent after each iteration of the test.

Actual behavior

Seeing a 2MB memory leak.
0.2MB of the leak looks to be coming from the usage of console.log, but the rest of the leak is coming from the mounting step.

Attempted Solutions

I have posted this same question on the GitHub Issues page.

Changing node versions (12, 16, 18) did not resolve the issue.

This is a Vue 2 project, so I cannot use vue-test-utils v2. However, I did a brief test on Vue 3 with Vue Test Utils v2, and it looked the issue was still present.

Looking for help on what to try next, or if others are experiencing the same issue.

I did see this StackOverflow post from 4 years ago, but I am using wrapper.destroy() and wrapper = null after each test and the issue is still present.

To prevent CI from grinding to a halt, I'm using the workerIdleMemoryLimit option from the latest version of Jest as a band-aid.


问:
How do I find Cumulative Updates using the module PSWindowsUpdate?
When listing available updates from our local WSUS using PSWindowsUpdate v2.2.0.2, I can't see any of the cumulative patches that's already been downloaded and have a Pending Install.

```<code>Get-WUList
</code>```

The cumulative updates are actually displayed once. But after upgrading using the module, they are still displayed in the GUI.

Body:
When listing available updates from our local WSUS using PSWindowsUpdate v2.2.0.2, I can't see any of the cumulative patches that's already been downloaded and have a Pending Install.

Get-WUList

The cumulative updates are actually displayed once. But after upgrading using the module, they are still displayed in the GUI.


问:
Get selected text from Chrome PDF viewer, `getSelection.toString()` always returns empty string
I have a simple HTML page with a button, and an iframe displaying a PDF file. When the button is clicked, I need to get the selected text in the PDF if any, and store it in a variable.

So far I have tried options from this question, among others. However it seems that getSelection.toString() is always returning an empty string.

By the way I am using Chrome with its default PDF viewer. Is there a way to achieve the above?

My code so far:

$(document).ready(function() {

  $("#btn-get-selection").on("click", function(e) {
    var iframe = document.getElementById('iframe');
    var idoc = iframe.contentDocument || iframe.contentWindow.document;
    var text = idoc.getSelection().toString();

    //always getting empty string
    console.log(text);
  })
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button id="btn-get-selection" class="btn btn-primary">Get Selection</button>

<iframe id="iframe" src="sample.pdf" width="100%" height="500" frameborder="0"></iframe></code>```

Current output:

Edit:

Using PDFjs instead of the Chrome default pdf viewer, the code works. A quick way to get PDFjs running can be found here.

Body:
I have a simple HTML page with a button, and an iframe displaying a PDF file. When the button is clicked, I need to get the selected text in the PDF if any, and store it in a variable.

So far I have tried options from this question, among others. However it seems that getSelection.toString() is always returning an empty string.

By the way I am using Chrome with its default PDF viewer. Is there a way to achieve the above?

My code so far:

$(document).ready(function() {

  $("#btn-get-selection").on("click", function(e) {
    var iframe = document.getElementById('iframe');
    var idoc = iframe.contentDocument || iframe.contentWindow.document;
    var text = idoc.getSelection().toString();

    //always getting empty string
    console.log(text);
  })
});

<button id="btn-get-selection" class="btn btn-primary">Get Selection</button>

Current output:

Edit:

Using PDFjs instead of the Chrome default pdf viewer, the code works. A quick way to get PDFjs running can be found here.


问:
Unity Surface Shader Texture Moving When Object Moves
In Unity I have modified a cube surface shader that works properly while the associated object is stationary, but when the object is moved the texture is moved on the object. I would like the texture to not move if the object moves or ideally even if vertices of the object are moved around at runtime. This is a gif created during runtime of what happens when the object is stationary vs moving:
GiphyLink

This is the shader code I've been working with (this is the code used in the gif that I linked above):

```<code>"CShader" {
        Properties{
        _CubeMap("Cube Map", Cube) = "white" {}
        _CubeMap2("Cube Map 2", Cube) = "white" {}
        _Color("Color", Color) = (1,1,1,1)
        _Color3("Color 1", Color) = (1,1,1,1)
        _Color4("Color 2", Color) = (1,1,1,1)
        _Blend("Texture Blend", Range(0,1)) = 0.0
        _Glossiness("Smoothness", Range(0,1)) = 0.0
        _Metallic("Metallic", Range(0,1)) = 0.0
        }
            SubShader{
              Tags { "RenderType" = "Fade" }
              CGPROGRAM
              #pragma target 4.5
              #pragma surface surf Standard alpha:fade vertex:vert
              struct Input {
                  float2 uv_CubeMap;
                  float3 customColor;
              };

        fixed4 _Color3;
        fixed4 _Color4;
        half _Blend;
        half _Glossiness;
        half _Metallic;

              samplerCUBE _CubeMap;
              samplerCUBE _CubeMap2;

              void vert(inout appdata_full v, out Input oo) {
                  UNITY_INITIALIZE_OUTPUT(Input, oo);
                  oo.customColor = v.vertex.xyz;
              }

              void surf(Input INN, inout SurfaceOutputStandard oo) {
                  fixed4 d = texCUBE(_CubeMap2, INN.customColor) * _Color3;
                  d = lerp(d, texCUBE(_CubeMap, INN.customColor) * _Color4, 1 / (1 + exp(100 * (-(INN.uv_CubeMap.y)))));

                  oo.Albedo = d.rgb;
                  oo.Metallic = _Metallic;
                  oo.Smoothness = _Glossiness;
                  oo.Alpha = d.a;
              }
              ENDCG
        }
            Fallback "Diffuse"
</code>```

I've tried many things including setting vertices in c# script and passing them to the shader but nothing has worked so far likely because I've coded it wrong or had the wrong procedure.
Any help would be greatly appreciated, Thank you.

Body:
In Unity I have modified a cube surface shader that works properly while the associated object is stationary, but when the object is moved the texture is moved on the object. I would like the texture to not move if the object moves or ideally even if vertices of the object are moved around at runtime. This is a gif created during runtime of what happens when the object is stationary vs moving:
GiphyLink

This is the shader code I've been working with (this is the code used in the gif that I linked above):

"CShader" {
        Properties{
        _CubeMap("Cube Map", Cube) = "white" {}
        _CubeMap2("Cube Map 2", Cube) = "white" {}
        _Color("Color", Color) = (1,1,1,1)
        _Color3("Color 1", Color) = (1,1,1,1)
        _Color4("Color 2", Color) = (1,1,1,1)
        _Blend("Texture Blend", Range(0,1)) = 0.0
        _Glossiness("Smoothness", Range(0,1)) = 0.0
        _Metallic("Metallic", Range(0,1)) = 0.0
        }
            SubShader{
              Tags { "RenderType" = "Fade" }
              CGPROGRAM
              #pragma target 4.5
              #pragma surface surf Standard alpha:fade vertex:vert
              struct Input {
                  float2 uv_CubeMap;
                  float3 customColor;
              };

        fixed4 _Color3;
        fixed4 _Color4;
        half _Blend;
        half _Glossiness;
        half _Metallic;

              samplerCUBE _CubeMap;
              samplerCUBE _CubeMap2;

              void vert(inout appdata_full v, out Input oo) {
                  UNITY_INITIALIZE_OUTPUT(Input, oo);
                  oo.customColor = v.vertex.xyz;
              }

              void surf(Input INN, inout SurfaceOutputStandard oo) {
                  fixed4 d = texCUBE(_CubeMap2, INN.customColor) * _Color3;
                  d = lerp(d, texCUBE(_CubeMap, INN.customColor) * _Color4, 1 / (1 + exp(100 * (-(INN.uv_CubeMap.y)))));

                  oo.Albedo = d.rgb;
                  oo.Metallic = _Metallic;
                  oo.Smoothness = _Glossiness;
                  oo.Alpha = d.a;
              }
              ENDCG
        }
            Fallback "Diffuse"

I've tried many things including setting vertices in c# script and passing them to the shader but nothing has worked so far likely because I've coded it wrong or had the wrong procedure.
Any help would be greatly appreciated, Thank you.


问:
Why does SDO_AGGR_LRS_CONCAT_3D clip (zero out) the third dimension in the resulting geometry?
Doing:

```<code>        SELECT SDO_AGGR_LRS_CONCAT_3D(SDOAGGRTYPE(
            SDO_GEOMETRY(z.SDO_GTYPE, z.SDO_SRID, z.SDO_POINT, z.SDO_ELEM_INFO, z.SDO_ORDINATES),
            0.005))
        into l_geoloc
        from (select * from TABLE(Pi_geom_array)) z;
</code>```

Pi_geom_array is series of rows:

MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117985, 41.6482888766313, 588.16578218591, 506.44231, ...)

MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117988, 41.6482888766318, 588.16578218598, 506.44238, ...)

etc...

l_geoloc is:
MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117985, 41.6482888766313, 0, 506.44231, -87.5471437282998, 41.6483175668031, 0, 506.44531, ...)

where the SDO_ORDINATE_ARRAY is correct union of input SDO_ORDINATE_ARRAY's.
But where the z index are all zeroed out.

Why is this occurring? There doesn't seem to be lot of documentation out there on oracle spatial functions. Is there a setting somewhere else, or how the function is being called that's causing this? Or is there an error with the SDO_AGGR_LRS_CONCAT_3D 3d function perhaps..?

New to oracle spatial...

The third dimension i.e. z values (since this is 3D version of the function) should not be zeroed out...

Body:
Doing:

        SELECT SDO_AGGR_LRS_CONCAT_3D(SDOAGGRTYPE(
            SDO_GEOMETRY(z.SDO_GTYPE, z.SDO_SRID, z.SDO_POINT, z.SDO_ELEM_INFO, z.SDO_ORDINATES),
            0.005))
        into l_geoloc
        from (select * from TABLE(Pi_geom_array)) z;

Pi_geom_array is series of rows:

MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117985, 41.6482888766313, 588.16578218591, 506.44231, ...)

MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117988, 41.6482888766318, 588.16578218598, 506.44238, ...)

etc...

l_geoloc is:
MDSYS.SDO_GEOMETRY(4402, 4326, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 2, 1), MDSYS.SDO_ORDINATE_ARRAY(-87.5471018117985, 41.6482888766313, 0, 506.44231, -87.5471437282998, 41.6483175668031, 0, 506.44531, ...)

where the SDO_ORDINATE_ARRAY is correct union of input SDO_ORDINATE_ARRAY's.
But where the z index are all zeroed out.

Why is this occurring? There doesn't seem to be lot of documentation out there on oracle spatial functions. Is there a setting somewhere else, or how the function is being called that's causing this? Or is there an error with the SDO_AGGR_LRS_CONCAT_3D 3d function perhaps..?

New to oracle spatial...

The third dimension i.e. z values (since this is 3D version of the function) should not be zeroed out...


问:
How to listen is context menu open in vscode extension api
I want to change context menu items in my vscode extension dynamically.

So, when the user triggers right-click I want to make some checks and generate some items in the context menu.

How can I do this?


问:
On Creating Random Walkers in 3D elements of 3 different 4D arrays
I am currently working with 2 different 4D arrays (x,y,z,l) containing voxel data of a brain scan (x,y,z) and a label (l). Every voxel holds the probability of that voxel to contain that label.

The first array, represents the brain tissue in 3D space, has 3 labels, white matter, grey matter, and the CSF. My only area of interest is grey matter.

The second aray, represents a pre defined probability distribution of 360 labels, all of which correspond to a portion of the grey matter.

The "shape" of the probability distributions are in 3D is similar, but not exactly the same. But they are already aligned in 3D space with a combination of rigid and affine transformations, and it is "as similar as possible".

What I want to do, is to map this 360 3D elements, onto the second 3D element of first array and get a best fit.

I am not an expert in machine learning, so I tried to come up with my own idea;

Pick every voxel from grey matter probability map

Generate 1000 random walks from each point.

Which territory is walked most? - Label the point

What I explained above, I havent been able to code yet, therefore I am unable to offer any code.
I am still trying to create "the random walking sampler" but I quickly realized I need a lot of nested for loops work on a lot of different 3D arrays (1363 to be exact).

Is there a better way to do it?

Is there a better way to do this?