on-internet

Measure of feature importance in PCA

I am doing principal component analysis (PCA), and I'd like to find out which features that contribute the most to the result. My intuition is to sum up all the absolute values of the individual contribution of the features to the individual components. import numpy as np from sklearn.decomposition import PCA X = np.array([[-1, -1, 4, 1], [-2, -1, 4, 2], [-3, -2, 4, 3], [1, 1, 4, 4], [2, 1, 4, 5], [3, 2, 4, 6]]) pca = PCA(n_components=0.95, whiten=True, svd_solver='full').fit(X) pca.components_ array([[ 0.71417303, 0.46711713, 0. , 0.52130459], [-0.46602418, -0.23839061, -0. , 0.85205128]]) np

Join the discussion →

How to test Reac Lazy inside an object

At the project I'm working on, there's a few named exports like the object below: export const object = { component: React.lazy(() => import('some-component')) } (They have more properties but I'll just show this one for brevity) The issue When I try to test it using Jest, I can't test inside React.lazy: I tried mocking React.lazy with no success: jest.mock('react', () => ({ lazy: () => { return 'lazy' }, })) describe('Auth route object', () => { it('', () => { expect(auth).toBeDefined() expect(auth[0].component).toBe('lazy') }) }) This returns passed but it keeps complaining about coverage. H

Join the discussion →

How to use in-memory MongoDB with Rails, Mongoid, and Rspec?

On unit or integration testing, I need to be able to use in-memory mongoDB just for convenience. Am I able to do that? I tried searching for solution and there is no tutorial in how to write mongoid.yml to use in-memory. Other than that, can I just use default env inside mongoid.yml rather than writing duplicates for both development and production? It is like moving from development: client: ... production: client: ... into default: &default client: ...

Join the discussion →

How to rename sheet and add value to the name in xlwings

I have a list of sheets and for each sheet I need to SUM float values from the column A and the SUM outcome should be added to the sheet name. For example: Sheet1 --> Sheet1 (123). import xlwings as xw wb = xw.Book(filepath) sheet_names = wb.sheets for x in sheet_names: # missing summary calculation here wb.sheets[x].name = wb.sheets[x] + str('123') # '123' should be the # outcome of the SUM so str(SUM) wb.save() wb.close() xw.App().quit()

Join the discussion →

How to Replace/Overwrite only certain values in Snowflake Table?

I have a Snowflake SQL command in the form of: CREATE TASK REPLACE_CERTAIN_ROWS WAREHOUSE=<MY_WAREHOUSE> SCHEDULE='USING CRON 0 5,17 * * * UTC' AS insert overwrite into <MY_SCHEMA>.<MY_TABLE>(FIELD1,FIELD2) <MY_SQL> And my table looks like: FIELD1|FIELD2 ABC,REPLACE DEF,REPLACE GHI,DONTREPLACE JKL,DONTREPLACE Instead of replacing the entire table how can I alter my Snowflake to only overwrite the FIELD2='REPLACE' rows? Do I have to first have a command that deletes these rows or is there a way to do it more instantaneously? I know I can only execute one command per Snowflake task so would like

Join the discussion →

How to size a view relative to its parent when the parent is inside a scrollview?

I'm trying to dynamically size some views which end up being placed inside of a scrollview. Here is the simplest sample code I can think of: struct RootView: View { var body: some View { ScrollView { VStack(alignment: .leading) { // More views above HStack(spacing: 16) { MyView() MyView() } .padding([.leading, .trailing], 16) // More views below } } } } struct MyView: View { var body: some View { VStack(alignment: .leading, spacing: 24) { Image("myImage") .resizable() .scaledToFill() VStack(alignment: .leading, spacing: 0) { Text("Text") OtherView() } } } } I think really the main issue I'm ha

Join the discussion →

maven: replace transitive dependency version

Here a mvn dependency:tree snippet: ... +- org.springframework.boot:spring-boot-starter-actuator:jar:2.1.12.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.1.12.RELEASE:compile [INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.1.12.RELEASE:compile [INFO] | \- io.micrometer:micrometer-core:jar:1.1.9:compile ... As you can see, my project is using version 1.1.9 of io.micrometer:micrometer-core. I'd like to use a most recent version of this library. This version is due to: <parent> <groupId>org.springframework.boot</groupId> <artifactI

Join the discussion →

RuntimeError: unexpected EOF, expected 3302200 more bytes. The file might be corrupted

I am trying to implement pretrained model of following repository. I need your assistance to rectify the error. RuntimeError: unexpected EOF, expected 3302200 more bytes. The file might be corrupted. I tried to implement pretrained model of CANNet present on following repo using google Collab and followed all steps of (Prerequisites, cloning, Data Preparation, and Testing) https://github.com/gjy3035/NWPU-Crowd-Sample-Code.git The detailed error is given below Traceback (most recent call last): File "test.py", line 118, in main() File "test.py", line 46, in main test(lines, model_path) File "te

Join the discussion →

Binary value representation issue [duplicate]

My task is to create a text file and put my first name as binary data in the text file, and then to read this file and convert this binary data to characters and put it in another file as characters. How do I represent my name in binary? I tried: reg [255:0] myname = 01001110011010010110101101101111011011000110111101111010; But, it did not work. The error says the number is too big. Then I tried: reg [1:0] myname1 = 2'b0100_1110_0110_1001_0110_1011_0110_1111_0110_1100_0110_1111_0111_1010; This also did not work. It always gave "_" as an output.

Join the discussion →

Express or Axios Error: socket hang up code: ECONNRESET

This is the first time I posted a question here, sorry if some data is missing. I'm trying to do some web scraping to get some info from a table. The page only responds with an index.php. When I use the search form, it makes a POST to index.php?go=le with some formData. To avoid the CORS problem, I'm making the post with my own API running in localhost. I'm pointing my frontend to my API and I get the response from localhost. No problem there. My problem appears when I try to make a second request to my API. The first GET works fine but after that response it keeps failing. When I restart the

Join the discussion →

Retrieve amino acids from fasta file and include its overall percentage for only the top 5 results

I want to display the amino acid, count and percentage for the top 5 but I can only manage the count and the amino acid with the script described below. How could I update this? L: 139002 (10.7%) A: 123885 (9.6%) G: 95475 (7.4%) V: 91683 (7.1%) I: 77836 (6.0%) #!/usr/bin/env python3 def FASTA(filename): try: f = open(filename) except IOError: print ("The file, %s, does not exist" % filename) return order = [] sequences = {} counts = {} for line in f: if line.startswith('>'): name = line[1:].rstrip('\n') # name = name.replace('_', ' ') order.append(name) sequences[name] = '' else: sequences[nam

Join the discussion →

one function as a class and also instance method

This could be a so called XY problem, so let me start with what I want: ed = Edit.add(1).add(2).add(3) print(ed.op) # [1,2,3] Following is what I tried and basically I got working code, but I'm not sure if I did it right or if there are other options. The first add(1) is a class method call and the following add(2) and add(3) are instance method calls. I started here: class Edit: def __init__(self): self.op = [] @classmethod def add(cls, x): self = cls() return self.add_im(x) def add_im(self, x): # im = instance method self.op.append(x) return self ed = Edit.add(1).add_im(2).add_im(3) print(ed

Join the discussion →

Is Python's dict_items() a constructor that is inaccessible to users?

I was learning Python dictionaries at W3Schools: car = { "brand": "Ford", "model": "Mustang", "year": 1964 } x = car.items() print(x) I get: dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)]) Demo here: https://onecompiler.com/python/459cgc42u The dict_items looks like a conversion function or class constructor, but it is not recognized at the command line: >>> dict_items([('brand', 'Ford'), ('model', 'Mustang'), ('year', 1964)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'dict_items' is not defined The most authoritative explanati

