python – Why is np.where not returning the expected values?

initialization

arr = np.zeros((2,2,2,2))

My input array is

((((0.5, 1. ),
     (0.6, 2. )),

    ((0. , 0. ),
     (0. , 0. ))),


   (((0. , 0. ),
     (0. , 0. )),

    ((0. , 0. ),
     (0. , 0. ))))

command

np.where (arr> 0)

output

(array((0, 0, 0, 0)),
 array((0, 0, 0, 0)),
 array((0, 0, 1, 1)),
 array((0, 1, 0, 1)))

Why is the last value in the above tuple not arr (0,0,1,0) ?

postgresql – How are string values ​​output in single quotes?

I'm trying to convert values ​​stored in a JSON to its string representation.

The #>> Operator works for this purpose for numbers, z.

SELECT '{"a":(1,2,3),"b":("4","5","6")}'::json#>>'{a,2}';

gives

 ?column? 
------
 3
(1 row)

For string values, the text representation (6 (in the example below), there are no single quotes so you can not tell that the stored value was a string:

SELECT '{"a":(1,2,3),"b":("4","5","6")}'::json#>>'{b,2}';
 ?column? 
----------
 6
(1 row)

Use a function or expression to output PostgreSQL '6' Instead of 6 in the second example above (and output 3 in the first example)?

(This is with PostgreSQL 12)

postgresql – How do I filter a memory where the values ​​in a trigger are not null?

The easiest way to explain the question is to use an audit trigger.

However, when pasting, all values ​​are stored, including the null values. I want to filter out the null values ​​in hstore(NEW.*), What is the easiest / fastest way to do this?

Source: https://github.com/2ndQuadrant/audit-trigger/blob/master/audit.sql#L134

audit_row.row_data = hstore(NEW.*) - excluded_cols;

Of course this does not work, but hopefully it will explain what the answer will be.

audit_row.row_data = hstore(hstore(NEW.*) FILTER (WHERE value IS NOT NULL)) - excluded_cols;

The answer is preferred if no user-defined function is used.

This is for> = PostgreSQL v11

Note: Answers must be used hstoreNot json or jsonb, You can suggest an alternative way with json or jsonbbut main answer has to use hstore,

Attempting to use the AngularFire module for cloud messaging will result in configuration values ​​for missing apps

I use Firebase Cloud Messaging in my Angular app with AngularFire2 to receive and send notifications. However, if an attempt is made to retrieve the user's current token, the app returns an error.

I've already created the firebase-messaging-sw.js and manifest.json files to register the service rep and added everything correctly, but to no avail.

The component where I subscribe to the observable.

export class HomeComponent implements OnInit {
  constructor(
    private afMessaging: AngularFireMessaging,
    private afStore: AngularFirestore,
    private afAuth: AngularFireAuth,
  ) {}

  ngOnInit() {
    this.afAuth.user.pipe(
      exhaustMap(
        user => {
          return this.afMessaging.getToken.pipe(
            tap(
              token => {
                console.log(token);
                this.afStore.collection('users').doc(user.uid).update({
                  fcmToken: token
                });
              }
            )
          );
        }
      )
    ).subscribe();
    this.afMessaging.messages
      .subscribe((message) => { console.log(message); });
  }
}

The service employee:

  // Give the service worker access to Firebase Messaging.
  // Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js");

// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
  messagingSenderId: "231973795174"
});

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(function(payload) {
  console.log(
    "(firebase-messaging-sw.js) Received background message ",
    payload
  );
  // Customize notification here
  const notificationTitle = "Background Message Title";
  const notificationOptions = {
    body: "Background Message body.",
    icon: "/firebase-logo.png"
  };

  return self.registration.showNotification(
    notificationTitle,
    notificationOptions
  );
});

The manifesto

{
  "name": "App",
  "gcm_sender_id": "103953800507"
}

The Angular.json

"assets": (
    "src/favicon.ico",
    "src/assets",
    "src/firebase-messaging-sw.js",
    "src/manifest.json"
 ),

The error I get in detail is this:

