Question about shipper carrier codes for orders

I am writing integration code to connect Magento to our ERP system. I need to pass the shipping carrier code to our ERP order creation but the code in the order does not match our internal carrier code.

I want to change the Magento carrier codes to align with our ERP codes to avoid having to do a lookup to convert the codes back and forth. I can’t figure out where these codes are stored on the Magneto side, and I can’t find any documentation explaining how to manage these codes.

Example: (From Magento order)

“shipping_description”: “UPS – UPS Next Day AirĀ®”, …

 "shipping": {    "address": {      "address_type": "shipping",      "city": "nowheresville",      "company": "foo",      "country_id": "US",      "customer_address_id": 84,      "email": "RandomGuy@fu-co.com",      "entity_id": 305,      "firstname": "Random",      "lastname": "Dude",      "parent_id": 187,      "postcode": "17602",      "region": "Pennsylvania",      "region_code": "PA",      "region_id": 51,      "street": [         "1313 mockingbird lane"       ],       "telephone": "555-1212"       },       **"method": "ups_01",** 

Here the method is set to ups_01

My hope was that I could change the string “ups_01” to match our existing codes.

Can anyone provide some guidance on how/if this can be configured?

Shortest possible good codes?

Good codes (those with positive rate $ r=k/n$ and positive relative distance $ \delta=d/n$ ) will achieve capacity on $ BSC$ (binary symmetric channel) if the codes have higher rates than capacity where positive relative distance is seen. However this requires very long codes to drive the error to reasonably low value.

To achieve an error rate of $ e$ if capacity is $ C$ then what is the shortest good code that is possible over $ BSC$ as a function of $ e$ ? I am just looking for an upper bound and a lower bound.

Looking for function to select array size based on matching ID codes in t-test (Google Sheets)

I’m using Google Sheets and trying to conduct a t-test on pre- and post-survey data. The follow-up survey will almost certainly have fewer respondents than the pre-survey. All respondents have a self-generated identification code that I am using to match pre- and post-survey data.

I’m looking for a way to conduct a paired t-test on a range of pre-survey data that has a matching identification code in the post-survey data set. I’m thinking the FILTER() function or maybe even a vlookup() function might be necessary? I’m pretty stuck.

Another option might be to copy the data into another sheet using the filter() function to get only data that has a pre- and post- match, but it seems like if I can do this, I should be able to eliminate the need to copy to another sheet.

Thanks for the help!


Final Codes for this problems please

Could you please post the final codes for this problem? Thank you very much! Please post java codes. The example has C#, but I am interesting in Java. Thanks

public decimal ShelfPrice { get; set; }

public string Name { get; set; }  public bool IsImported { get { return Name.Contains("imported "); } }  public bool IsOf(ProductType productType) {     return productType_Identifiers.ContainsKey(productType) &&         productType_Identifiers[productType].Any(x => Name.Contains(x)); } 

What is the difference between these two codes? Ultimately, which one is more effective on performance?

The codes below both just print numbers 0 through 9 and what is the performance difference between the two? Which one is better for effectiveness and style?

THE DIFFERENCE BETWEEN

#include <stdio.h>  int main(void) {     for (int x = 0; x < 10; x++)     {       printf("%i\n", x);     } } 

AND

#include <stdio.h>  int main(void) {     int x = 0;     while (x < 10)     {       printf("%i\n", x);       x++;     } } 

Huffman Codes C++

This is my version of the Huffman Codes. I really appreciate all your advices and I thank you in advance for taking your time to read through my code.

Cheers, SM

/*     Author: Stevan Milic     Date: 05.05.2018.     Course: Data Structures II     Professor: Dr. Claude Chaudet     Description: Huffman Codes */ #include <iostream>  #include <cstdlib>  using namespace std; #define MAX_TREE_HEIGHT 1000  // A Huffman tree node  struct MinHeapNode  {     char codeword; // I chose char because we are inputing alphabetic       letters      // The reason why I chose unsigned data type is because an unsigned  integer can never be negative.     // In this case the frequency and the capacity of a character cannot be negative.     unsigned freq; // Frequency of the character - how many times does it occur      struct MinHeapNode *left, *right; // Left and Right children };  struct MinHeap // Collection of nodes {     unsigned size; // Size of the heap     unsigned capacity; // Capacity of the heap     struct MinHeapNode** array; // Heap node pointers array };  // Function to dynamically alocate a new heap node with provided character   (codeword) and its frequency struct MinHeapNode* newHeapNode(char codeword, unsigned freq) {     struct MinHeapNode* temp = (struct MinHeapNode*)malloc(sizeof(struct   MinHeapNode));      temp->left = temp->right = NULL;     temp->codeword = codeword;     temp->freq = freq;      return temp; }  // Creating a new dynamically allocated min heap with given capacity struct MinHeap* createMinHeap(unsigned capacity) {     struct MinHeap* minHeap = (struct MinHeap*)malloc(sizeof(struct MinHeap));     minHeap->size = 0; // Setting the size to 0     minHeap->capacity = capacity; // Inserting the given capacity     // Inserting into the heap node pointers array     minHeap->array= (struct MinHeapNode**)malloc(minHeap->capacity * sizeof(struct MinHeapNode*));      return minHeap; }  // Swap function to swap two min heap nodes void swap(struct MinHeapNode** a, struct MinHeapNode** b) {     struct MinHeapNode* temp2 = *a;     *a = *b;     *b = temp2; } // minHeapify function  void minHeapify(struct MinHeap* minHeap, int index) {     int smallest = index;     int leftSon = 2 * index + 1;     int rightSon = 2 * index + 2;      if (leftSon < minHeap->size && minHeap->array[leftSon]->freq <      minHeap->array[smallest]->freq)         smallest = leftSon;      if (rightSon < minHeap->size && minHeap->array[rightSon]-> freq < minHeap->array[smallest]->freq)         smallest = rightSon;      if (smallest != index)     {         swap(&minHeap->array[smallest], &minHeap->array[index]);         minHeapify(minHeap, smallest);     } }  // Checking if the size of the heap is 1 int heapSizeOne(struct MinHeap* minHeap) {     return (minHeap->size == 1); }  // Extracting minimum value node from the heap struct MinHeapNode* extractMin(struct MinHeap* minHeap) {     struct MinHeapNode* temp = minHeap->array[0];     minHeap->array[0] = minHeap->array[minHeap->size - 1];      --minHeap->size;     minHeapify(minHeap, 0);     return temp; }  // Inserting a new node into min heap void insert(struct MinHeap* minHeap, struct MinHeapNode* minHeapNode) {     ++minHeap->size;     int i = minHeap->size - 1;     while (i && minHeapNode->freq < minHeap->array[(i - 1) / 2]->freq)      {         minHeap->array[i] = minHeap->array[(i - 1) / 2];         i = (i - 1) / 2;     }     minHeap->array[i] = minHeapNode; }  // Build function to build min heap void build(struct MinHeap* minHeap) {     int n = minHeap->size - 1;     for (int i = (n - 1) / 2; i >= 0; --i)         minHeapify(minHeap, i); }  // Display function to print an array void display(int arr[], int n) {     int i;     for (i = 0; i < n; ++i)         cout << arr[i];     cout << "\n"; }  // Function to check if the node is a leaf int isLeaf(struct MinHeapNode* root) {     return !(root->left) && !(root->right); }   // Creating a min heap with given capacity equivalent to size and inserts all    the codewords and their frequency. struct MinHeap* create(char codeword[], int freq[], int size) {     struct MinHeap* minHeap = createMinHeap(size);     for (int i = 0; i < size; ++i)         minHeap->array[i] = newHeapNode(codeword[i], freq[i]);     minHeap->size = size;     build(minHeap);     return minHeap; }  // Function that builds the Huffman tree  struct MinHeapNode* buildHT(char codeword[], int freq[], int size) {     struct MinHeapNode *left, *right, *top;      // Creating a min heap with given capacity equivalent to size and inserts all the codewords and their frequency.     struct MinHeap* minHeap = create(codeword, freq, size);      // while loop runs as long as the size of heap doesn't reach 1      while (!heapSizeOne(minHeap))      {         // Getting the two minimums from min heap         left = extractMin(minHeap);         right = extractMin(minHeap);          // The frequency of top is computed as the sum of the frequencies of left and right nodes.          top = newHeapNode('_', left->freq + right->freq);         top->left = left;         top->right = right;         insert(minHeap, top);     }     // The remaining value is the root node which completes the tree     return extractMin(minHeap); }  // Prints huffman codes from the root of // Displaying Huffman codes void displayHC(struct MinHeapNode* root, int arr[], int top) {      // Left side is given the value 0      if (root->left)      {         arr[top] = 0;         displayHC(root->left, arr, top + 1);     }     // Right side is given the value 1     if (root->right)      {         arr[top] = 1;         displayHC(root->right, arr, top + 1);     }     // If this is a leaf node, print the character and its code.     if (isLeaf(root))      {         cout << root->codeword << ": ";         display(arr, top);     } }  // Building a Huffman Tree and displaying the codes void HuffmanCodes(char codeword[], int freq[], int size)  {     // Building a HT     struct MinHeapNode* root = buildHT(codeword, freq, size);      // Displaying the HT we built     int arr[MAX_TREE_HEIGHT], top = 0;      displayHC(root, arr, top); }  // I used the example from the PP presentation in the Files section - The Hoffman Coding int main() {     cout << "A|4\t B|0\t C|2\t D|1\t C|5\t E|1\t F|0\t G|1\t H|1\t I|0\t J|0\t K|3\t L|2\t M|0\t N|1\t\nO|2\t P|0\t Q|3\t R|5\t S|4\t T|2\t U|0\t V|0\t W|1\t X|0\t Y|0\t Z|0\t _|6\n" << endl;     char arr[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_' };     int freq[] = { 4, 0, 2, 1, 5, 1, 0, 1, 1, 0, 0, 3, 2, 0, 1, 2, 0, 3, 5, 4, 2, 0, 0, 1, 0, 0, 6};      int size = sizeof(arr) / sizeof(arr[0]);      HuffmanCodes(arr, freq, size);      cout << "\n\n";     system("pause");     return 0; } 

Python: How can the following codes be converted into a more generalized form?

I have a df as follows:

ContextID   EscAct_Curr_A   StepID 7289973 0.122100122           1 7289973 0                     2 7289973 0                     2 7289973 0.122100122           2 7289973 0.122100122           2 7289973 0.122100122           2 7289973 0.122100122           2 7289999 0.244200245           1 7289999 0.244200245           1 7289999 0.244200245           1 7289999 0.244200245           2 7289999 0.366300374           2 7289999 0.366300374           2 7289999 0.366300374           2 7290025 0.122100122           1 7290025 0.122100122           1 7290025 0.122100122           2 7290025 0                     2 7290025 0                     2 7290025 0.122100122           2 

What I want to do is to club all the values from different StepIDs and create a separate df of it.

For instance, all the values of StepID 1 must be saved to one df, say s1 and all the values of StepID 2 must be saved to one df, say s2 so on. I have 24 such StepIDs. After this is done, I want to plot a scatterplot after running a machine learning algorithm.

What I have done:

For StepID 1

s1 = X.loc[X['StepID'] == 1] s1_array = s1.iloc[:,1].values.astype(float).reshape(-1,1) min_max_scaler = preprocessing.MinMaxScaler() scaled_array_s1 = min_max_scaler.fit_transform(s1_array) s1.iloc[:,1]=scaled_array_s1  ocsvm = OneClassSVM(nu = 0.1, kernel = 'rbf', gamma = 'scale') s1['y_ocsvm1'] = ocsvm.fit_predict(s1.values[:,[1]]) 

For StepID 2

s2 = X.loc[X['StepID'] == 2] s2_array = s2.iloc[:,1].values.astype(float).reshape(-1,1) min_max_scaler = preprocessing.MinMaxScaler() scaled_array_s2 = min_max_scaler.fit_transform(s2_array) s2.iloc[:,1]=scaled_array_s2  ocsvm = OneClassSVM(nu = 0.1, kernel = 'rbf', gamma = 'scale') s2['y_ocsvm2'] = ocsvm.fit_predict(s2.values[:,[1]]) 

Plotting the scatter plot:

fig, ax = plt.subplots() ax.scatter(s1.values[s1['y_ocsvm1'] == 1, 2], s1.values[s1['y_ocsvm1'] == 1, 1], c = 'green', label = 'Normal') ax.scatter(s1.values[s1['y_ocsvm1'] == -1, 2], s1.values[s1['y_ocsvm1'] == -1, 1], c = 'red', label = 'Outlier') ax.scatter(s2.values[s2['y_ocsvm2'] == 1, 2], s2.values[s2['y_ocsvm2'] == 1, 1], c = 'green') ax.scatter(s2.values[s2['y_ocsvm2'] == -1, 2], s2.values[s2['y_ocsvm2'] == -1, 1], c = 'red') plt.legend() 

These codes do exactly what I want it to, but writing codes like this for 24 different StepIDs is a lot tedious. So, I would like to know if there’s a more compact way to achieve the following, maybe by using a loop or functions.