โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayRecent Questions - Stack Overflow

VSCode, There is no "\n" for the mouse over the function

IN VSCode, I used the Doxygen Generator Documentation plug-in to generate the following comments in a functional method. enter image description here

But when I hovered over the function, there was no newline in the function tip about brief enter image description here

This makes me very uncomfortable.This makes me very uncomfortable.

In addition,I'm not sure if Breif is the problem

enter image description here

enter image description here

enter image description here

enter image description here

Hope how to correct this phenomenon

Error Encountered an issue when uploading and creating pre-authenticated URLs. process is holding on

We are using OCI Java SDK to integrate Object Storage with our services and facing issues of thread holding. Each call is holding one thread. For example, if we make a call to a pre-authenticated URL with five files, it holds five threads. This continuous increase in thread count results in the holding of system-native threads.

Problematic methods : โ€ข createPreauthenticatedRequest.getPreauthenticatedRequest(); โ€ข getObjectStorage().putObject(putObjectRequest);

Any suggestions where i may be going wrong

Tried the latest SDKs and Java versions but the problem exists

LLVM: Builtin DEF corresponding to RVV vector

I have a question regarding how to build a builtin type for my custom instruction. The instruction itself has a VR (RISCV vector register) type parameter. The corresponding intrinsic type is llvm_anyvector_ty. However I could not search any type to define it in TARGET_BUILTIN.

For example, in BuiltinsRISCV.def, we could find something like:

TARGET_BUILTIN(__builtin_riscv_sgcfgsatu, "vUWi", "nc", "xsgmat,64bit")

It defines return type as void and the only paramter as unsigned long. But what key word corresponds to the parameter types of RVV, like __rvv_float32m1_t?

PS: it seems RVVBuiltin provides the parsing method, but would it be possible to define them without assistance from RVVBuiltin?

Thanks!

I tried to use "V16f" as the keyword string, like

TARGET_BUILTIN(__builtin_riscv_sgmovtv, "vV4fUWi", "nc", "xsgmat,64bit")

but while compiling the following code, LLVM reports: test.c:47:29: error: passing '__rvv_float32m1_t' to parameter of incompatible type 'attribute((vector_size(16 * sizeof(float)))) float' (vector of 16 'float' values)

__rvv_float32m1_t vec_a = __riscv_vle32_v_f32m1(ptr_a, vl);
__builtin_riscv_sgmovtv(vec_a, 0xFFA);

How to close a python program anytime a key is pressed?

I was trying to make a bot that farms microsoft points and i wanted the macro to stop anytime i pressed the "Esc" key I was using keyboard module to check if esc key was being pressed and close the program if the key was being pressed, but i was also using the time.sleep() function to wait some time for the weppage to load so that i can get points, but I found that if i press "Esc" while the program is on the time.sleep() part then the program doesnt end. Please help.

import webbrowser,time,random,pyautogui,requests,keyboard
def close():
    with pyautogui.hold("Ctrl"):
            pyautogui.press("w")

def generate():
    with open("wow","r",encoding="utf-8") as f:
        p = eval(f.read())
        search = random.choice(p)+"+"+random.choice(p)+"+"+random.choice(p)
    with open("wow1","r",encoding="utf-8") as f:
        p = eval(f.read())
        c = random.choice(p)
        url = c.replace(" ",search)
    return url
def links():
    while ():
        url = generate()
        webbrowser.open(url)
        webbrowser.open("https://rewards.bing.com/pointsbreakdown")
        requests.get("https://rewards.bing.com/pointsbreakdown")
        ''' try:
                no = requests.get(url=points)
        except Exception as err:
            if type(err) == requests.exceptions.ReadTimeout:
                print("Internet connection issues, Retrying ...")
            else:
                print(err)
            continue
        print(no)'''
        time.sleep(3)
        for i in range(2):
            close()
webbrowser.open("example.com")
time.sleep(0.2)     
links()
close()

i was hoping to see if anyone could tell me if there were some alternative modules or some alternative method of doing this.

Throw an thisNullReferenceException when I perform a static code scan of java code

This is my first time to use the software. When I selected the java project to perform the scan, the program did not respond. Here is the log information. enter image description here