Uninhibited (Promise): FirebaseError: Installations: Missing app configuration values. (installations / missing-app-config-values).
FirebaseError: Installations: Missing app configuration values. (installations / missing-app-config-values).
at extractAppConfig (index.esm.js: 89)
Object.factoryMethod (as installations) (index.esm.js: 1110)
at FirebaseAppImpl.push ../ node_modules/@firebase/app/dist/index.cjs.js.FirebaseAppImpl._getService (index.cjs.js: 191)
at FirebaseAppImpl.firebaseAppImpl. (as installations) (index.cjs.js: 458)
at index.esm.js: 415
at step (tslib.es6.js: 99)
at Object.next (tslib.es6.js: 80)
at tslib.es6.js: 73
new ZoneAwarePromise (zone-evergreen.js: 876)
at __awaiter (tslib.es6.js: 69)
at resolvePromise (zone-evergreen.js: 797)
at zone-evergreen.js: 707
at zone-evergreen.js: 723
at ZoneDelegate.invoke (zone-evergreen.js: 359)
Object.onInvoke (core.js: 39698)
at ZoneDelegate.invoke (zone-evergreen.js: 358)
at Zone.run (zone-evergreen.js: 124)
at zone-evergreen.js: 855
at ZoneDelegate.invokeTask (zone-evergreen.js: 391)
Object.onInvokeTask (core.js: 39679)

Sudoku PHP Save Values ​​- Stack overflow in Spanish

I'm trying to make a little sudoku in PHP, and my question is: I want to be able to save the user-entered values ​​and reload them when sending. Does anyone know?

";
    echo "";
    if (isset($_POST('Sudo()()'))) {
        $array1 = $_POST('Sudo()()');
    } else {
        $array1 = ((1,2,3,4,5,6,7,8,9),(5,6,7,8,9,1,2,3,4),
        (8,9,4,2,3,7,5,6,1),
        ('','','','','','','','',''),
        ('','','','','','','','',''),
        ('','','','','','','','',''),
        ('','','','','','','','',''),
        ('','','','','','','','',''),
        ('','','','','','','','',''),
        ('','','','','','','','',''));
    }
    for ($i = 0; $i < 9; $i++) {
        echo "";
        for ($j = 0; $j < 9; $j++) {

        echo "";
        }
        echo "";
    }
    echo "
"; echo "
"; echo ""; echo var_dump($_POST('Sudo')); ?>

java – to set values ​​from the yml configuration

I have class:

@WebServiceClient(name = "${service.name}", targetNamespace = "${service.namespace}", wsdlLocation = "${service.wsdlLocation}")
public class ExampleService extends Service {
    @Value("${service.wsdlLocation}")
    private static String wsdlLocation;
}

It's part of the MVN project that I compile and use from my local Maven repo as a dependency on my other Spring Boot app, which has the yml configuration:

service:
  name: name
  namespace: namespace
  wsdlLocation: wsdlLocation

Is there a way that this ExampleService class uses the configuration of the parent project?

List Manipulation – Find the highest values ​​between two different sentences

I have the following two lists:

a1 = {0, 2, 4, 7, 8, 10};
b1 = {1, 4, 15, 8, 6, 2};
c1 = Thread@{a1, b1};
a2 = {0, 1, 4, 6, 8, 10};
b2 = {1, 6, 12, 10, 4, 2};
c2 = Thread@{a2, b2};

gives the following picture ListPlot[{c1, c2}, Joined -> True, Mesh -> All]:

Two lists

I want to find the wrapped points of the two lists, so I tried:

a3 = Join[a1, a2] // DeleteDuplicates // Sort;
f[l_List] := Interpolation[l, InterpolationOrder -> 1, Method -> "Spline"]
b11 = f[c1][#] & /@ a3;
b22 = f[c2][#] & /@ a3;
env = Table[Max[#[[i]] & /@ {b22, b11}], {i, 1, Length@a3}];
ListPlot[{c1, c2, Thread@{a3, env}}, Joined -> True, Mesh -> All]

env

But it's not as good as I had hoped.

I'm a bit rusty, so I know you all know a better and right way to do this :]

Clustering – difference between NMI and AMI values

Can anyone explain the difference between two normalized versions of measurements (NMI and AMI), which measure the correspondence of the two assignments, ignoring permutations.

Let's look at this code:

from sklearn import metrics
labels_true = (0, 0, 0, 1, 1, 1)
labels_pred = (0, 0, 1, 1, 2, 2)

# AMI score: 
score_ami = metrics.adjusted_mutual_info_score(labels_true, labels_pred)  
print(score_ami)

# NMI Score
score_nmi = metrics.normalized_mutual_info_score(labels_true, labels_pred)  
print(score_nmi)

magento2 – Magento 2 Get custom attribute values ​​in phtml

I want to enter attribute values ​​(gender) in the selection list on the list page. When selecting a specific value for the gender attribute, the product list should be filtered.

The gender attribute has 3 values

  1. Male
  2. Female
  3. Other

For some products, the attribute value is set to male and female because the product is unisex.

I want to know how to get the values ​​of attributes (male, female, others) independent of products.