天道酬勤,学无止境

问答

ValueError: check_hostname requires server_hostname

I was going to install pandas and epanettools on my computer using the code shown below with python 3.8.5 and I received one Error exception. Code: pip install epanettools pip install pandas Actually, I could install epanettools on my old computer and I bought a new computer and I wanted to do the same thing on my new computer, but it didn't work and the error exception shown below after running the code shown above: Error: Exception: ERROR: Exception: Traceback (most recent call last): File "c:\users\ziyuan\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\base

2022-05-03 11:55:41   python   pip

In Rails, how can I submit a form and request a csv formatted page?

I have a few parts of the solution, but I'm having trouble bringing them together. I have a page with two text fields (in a form_tag) in which I'll enter a datetime string with the start and end dates of the records I want to download in CSV form. I can use a submit_tag and get the two dates, but then I don't know how to get the view to tell the controller that I want a CSV, so . I can use a link_to, but then the params get left behind. The view and controller look a little wonky as I'm trying to figure out how this stuff should work together. I won't ship both a link and a button, for example

2022-05-03 11:55:23   ruby-on-rails   ruby   csv   ruby-on-rails-5

R: read.csv.sql from sqldf is able to successfully read one csv but not another

I have a dataset which is around 20GB big and therefore, I am not able to read it into an R dataframe without running out of memory. After reading some posts here, I have decided to use read.csv.sql into a database. The code I used is: read.csv.sql( "jobs.csv", sql = "CREATE TABLE Jobs2 AS SELECT * FROM file", dbname = "Test1.sqlite" ) When I run the following: sqldf( "select * from Jobs2", dbname = "Test1.sqlite" ) I get the heading of the columns, but then no value: <0 rows> (or 0-length row.names) But when I try the same with a csv I created using the iris dataset, everything works fine

2022-05-03 11:55:13   r   csv

Same FLT_EVAL_METHOD, different results in GCC/Clang

The following program (adapted from here) is giving inconsistent results when compiled with GCC (4.8.2) and Clang (3.5.1). In particular, the GCC result does not change even when FLT_EVAL_METHOD does. #include <stdio.h> #include <float.h> int r1; double ten = 10.0; int main(int c, char **v) { printf("FLT_EVAL_METHOD = %d\n", FLT_EVAL_METHOD); r1 = 0.1 == (1.0 / ten); printf("0.1 = %a, 1.0/ten = %a\n", 0.1, 1.0 / ten); printf("r1=%d\n", r1); } Tests: $ gcc -std=c99 t.c && ./a.out FLT_EVAL_METHOD = 0 0.1 = 0x1.999999999999ap-4, 1.0/ten = 0x1.999999999999ap-4 r1=1 $ gcc -std=c99 -mpfmath=387 t.c

2022-05-03 11:55:05   c   gcc   floating-point   clang

NetworkX: how to add weights to an existing G.edges()?

Given any graph G created in NetworkX, I want to be able to assign some weights to G.edges() after the graph is created. The graphs involved are grids, erdos-reyni, barabasi-albert, and so forth. Given my G.edges(): [(0, 1), (0, 10), (1, 11), (1, 2), (2, 3), (2, 12), ...] And my weights: {(0,1):1.0, (0,10):1.0, (1,2):1.0, (1,11):1.0, (2,3):1.0, (2,12):1.0, ...} How can I assign each edge the relevant weight? In this trivial case all weights are 1. I've tried to add the weights to G.edges() directly like this for i, edge in enumerate(G.edges()): G.edges[i]['weight']=weights[edge] But I get this

2022-05-03 11:54:59   python   algorithm   graph   networkx   edges

Creating Instance Of Class Based On ClassName : string

Before anyone marks this as duplicate please read below, My scenario doesn't just involve TypeScript but also Angular2. Objective I need a method in app.component.ts which takes a string(Class Name) and creates a instance of that. The classes exist in other ts files. Now to the use case: I have a method getWidgetObjectFromClassName(className : string) : Object{} which needs to return the instances of the class name which is in string format. Now the problem, I tried using NameSpace and doing let instance = new SampleNS['OtherName'](); (SampleNS is a namespace), works perfectly fine in the case

2022-05-03 11:54:51   typescript   angular   typescript1.8

In R, sample n rows from a df in which a certain column has non-NA values (sample conditionally)

Background Here's a toy df: df <- data.frame(ID = c("a","b","c","d","e","f"), gender = c("f","f","m","f","m","m"), zip = c(48601,NA,29910,54220,NA,44663),stringsAsFactors=FALSE) As you can see, I've got a couple of NA values in the zip column. Problem I'm trying to randomly sample 2 entire rows from df -- but I want them to be rows for which zip is not null. What I've tried This code gets me a basic (i.e. non-conditional) random sample: df2 <- df[sample(nrow(df), 2), ] But of course, that only gets me halfway to my goal -- a bunch of the time it's going to return a row with an NA value in zip

2022-05-03 11:54:37   r   dataframe   random   subset

App Launcher Icon Disappears from screen

I was trying to set the intent filters for a simple app to handle urls. I applied the basic tags for "intent-filter" like "action" ,"category". Here I used 2 "intent-filter" tags. <activity android:name=".MyBrowserActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter > <action android:name="android.intent.action.VIEW" /> <data android:scheme="http" /> <category android:name="android.intent.category.BROWSABLE"/> <category android:name="android

2022-05-03 11:54:30   android   android-intent

Swagger UI for net core 3.1 api is very slow

I updated Our net core API application from 2.1 to 3.1, SwashBuckle.Asp.NetCore to 5.0.0. Here is my startup set: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string authServerUrl = "http://testserver.com/identityserver4"; services.AddControllersWithViews(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Version = "v1"

2022-05-03 11:54:24   c#   .net-core   swagger   swagger-ui   swashbuckle

How to prove this invariant?

I aim to prove that the Horner's Rule is correct. To do so, I compare the value currently calculated by Horner with the value of "real" polynominal. So I made this piece of code: package body Poly with SPARK_Mode is function Horner (X : Integer; A : Vector) return Integer is Y : Integer := 0; Z : Integer := 0 with Ghost; begin for I in reverse A'First .. A'Last loop pragma Loop_Invariant (Y * (X ** (I - A'First + 1)) = Z); Y := A(I) + Y * X; Z := Z + A(I) * (X ** (I - A'First)); end loop; pragma Assert (Y = Z); return Y; end Horner; end Poly; Which should prove the invariant. Unfortunately

2022-05-03 11:54:16   ada   proof   invariants   proof-of-correctness   spark-ada