json
06/05/2024 13:32:00,366 [5] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.6057167 [Unspecified] - End loading sources from project original location to local destination location : 'C:\Users\Administrator\AppData\Local\Checkmarx\Checkmarx SAST\CxAuditSrc\base-user-server'  
06/05/2024 13:32:00,386 [5] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.6263276 [Unspecified] - ProjectLoadingThread -- Finish  
06/05/2024 13:32:00,692 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9318138 [Unspecified] - ProjectLoading_Shown -- Exception  
06/05/2024 13:32:00,693 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9324926 [Unspecified] - ProjectLoading_Shown: System.ArgumentOutOfRangeException: InvalidArgument=โ€œ-1โ€็š„ๅ€ผๅฏนไบŽโ€œindexโ€ๆ— ๆ•ˆใ€‚
ๅ‚ๆ•ฐๅ: index
   ๅœจ System.Windows.Forms.ListView.ListViewItemCollection.get_Item(Int32 index)
   ๅœจ CxAudit.ProjectLoading.ProjectLoading_Shown(Object sender, EventArgs e)  
06/05/2024 13:32:00,693 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9325402 [Unspecified] - ProjectLoading_Shown -- Finish  
06/05/2024 13:32:00,699 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9393617 [Unspecified] - LoadingProjectCancellation: System.NullReferenceException: ๆœชๅฐ†ๅฏน่ฑกๅผ•็”จ่ฎพ็ฝฎๅˆฐๅฏน่ฑก็š„ๅฎžไพ‹ใ€‚
   ๅœจ CxAudit.FormsMetadata.AuditForm.AuditFormMetadata.LoadingProjectCancellation()  
06/05/2024 13:32:00,700 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9394695 [Unspecified] - Cancel Loading Project  
06/05/2024 13:32:00,700 [MainThread_CxAudit] INFO  Available memory: 3664 Used memory: 431 Elapsed Time: 00:00:25.9397075 [Unspecified] - Clear: System.NullReferenceException: ๆœชๅฐ†ๅฏน่ฑกๅผ•็”จ่ฎพ็ฝฎๅˆฐๅฏน่ฑก็š„ๅฎžไพ‹ใ€‚
   ๅœจ CxAudit.CxAuditProject.Clear()  

version info:

Product version: 9.5.0.0-390131
Available memory: 3772Mb
Used memory: 381Mb
OS: Microsoft Windows NT 10.0.19045.0
Product: Checkmarx SAST Engine
-   Main Version: 9.5.0.100
-   Hotfix Version: 0
-   Path: F:\CxSAST\Checkmarx\Checkmarx Engine Service\
Product: Checkmarx SAST Audit
-   Main Version: 9.5.0.100
-   Hotfix Version: 0
-   Path: F:\CxSAST\Checkmarx\Checkmarx Audit\
Current Product dll's version list:
___________________________________
Assembly name:                 File version:
ASP.dll                        9.5.0.0-390131
CSharp.dll                     9.5.0.0-390131
DataCollections.dll            9.5.0.0-390131
EngineFacade.dll               9.5.0.0-390131
Flowgraphs.dll                 9.5.0.0-390131
Plugin.dll                     9.5.0.0-390131
Query.dll                      9.5.0.0-390131
CxWrm.dll                      9.5.0.0-390131
CxSyntaxEdit.dll               9.5.0.0-390131
QWhale.Common.dll              2.3.0.0
QWhale.Editor.dll              2.3.0.0
QWhale.Syntax.dll              2.3.0.0
QWhale.Syntax.Parsers.dll      2.3.0.0

I have tried to scan for another java project and will report the same error.

[iOS]FCMใ‚’็”จใ„ใŸใƒ—ใƒƒใ‚ทใƒฅ้€š็Ÿฅใ‚’ใ€ไปฅๅ‰ใฎ HTTP ใ‹ใ‚‰ HTTP v1 ใซ็งป่กŒใ™ใ‚‹ๆ–นๆณ•ใซใคใ„ใฆ [closed]

ไปฅๅ‰ใฎ HTTP ใ‹ใ‚‰ HTTP v1 ใซ็งป่กŒใ™ใ‚‹ใŸใ‚ใซใ€ใ‚ตใƒผใƒใƒผใ‚ญใƒผใงใฏใชใใ€OAuth 2.0 ใ‚ขใ‚ฏใ‚ปใ‚น ใƒˆใƒผใ‚ฏใƒณใŒๅฟ…่ฆใซใชใ‚Šใพใ—ใŸใ€‚ ใŸใ ใ€ใ“ใฎๅ–ๅพ—ๆ–นๆณ•ใŒใ‚ใ‹ใ‚Šใพใ›ใ‚“ใ€‚

