Categories

## R: y-axis disappears when using coord_trans

Data: structure(list(Doy = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), Greenup = c(108, NA, 107, NA, 108, 108, NA, 108, NA, 108, […]

Categories

## Fast way to remove array of specific row values from 2D numpy array

I have a 2D array like this: a = np.array([[25, 83, 18, 71], [75, 7, 0, 85], [25, 83, 18, 71], [25, 83, 18, 71], [75, 48, 8, 43], [ 7, 47, 96, 94], [ 7, 47, 96, 94], [56, 75, 50, 0], [19, 49, 92, 57], [52, 93, 58, 9]]) and I want to […]

Categories

## How can I get all details of the top x models from forecast::auto.arima in R?

My goal is to exactly re-create the top say 3 models from the auto.arima function in R. My example uses the following series: > data <- c(79, 73, 102, 158, 235, 326, 216, 153, 82, 87, 94, 163, 119, 81, 143, 179, 182, 247, 248, 105, 143, 64, 45, 163, 122, 95, 47, 117, 345, […]

Categories

## Segmentation fault (core dumped) in C when assigning value to variable in struct

I’m getting this error when trying to modify an integer variable inside a struct. This would be the struct: typedef struct{ tPartner *partnerList; int numPartners; tContract *contractList; int numContracts; tWorkspace workspaces[MAX_SPACES]; int numSpaces; } tCoworking; And here is where I am trying to modify numContracts: void add_contract(tCoworking *cw, int partnerID, int spaceID, int month, int […]

Categories

## How to manipulate the n.label values with paste0() for the number of observations using the plotmean() function in the gplot() package in R

Problem: I have a data frame called FID and I want to label the number of observations for each mean and the upper and lower confidence intervals. Because the data frame shows the number of observations per month over three years (below), the n.labels are being labelled as n=3 (see figure 1 below). I created […]

Categories

## Object.keys(myObject) returns an arbitrary list of numbers, not expected value

This is a bit of a head-scratcher – and has been a source of pain for the past 3 hours. Here’s my code. const payloadBody = JSON.parse(gatewayEvent.body); console.log(payloadBody); console.log(gatewayEvent.body); console.log(payloadBody.paymentMethodId); console.log(payloadBody[‘paymentMethodId’]); console.log(Object.keys(payloadBody)); If I look at the CloudWatch logs for this (I am executing in Lambda), the line console.log(payloadBody) logs: { "customerId": "cus_REDACTED", "paymentMethodId": "pm_REDACTED", […]

Categories

## Linux mint freezes when running SDL2 prgram

In the past couple SDL2 programs I’ve been developing the strangest error seems to pop up; whenever I run the program– after an arbitrary amount of time has passed– Linux mint freezes. I can’t move my mouse or do anything with the computer. My only option at that point is to push the power button […]

Categories

## Efficient neighbourhood search in numpy ndarray instead of nested conditional for loops

Although there are many instances of the question: "What is the numpy alternative to nested for loops", I was unable to fins a suitable answer for my case. Here it goes: I have a 3D numpy array with "0" background and other integers as foreground. I would like to find and store the foreground voxels […]

Categories

## when we reshape numpy array, how is the stride size inferred?

I have an 1×1024 1-d array (flattened image). To see the image, I want to reshape its size as 32×32. I can easily achieve this by doing x.reshape(-1,32) and it works as I intended. It doesn’t screw the image. It reads the 1d array with 32-width stride each time. Say this time, there are 4 […]

Categories

## Bash: convert 100,000+ characters to decimal format?

I’m looking for a quick and not-so CPU intensive solution to convert 100,000+ lines of text into decimal format. # random ascii string=’QPWOEIRUTYALSKDJFHGZMXNCBV,./;[]75498053\$#!@*&^%(*’ convert () { for ((b=0; b<\${#string}; b++ )) do # convert to dec, append colon character, add to array arr+=\$(printf ‘%d,’ "’\${string:\$b:1}"); done; # show array contents printf ‘%s’ "\${arr[@]::-1}" } time […]