Join the discussion →

ElementNotInteractableException : element not interactable C# Nunit Selenium

I am new to Selenium C# Nunit. I ran following line of codes IWebElement SplitCase = driver.FindElement(By.XPath(".//*[@id='OpportunityPageV2UsrSplitCase503e4272-cdbd-44d2-98c2-e67a2996c717ComboBoxEdit-el']")); SplitCase.Click(); IWebElement SplitCaseYes = driver.FindElement(By.CssSelector("li[data-item-marker=Yes]")); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(d => (bool)(d as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0")); SplitCaseYes.Click(); I got following Message: Message: OpenQA.Selenium.ElementNotInteractableException : element not int

Join the discussion →

Operators(and , or) in JSON Structure

I have never seen this kind of JSON before and I am not sure how this structure can be generated using code.In below Json structure offerings cantains an array of objects as well as an object with OR operator. Can somebody explain how is this valid JSON structure and how can we generate proto buffer for this kind of JSON structure? { "id": 147, "display_text": "Entertainment available", "quality": "better", "cost": "free or paid", "exists": "yes", "type": "streaming", "updated_at": "2019-01-30T09:13:30Z", "offerings": [ [ { "delivery_medium": "in-seat", "content_type": "livetv", "selection_typ

Join the discussion →

How to find and disable specific NVCC warning?

Where are the NVCC codes for a specific warning listed? Looking at other questions like this one gives the answer to use -Xcudafe "--diag_suppress=xxx to suppress warning "xxx", and links to a list of possible warnings here (edit: the link is dead, try on the Wayback Machine. However, when I have the warnings /usr/include/eigen3/Eigen/src/Core/util/XprHelper.h(94): warning: __host__ annotation is ignored on a function("no_assignment_operator") that is explicitly defaulted on its first declaration and /usr/include/eigen3/Eigen/src/Core/util/XprHelper.h(94): warning: __device__ annotation is ign

Join the discussion →

Decompiling PYC file with Uncompyle6 getting AssertionError

I am trying to recover the original python scripts from a pyinstaller exe. I was able to extract the files from the exe and obtain the magic number. From what I read, the main .py file (found in the extract folder with no suffix) just needs to be renamed to main.pyc and the magic number appended should work. I followed these instructions and it worked, but my issue is the other .pyc files (found in the PYZ-00.pyz_extracted) all error out when I try to decompile them with uncompyle6 - even when I append the magic number. The error I'm getting is: Unknown type 0 Traceback (most recent call last)

Join the discussion →

Add file to LSApplicationQueriesSchemes in your Info.plist WebView React Native

I'm implementing a payment platform in the app that I'm building so the payment form is shown on a WebView Now the form loads okay, but when I change something like I select a payment method from the drop-down web page loads to show options accordingly. But after that refresh it takes me back to the original state as in the page was never changed and throws a warning that reads: Error opening URL: [Error: Unable to open URL: file:///private/var/containers/Bundle/Application/457E6674-DA77-4676-A2CF-3F21C9572B57/mnopqmobile.app/entry.asp. Add file to LSApplicationQueriesSchemes in your Info.plis

Join the discussion →

Visual Studio Code Extension Install/Update Error: "Failed to load resource: net::ERR_CONNECTION_RESET"

Why can't I download or update any extensions from VS Code 1.54.3 on Windows 10 1930? Every time I tried to update or install those extensions, it always shows this error in the Dev Tools: Failed to load resource: net::ERR_CONNECTION_RESET ERR [uncaught exception in sharedProcess]: XHR failed: downloading: XHR failed at It says "XHR failed" and I can't find the fix for this issue.

Join the discussion →

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

I'm receiving the error in the title and I'm not sure why. I'm trying to run a docker container in Unraid. The dockerfile code is down below if anyone would like to critique. ENV DEBIAN_FRONTEND=noninteractive \ LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 \ LC_ALL=en_US.UTF-8 \ TERM=xterm \ TZ=:/etc/localtime \ PATH=$PATH:/usr/local/go/bin \ GOBIN=/go/bin \ APP=/go/src/smugmug-backup RUN sed -e "/deb-src/d" -i /etc/apt/sources.list \ && apt-get update \ && apt-get install --no-install-recommends --yes \ ca-certificates \ && apt-get clean \ && rm -rf /.root/cache \ && rm -rf /var/lib/apt/lists/*

Join the discussion →

Visual Studio Code doesn't find my python file. [Errno 2] No such file or directory

I'm struggling with a Visual Studio Code python compiler. Whenever I try to run the code it says python: can't open file 'c:\Users\User\Desktop\Programowasko\Python\Cybepunk encounter calculator\cyberpunk.py': [Errno 2] No such file or directory The only code which is written there is print("Hello World") by now. Also any other code which has recently worked, now it doesn't.

Join the discussion →

Resign previous Git commits with a new GPG key

I am trying to transition to a new GPG key. I would like to re-sign all of my previous commits in a Git repository (that have a valid signature with my formerly used key) with the new GPG key. In other words, how can I automatically resign (with my new key) all of the commits that I signed with my previous key? If you need key fingerprints to use in your example, please use 0000000000000000000000000000000000000000 as my old GPG key fingerprint and 1111111111111111111111111111111111111111 as my new key fingerprint.

Join the discussion →

A way to distinguish `\e` from escaped keys like `\e[A` in C++

I'm writing a readline replacement in C++, and I want to process terminal input in raw mode, including special/escaped keys like "up arrow" \e[A. However, I also want to be able to distinguish between a single press of the escape key \e followed by a press of [ and a press of A vs a press of the up arrow. I assume that the primary difference between those two situations is that when up arrow is pressed, the input characters come in within less than a millisecond, so I thought I could do something like: #include <termios.h> #include <absl/strings/escaping.h> #include <iostream> termios enter_ra

Join the discussion →

How do I install pipx on Windows?

I'm currently trying to follow the guides from CumulusCI, and I'm having some trouble installing pipx inside my computer. I already have installed Python 3, and I'm currently running the following command: pip install --user pipx The result is the following: Requirement already satisfied: pipx in c:\users\aharo\appdata\roaming\python\python39\site-packages (0.16.1.0) I set up the path environmental variables, and when I'm running pipx list is telling me the following: pipx : The term 'pipx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spellin

Join the discussion →

Kafka Consumer Error - Could not find attribute records-lag

I am trying to connect my application to Kafka and I am able to do that successfully. However, when I look at the logs, I get the below exception : WARN 2021-01-18 21:45:11,438 [**] org.apache.kafka.common.metrics.JmxReporter [RequestID=] Error getting JMX attribute 'records-lag' javax.management.AttributeNotFoundException: Could not find attribute records-lag at org.apache.kafka.common.metrics.JmxReporter$KafkaMbean.getAttribute(JmxReporter.java:192) at org.apache.kafka.common.metrics.JmxReporter$KafkaMbean.getAttributes(JmxReporter.java:200) at com.sun.jmx.interceptor.DefaultMBeanServerInter

Join the discussion →

Flutter / Dart Error SocketException: OS Error: The remote computer refused the network connection. , errno = 1225, address = 127.0.0.1, port = 59250

I am getting this error in my debugger. From what I understood it's an error generated by ip config. I found this solve here, but i dont understand where should i modify it. where should i change the ip address? Flutter SocketException (SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 51500) ERROR - 2021-03-23 18:21:26.074284 PUT /SXUs66yGd7s=/ Error thrown by handler. SocketException: OS Error: The remote computer refused the network connection. , errno = 1225, address = 127.0.0.1, port = 59250 Help! Thank you alot

Join the discussion →

Adding SSH-1 from firebase doesn't update google-services.json file

Hello I am facing issue that my google-services.json file is not updating after adding new fingerprint from Firebase console. I have generated debug SSH-1 from terminal and added that SSH-1 to firebase console but after downloading new google-services.json I found my new oauth_client array is not updating with new certificate. Please help me this "oauth_client": [ { "client_id": "508076951118-vg2ihk02grdoje0t0fmfdkimtn3a7kqs.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "com.money.demo", "certificate_hash": "My Machine Hash" } }, { "client_id": "XXXXX06951118

Join the discussion →

Find current Windows BCD Store file path

I need to get the currently Windows using BCD Store file path. I know the current BCD Store registry is loaded under HKEY_LOCAL_MACHINE\BCD00000000 but I couldn't find any WinAPI to get the file path of a loaded key. Usually the volume containing the BCD file is not mounted so I also finding an API that results the disk index and partition index of the BCD file.

Join the discussion →
Older stories