ๆ—ง Authorization: key=AIzaSyZ-1u...0GBYzPu7Udno5aA ๆ–ฐ๏ผˆโ†“ใ“ใ‚Œใ‚’ๅ–ๅพ—ใ—ใŸใ„๏ผ‰ Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA

swiftใงใ‚ณใƒผใƒ‡ใ‚ฃใƒณใ‚ฐใ—ใŸใ„ใฎใงใ™ใŒใ€ใฉใ†ใ—ใŸใ‚‰่‰ฏใ„ใงใ—ใ‚‡ใ†ใ‹๏ผŸ

็ง˜ๅฏ†้ตใ‚’ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰ใ—ใ€OAuth2ใฎใ‚ขใ‚ฏใ‚ปใ‚นใƒˆใƒผใ‚ฏใƒณใ‚’ๅ–ๅพ—ใ—ใ‚ˆใ†ใจใ—ใŸใฎใงใ™ใŒใ€ใ‚ฏใƒฉใ‚คใ‚ขใƒณใƒˆIDใฏใ‚ใฃใฆใ‚‚ใ€ใ‚ฏใƒฉใ‚คใ‚ขใƒณใƒˆใ‚ทใƒผใ‚ฏใƒฌใƒƒใƒˆใฎๆƒ…ๅ ฑใŒใชใใ€ใงใใพใ›ใ‚“ใงใ—ใŸใ€‚

Select parent and only some fields from child in @OneToMany relationships using JPA and Criteria Builder

Implemented one to many relationship and select parent and child I have a onetomany relationship. Using criteria builder, i need to get parent and all related childs but selecting only some fields from each child.

@Entity
@Table(name="transaction_status")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class TransactionStatus implements Serializable {
@Id
@Column(name = "id")
@JsonProperty("id")
public String id;

@SerializedName("status")
public String status;

@Column(name="lastUpdatedDate")
@JsonProperty("lastUpdatedDate")
@SerializedName("lastUpdatedDate")
private Date lastUpdatedDate;

@JsonProperty("generatedAt")
@SerializedName("generatedAt")
@JsonIgnore
private Date generatedAt;

@JsonProperty("invoices")
@SerializedName("invoices")
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name="transactionstatusId",referencedColumnName = "xmlFilename")
private List<InvoiceTransaction> invoiceTransactions = new ArrayList<>();

}

@Entity
@Table(name="invoice_transaction")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor

public class InvoiceTransaction implements Serializable {
    @Column(name = "status", nullable = false)
    @JsonProperty("status")
    @SerializedName("status")
    private String status;
    @Column(name = "originalStatus", nullable = false)
    @JsonProperty("originalStatus")
    @SerializedName("originalStatus")
    private String originalStatus;
    
    @Column(name = "errorMessage")
    @JsonProperty("errorMessage")
    @SerializedName("errorMessage")
    private String errorMessage;

    @Column(name = "generatedAt" )
    @JsonProperty("generatedAt")
    @SerializedName("generatedAt")
    private Date generatedAt;
}

CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<TransactionStatus> cq = builder.createQuery(TransactionStatus.class);
Root<TransactionStatus> rootTrnStatus = cq.from(TransactionStatus.class);
List<TransactionStatus> resultList = entityManager.createQuery(cq).getResultList();

this implementation, gives me list of Transactionstatus objetc with list of its childs. what im seraching to get is: list of Transactionstatus object with list of its childs with olny status and errorMessage fileds. How can i get this result using Crtiteria builder? thank you

recursively change the value of field in mongodb document

I need to change a value of a field in a mongoDB document recursively.

More or less, this is just a find and replace for a value of a field if the field name and the (old) value matches.

Example Document:

{
  "topLevel": {
    "level1": [
      {
        "itemKey": "N-99999",
        "level2": [
          {
            "itemKey": "N-99999",
            "level3": [
              {
                "itemKey": "N-99999"
              },
              {
                "itemKey": "a-4157-637"
              },
              {
                "itemKey": "t-3213-569"
              },
              {
                "itemKey": "s-3984-763"
              },
              {
                "itemKey": "n-5996-963"
              }
            ]
          }
        ]
      }
    ]
  }
}

What I tried, but doesn't work:

func replaceItemKey(ctx context.Context, coll *mongo.Collection, old, new string) (*mongo.UpdateResult, error) {
    filter := bson.D{
        {Key: "toplevel.level1.itemKey", Value: old},
        {Key: "toplevel.level1.level2.itemKey", Value: old},
        {Key: "toplevel.level1.level2.level3.itemKey", Value: old},
    }
 
    update := bson.D{
        {Key: "$set", Value: bson.D{{Key: "toplevel.$[l1]level1.itemKey", Value: new}}},
        {Key: "$set", Value: bson.D{{Key: "toplevel.level1.$[].level2.$[l2].itemKey", Value: new}}},
        {Key: "$set", Value: bson.D{{Key: "toplevel.level1.$[].level2.$[].level3.$[l3].itemKey", Value: new}}},
    }
    
    opts := options.Update().SetArrayFilters(
        options.ArrayFilters{
            Filters: []interface{}{
                bson.D{{Key: "l1.itemKey", Value: bson.D{{Key: "$eq", Value: old}}}},
                bson.D{{Key: "l2.itemKey", Value: bson.D{{Key: "$eq", Value: old}}}},
                bson.D{{Key: "l3.itemKey", Value: bson.D{{Key: "$eq", Value: old}}}},
            },
        },
    )
    
    return coll.UpdateMany(ctx, filter, update, opts)
}



I know this is not recursively at all. It just tries to change the value in 3 levels. Recursively would be better.

I'd prefer to change the value in one statement. Doing it in a statement per level works fine. But I'm not aware on the performance impact if I have to change thousends of documents.

Thanks a lot.

Why does filtering based on a condition results in an empty DataFrame in pandas?

I'm working with a DataFrame in Python using pandas, and I'm trying to apply multiple conditions to filter rows based on temperature values from multiple columns. However, after applying my conditions and using dropna(), I end up with zero rows even though I expect some data to meet these conditions.

The goal is compare with Ambient temp+40 C and if the value is more than this, replace it with NaN. Otherwise, keep the original value.

Here's a sample of my DataFrame and the conditions I'm applying:

data = {
    'Datetime': ['2022-08-04 15:06:00', '2022-08-04 15:07:00', '2022-08-04 15:08:00', 
                 '2022-08-04 15:09:00', '2022-08-04 15:10:00'],
    'Temp1': [53.4, 54.3, 53.7, 54.3, 55.4],
    'Temp2': [57.8, 57.0, 87.0, 57.2, 57.5],
    'Temp3': [59.0, 58.8, 58.7, 59.1, 59.7],
    'Temp4': [46.7, 47.1, 80, 46.9, 47.3],
    'Temp5': [52.8, 53.1, 53.0, 53.1, 53.4],
    'Temp6': [50.1, 69, 50.3, 50.3, 50.6],
    'AmbientTemp': [29.0, 28.8, 28.6, 28.7, 28.9]
}
df1 = pd.DataFrame(data)
df1['Datetime'] = pd.to_datetime(df1['Datetime'])
df1.set_index('Datetime', inplace=True)

Code:

temp_cols = ['Temp1', 'Temp2', 'Temp3', 'Temp4', 'Temp5', 'Temp6']
ambient_col = 'AmbientTemp'

condition = (df1[temp_cols].lt(df1[ambient_col] + 40, axis=0))

filtered_df = df1[condition].dropna()
print(filtered_df.shape)

Response:

(0, 99)

Problem:

Despite expecting valid data that meets the conditions, the resulting DataFrame is empty after applying the filter and dropping NaN values. What could be causing this issue, and how can I correct it?

The same uuid is generated for different objects in Django

When I run a server on localhost I am able to add new objects in my postgre database through the Django admin panel, but only one for every table. When I try to add a second new object, it assigns the same UUID that has already been used. There is an example of model with UUID as primary key:

models.py

from django.db import models
from authuser.models import User
from django.utils import timezone
import uuid

class Thread(models.Model):

    idthread = models.UUIDField(default=uuid.uuid4(), primary_key=True, unique=True)
    date_created = models.DateTimeField(default=timezone.now)
    userid = models.ForeignKey(User, on_delete=models.DO_NOTHING)
    name = models.CharField()

    def __str__(self):
        return self.name

Only after restarting the server will assign a new unique UUID to objects that I would like to add.

Find remaining queens for nqueens problem

As the title says, I have to find the remaining queens for the nqueens problem, but I have not use recursive calls and I have to use stacks and backtracking. Currently I have:

#include <stdio.h>
#include <stdbool.h>

#define MAX_N 11

typedef struct {
    int row;
    int col;
} Queen;

typedef struct {
    int top;
    Queen items[MAX_N];
} Stack;

void initStack(Stack* stack) {
    stack->top = -1;
}

void push(Stack* stack, Queen queen) {
    if (stack->top < MAX_N - 1) {
        stack->top++;
        stack->items[stack->top] = queen;
    }
}

Queen pop(Stack* stack) {
    if (stack->top >= 0) {
        stack->top--;
        return stack->items[stack->top];
    }
    Queen emptyQueen = { -1, -1 }; // Return an invalid queen
    return emptyQueen;
}

// Helper function to check if a queen can be placed at (row, col)
bool isValid(Queen queens[], int numQueens, int row, int col) {
    for (int i = 0; i < numQueens; i++) {
        if (queens[i].row == row || queens[i].col == col ||
            queens[i].row - queens[i].col == row - col ||
            queens[i].row + queens[i].col == row + col) {
            return false; // Queens attack each other
        }
    }
    return true;
}

void solveQueens(int max_queens, Queen* initQs, int numInitQ) {
    Queen queens[MAX_N];
    Stack stack;
    initStack(&stack);

    // Initialize with initial queens
    for (int i = 0; i < numInitQ; i++) {
        queens[i] = initQs[i];
    }

    int numQueens = numInitQ;
    int row = numInitQ; // Start from the next row

    while (numQueens < max_queens) {
        bool found = false;
        for (int col = 0; col < max_queens; col++) {
            if (isValid(queens, numQueens, row, col)) {
                queens[numQueens] = (Queen){ row, col };
                numQueens++;
                found = true;
                break;
            }
        }
        if (!found) {   //backtrack, pop the queen
            queens[numQueens - 1] = pop(&stack);
            numQueens--;
            row = queens[numQueens - 1].row + 1;
            if(numQueens <= numInitQ){  //there are not enough queens in total, therefore no solution
                printf("no solution\n");
                return;
            }
        } else {
            push(&stack, queens[numQueens - 1]);
            row++;
        }
    }

    // Print the solution
    for (int i = 0; i < numQueens; i++) {
        printf("%d %d\n", queens[i].row, queens[i].col);
    }
}

for testing, I have used the main function:

int main() {
    Queen initialQueens[] = { {0, 0} }; // Example initial queens
    int numInitialQueens = 1;
    int maxQueens = 4; // Change this to the board size
    solveQueens(maxQueens, initialQueens, numInitialQueens);
    return 0;
}

Which expectedly prints No Solution. However, when I try to make the board size 5 (setting maxQueens to 5) the function enters an infinite loop. My theory is that this is probably caused by the function finding a valid queen, but the total number of queens is not enough, which causes it to backtrack repeatedly. Don't take my word for the error, I could be way off but it might be a lead. Anyone got any fixes and suggestions?

Overcounting Issue in solution Implementation

I was trying to solve [this][1] question.

I tried to come up with the following approach.

First sort all the numbers then iterate from large to small while doing these steps, Suppose the number we are currently iterating is num. Find how many factors of the number num are there in the array. Suppose it is x, then we have Select at least one factor of num total ways to have the number num as the maximum, also we have the remaining (n-x) numbers, which can give Left numbers other choices.

We multiply these two and get the total ways we will get the number num as our answer. So, for each number a[i](from max to min), we have Final Answer for each array element as contribution to answer.

But I am getting wrong answer in Sample Test Case 3 this way. I think I am overcounting somewhere. Here is my code.

#include <bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define MULTI int _T; cin >> _T; while(_T--)
#define el '\n'
#define yes cout<<"YES"<<el
#define no cout<<"NO"<<el
#define f(i,a,b) for(ll i = a; i <= b; i++)
#define fr(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)(x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> pbds; // find_by_order, 
order_of_key
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 998244353;

ll powmod(ll a, ll b, ll p){
   a %= p;
   if (a == 0) return 0;
   ll product = 1;
   while(b > 0){
   if (b&1){    // you can also use b % 2 == 1
        product *= a;
        product %= p;
        --b;
    }
    a *= a;
    a %= p;
    b /= 2;    // you can also use b >> 1
}
    return product;
}

int main()
{
ios::sync_with_stdio(false);
cin.tie(0);

ll n;
cin>>n;
vector<ll> a(n);
vector<vector<ll>> factor(1e5+1);
vector<ll> b(1e5+1,0),c(1e5+1,0);
f(i,0,n-1)
{
    cin>>a[i];
    ++c[a[i]];
}
sort(all(a));
f(i,1,1e5)
{
    for(int j=i;j<=1e5;j+=i)
    {
        if(c[j] && c[i])
            factor[j].pb(i);
    }
}
ll z =0;
ll ans = 0;
fr(i,n-1,0)
{
    while(i>=1 && a[i]==a[i-1])
    {
        --i;
    }
    ll temp = 0;
    for(auto it:factor[a[i]])
    {
        if(c[it])
        {
            temp+=c[it];
            c[it]=0;
        }
    }
    z+=temp;
    ans = (ans+((powmod(2,temp,mod)-1)*(powmod(2,n-z,mod)))*(a[i]))%mod;
}
cout<<ans<<el;
}

Where am I overcounting?

I will be thankful for any help!

Remove observations within 7 days of each other within specific ID group

I have a pandas dataframe with ID and dates like this:

ID Date
111 16/09/2021
111 14/03/2022
111 18/03/2022
111 21/03/2022
111 22/03/2022
222 27/03/2022
222 30/03/2022
222 4/04/2022
222 6/04/2022
222 13/04/2022

For each ID, I would like to filter the table and remove observations that are within 7 days of each other. But I want to keep the earliest date of the dates that are within 7 days of each other so that each ID will have unique dates that are more than 7 days apart and do not contain other dates in between:

ID Date
111 16/09/2021
111 14/03/2022
111 22/03/2022
222 27/03/2022
222 4/04/2022
222 13/04/2022

I'm quite new to python and pandas dataframe so hoping someone can assist and provide some pointers. There is a similar SO question How do I remove observations within 7 days of each other within a specific ID group? but this was done in R so hoping there is something similar that can be done with Pandas.

lmdb read slow when file amout is a little larger

I installed lmdb from python:

python -m pip install lmdb

Then I write images into it, I have two settings, one is inserting 6800 images, and the other is 10000 images. All the images have size of 1024x2048, and they are in png format, and my memory size is 1T.

Here is part of the code piece with which I read images from it:

  def init_lmdb(self):
        self.env = lmdb.open(
                self.file_root,
                map_size=2**40,
                readonly=True,
                max_readers=512,
                readahead=False,
                )

    def get_bins(self, inds):
        im_bins = []
        with self.env.begin(write=False) as txn:
            for ind in inds:
                impth = self.im_paths[ind]
                im_bin = txn.get(impth)
                im_bins.append(np.frombuffer(im_bin, dtype=np.uint8))
        return im_bins

I used identical code to read from the two lmdb files, I found that the first lmdb with 6800 images needs about 9s to read 6400 images in random order, while the second lmdb with 10000 images requires 16s to read same amount of images in random order.

Would you tell me what is the cause of the difference ?

PS: I do not read images for only once. Actually, I read from only half of the images. For the lmdb with 6800 images, I only read from the 3400 of them. Also, for the lmdb with 10000 images, I only read from the subset of 5000 images. The images are read in random order, and images can be read more than one time. Until the total amount of read reaches 6400, I tested the time.

How do I update the Google Colab Notebook kernel? I am running an old version (0.0.1a2) and I can't update to the current version

I am running an ancient version of the Colab notebook kernel on colab.research.google.com. Iโ€™ve tried everything to update the kernel, but nothing has worked.

I am running version 0.0.1a2 (I think this is an alpha version) while the most recent version is 2.0.6!!!

I would appreciate getting help with this problem as many modules don't work properly with the antiquated notebook.

My futile attempts to update the Colab notebook kernel have consisted of:

  • Trying different browsers.
  • Clearing cache and cookies.
  • Restarting the Colab notebook runtime with GPU and TPU runtimes.
  • Pip installs colab from the notebook.
  • Manually install colab with the colab-0.3.2.tar.gz file. The tarball had a blank file in it.
  • Manually install colab from the Github Repo. That didn't work either.

enter image description here

Hover effect is not applyed in CSS. What is the exact problem?

I am trying to build searchlist for the searchbar and the list should be change color when cursor is placed their and got selected when clicked from list of item shown.

searchlist.jsx:

import React from 'react'
import { FaSearch } from 'react-icons/fa';
import './SearchList.css';

function SearchList({TitleArray,setSearchQuery}) {
  return (
   <>
    <div className="Container_SearchList">
    {
            TitleArray.map(m=>{
                return   <p
                key={m}
                onClick={e=>setSearchQuery(m)}
                className='titleItem'> 
               <FaSearch/>
            {m}
            </p>  
          })
      
        }   
    </div>
    </>
  )
}

export default SearchList;

searchlist.css:

.Container_SearchList {
    background-color: white;
    width: 90.75%;
    position: absolute;
    top:2.7rem;
    height: fit-content;
    z-index: 91;
}

.titleItem {
    margin: 0;
    padding: 0.5rem;
    cursor: pointer;
}

.titleItem div p:hover {
    background-color: rgba(166,202,234,0.516);
}

enter image description here

When cursor is placed on the name, the color should change and the name should get selected

LangChain with OpenAI not return full products in RAG QnA

I used the Python LangChain UnstructuredURLLoader to retrieve all our products on the company website for RAG purposes. The products were on different pages in the company website.

UnstructuredURLLoader was able to retrieve the products in multiple Document objects before they were chunked, embedded and stored in the vector database.

With the OpenAI LLM and RAG module, I asked the AI, "How many products in the company A?" AI replied "There are 11 products. You should check the company website for more info..."

If I asked "Please list all the products in the company A", AI replied the list of the 11 products only.

The problem is, there are more than 11 products. Why can't LLM read and aggregate the products in the Documents to count and to return all of the products?

Is there any context hint or prompt to tell LLM to read and return all products? Is it because of the chunking process?

Why don't local variable initialisation instructions contribute to the executable size as much as global variables do?

The text I am reading says:

Global variables are located in executable image, so using number of global variables will increase the size of executable image.

Questions:

  1. What does 'located in executable image' mean? From what I have read the global variables are located in the 'data' section of the executable. I presume that local variable initialisation instructions are stored in the 'text' section. So why don't the local variable initialisation instructions take up about the same amount of space as the global variables do?

  2. By executable, does it mean here the executable loaded into the memory or the executable that is only on the non-volatile memory? Will the global variables also take up more space for executable that is not loaded into the RAM?

  3. Are there books or concise reading resources I may refer to that will help me with such lower level concepts?

I expected the size of the local variable initialization instructions to take up the same amount of space in executable as global variables do. Consider the following program:

#include <stdlib.h>

int global_var = 10

int main(void){

    int local_var = 20;
    return EXIT_SUCCESS;
}

When converted to machine level executable (assuming its not loaded into memory/not a process), I assume both definition and initialisation of global_var and local_var will be encoded as machine level code, albeit in different sections (data and text) of executable. So why will global_var take up more space?

whilst trying to make a language select for a web im making i get an error that reads [Cannot read properties of null (reading 'addEventListener')]

javascript code (the error code is placed at addEventListener)

const translations = {
    en: {
        text1: "testing"
    },
    no: {
        text1: "testing"
    },
    gm: {
        text1: "testen"
    }
}


const languageSelectop = document.querySelector("LS");

problem being around here

languageSelectop.addEventListener("change", (event) => {
    setLanguage(event.target.value)
})
const setLanguage = (language) => {
    if(language == "no"){
        console.log(language);
    }else if(language == "en"){
        console.log(language)
    }else if(language == "gm"){
        console.log(language)
    }
}

html code (no aperent isues as far as i know)

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Arctic Fox Web - WIP</title>
        <script type="text/javascript" src="js/Language.js"></script>
        
    </head>
    <body>

        <div>
            <select name="" id="LS">
                <option value="en">English</option>
                <option value="no">Norsk</option>
                <option value="gm">Deutsch</option>
            </select>

        </div>

        <div>
            testing
        </div>
        <div>
            testing
        </div>
    
    </body>
</html>

im following a tutorial on yt thus i dont quite know whats wrong if it is needed here is the video Youtube

โŒ
โŒ