How extract Values from List with Python?

I request a JSON File from API. Then i want to parse/save just some values out of the File.

Code:

First the request call:

request = requests.get(self.url, verify = False)
request_data = request.json()

Example File (Type <class ‘list’>):

(
    {
        "id1": null,
        "id2": "test1",
        "id3": "test2",
    }
    {
        "id1": null,
        "id2": "test3",
        "id3": "test4",
    }
)

Now i just want to get all id2 and their value, i tried with the code below, but it only works with dictionaries, how can i convert the list to dict? Or can i extract the values with list too?

value = {}
output_data = {}
value("id2") = data.get("id2")
output_data.append(value)

sharepoint online – Lookup Field to pull in values from Choice Column

I have a Customer Table containing info such as Customer # (Number), Name(Single line of text), Bankruptcy status (Yes/No), Currency (Choice).

I also have a Invoice table which has a lookup column for the Customer #, pulling in the Customer Name.

Now, the scope of the project has made it so I need to pull in the Currency column using the Customer # lookup, which seems like it would’ve been straight forward; however, I don’t see any of the other columns besides the system generated ones (Version, Title, ID, Created, etc.) w

How can I get the lookup column to also include the currency in the Invoice table?

Google Sheet multiple lookup values and return entire row

I’d like to lookup the activation type in C6 as well as the date range found in L6 and O6 on the “dashboard” tab and return the resulting rows (specifically columns E-J) from the “batches” tab?

Example Google Sheet

You can see in C17, I’ve been able to return a single value based on one lookup value, but would like to expand to lookup multiple values and return the entire row?

=IFERROR(LOOKUP(L$6,Batches!A:A,Batches!E:E),"no live activations for that date range")

plotting – How to show no data (white background) with ListDensityPlot instead of copying exteme values of data?

I have a list of experimental (x,y,f) data, e.g. I can generate similar data with this:

Fitness({x_, y_}) := (x - 1)^2 + 10 (x^2 - y)^2;
ListDensityPlot(Flatten(#, 1) &@ Table({x, y, Fitness({x, y})}, {x, -1, 1.5, 0.1}, {y, -1, 1.5, 
    0.1}), InterpolationOrder -> 0)

enter image description here

How to show more range in this ListDensityPlot to illustrate absence of data (of course with white backgroung style)? I mean that if you just try to increase range with PlotRange -> {{-5, 5}, Automatic, Automatic}, you will see smth like this enter image description here

This picture illustrates that WM instead of showing white background in regions without data interpolates data or, idk, tries to copy extreme values of data and shows this values in no data regions.

How to show white background in regions where I don’t have experimental data?

mysql – How to return row with values if nothing fits the conditions

I have his query that works fine, but i need it to return a line when nothing is found to suit the conditions:

SELECT D.CODPRO, D.VALPRO, COALESCE(SUM(d.UVCLIV), 0)  AS SUM 
FROM FGE50LM0TV.GESUPE E LEFT JOIN FGE50LM0TV.GESUPD D   
ON E.NUMSUP=D.NUMSUP AND E.SNUSUP=D.SNUSUP               
WHERE E.CODACT = '001'                                         
AND D.CODPRO <> ''                                       
AND E.CIRPIC = 'HUB'                                     
AND E.ETASUP IN ('30','40','60')                         
AND D.CNFLIG = '2'                                       
AND E.TOPMNQ <> '1'                                      
AND D.CODPRO IN ('TST UOP 1')                                 
GROUP BY D.CODACT, D.CODPRO, D.VALPRO 

How to send all theme_mod customizer default values to the database upon theme installation?

I’m building a new theme with many customizer settings, which all have default values.

I need these default values to be sent to the database immediately upon theme installation, so that they appear on the front end of the website.

Is there a simple way to do this?

unity3d – State machine – how to handle outside environment values?

I’ve got a state machine implementation in Unity that I’m working on (C#), the plan being that it will be mostly used for AI related things.

I’m not sure how I should deal with various “inputs” / how it should interact with knowledge from the outside environment. Two approaches I’ve considered and tried so far:

1, I have a dedicated “Query” class that holds various bools. At the end of the Tick() method in each state I make some checks like

if (queries.JumpUp) { SetState(JumpState); }

that take care of switching states. To change states, I simply set the bool to true.
This seems to work fine, creates a very loose relationship between the “query” and the resulting behaviour, and lets me place pretty much all the transition logic in a dedicated method (my base Tick() method calls an CheckForTransitions() method at its end, and it’s this method that I override and put all the transition logic in).
It works fine so far, but I’m a bit worried that this type of logic might be almost a bit too loose. I think it might be somewhat similar to the blackboard design pattern. It also feels a bit like an observer pattern, which could be useful – I might have multiple different types of state machines active at the same time. A “Query” class that has booleans like I mentioned seems like a very natural way of implementing a general interface layer that will allow for loose “communication” between the layers etc.

2, Create virtual methods for all possible “events” I would like to be handled.

public override void TryJump() { SetState(JumpState); }

To change states, I explicitly call the method above (or some wrapper around it, implemented inside the StateMachine).

This also seems to work fine. Some slight negatives I can see compared to 1:
With approach 1, there’s no issues if I choose to update my state machine independently of the game loop. With approach 2, there could be multiple calls that result in a transition between two state machine ticks/updates. This could be fixed by the making calls like “TryJump()” change some buffer variable that would just hold the desired next state, and the actual transition would perhaps happen at the end/start of the state machine update (rather than “TryJump()” causing an immediate change in states).
But at that point I’m getting very close to the approach used in 1, so I’d think I might as well just use that.

I don’t have a single nice place in the code where I can check exactly what sort transitions can happen and what their conditions are.
I will have to have tons of virtual methods for each state, for each “TryJump” type event. If I don’t want to work with a direct reference to the state machine, I will have to also write wrappers, that will call those TryJump events the currently active StateMachines – so something like say:

public void TryJump() 
{ 
 foreach (StateMachine stateMachine in ActiveStateMachines) 
     stateMachine.currentState.TryJump(); 
}

Despite that, something just feels a bit off about the method in 1, – using booleans like that just seems a bit weird. I’m also not terribly comfortable with event based approaches, and it feels a bit “wrong” to use a special layer with booleans etc., when I could just make a direct call that does what I want using approach 2.

c++ – How to voxel grid without losing our scalar values in PCL?

I have made my own point type which has a scalar value. My point cloud is huge, so I need to voxel grid it.

However, when I voxel grid my data I lose my scalar values, they are turned to 0 :

//include
#define PCL_NO_PRECOMPILE
#include <pcl/pcl_macros.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/filters/approximate_voxel_grid.h>
using namespace pcl;


//defining my point type
struct MyPointType
{
    PCL_ADD_POINT4D;                  // preferred way of adding a XYZ+padding

    float beautiful_name;


    EIGEN_MAKE_ALIGNED_OPERATOR_NEW     // make sure our new allocators are aligned
} EIGEN_ALIGN16;                    // enforce SSE padding for correct memory alignment


POINT_CLOUD_REGISTER_POINT_STRUCT(MyPointType,           // here we assume a XYZ + "test" (as fields)
    (float, x, x)
    (float, y, y)
    (float, z, z)
    (float, beautiful_name, beautiful_name)
)


//main program
int main(int argc, char** argv)
{
    pcl::PointCloud<MyPointType>::Ptr cloud(new pcl::PointCloud<MyPointType>);
    pcl::PointCloud<MyPointType>::Ptr cloud2(new pcl::PointCloud<MyPointType>);

    for (int i = 0; i < 500; i++)
    {
        MyPointType p;
        p.x = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
        p.y = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
        p.z = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
        p.beautiful_name = 55;
        cloud->push_back(p);
    }

    pcl::VoxelGrid<MyPointType> vo;
    vo.setInputCloud(cloud);
    vo.setLeafSize(0.1f, 0.1f, 0.1f);
    vo.setMinimumPointsNumberPerVoxel(1);
    vo.filter(*cloud2);



    for (auto& p : *cloud2)
    {
        std::cout << p.beautiful_name << std::endl;
    }

return 0;
}

If I execute the program above, only 0s are printed, there are no “55”. Do a voxel grids always loose scalar values ?

sql – How to search to see if values of a column exist in another table as sub-string in BQ

I am familiar with the CONTAINS_SUBSTR function in BigQuery.
 Here’s an example from the official BigQuery documentation of how it works (with minor modification):



WITH Recipes AS
 (SELECT 'Blueberry pancakes' as Breakfast, 'Egg salad sandwich' as Lunch, 'Potato dumplings' as Dinner UNION ALL
  SELECT 'Potato pancakes', 'Toasted cheese sandwich', 'Beef stroganoff' UNION ALL
  SELECT 'Ham scramble', 'Steak avocado salad', 'Tomato pasta' UNION ALL
  SELECT 'Avocado toast', 'Tomato soup', 'Blueberry salmon' UNION ALL
  SELECT 'Corned beef hash', 'Lentil potato soup', 'Glazed ham')
SELECT * FROM Recipes;

Recipes:

Breakfast Lunch Dinner
Blueberry pancakes Egg salad sandwich Potato dumplings
Potato pancakes Toasted cheese sandwich Beef stroganoff
Ham scramble Steak avocado salad Tomato pasta
Avocado toast Tomato soup Blueberry salmon
Corned beef hash Lentil potato soup Glazed ham
SELECT * FROM Recipes WHERE CONTAINS_SUBSTR((Lunch), 'potato');

Result:

Breakfast Lunch Dinner
Corned beef hash Lentil potato soup Glazed ham

However, instead of a single STRING literal (potato in the above example), I want to be able to use a table with a single column that contains the keywords that I’m looking for:

Keywords AS
(SELECT 'potato' as ingredient UNION ALL
 SELECT 'cheese' UNION ALL
 SELECT 'egg')

Desired output:

Breakfast Lunch Dinner
Corned beef hash Lentil potato soup Glazed ham
Potato pancakes Toasted cheese sandwich Beef stroganoff
Blueberry pancakes Egg salad sandwich Potato dumplings

Is there a way to use CONTAINS_SUBSTR or any other function and pass the ingredient column of Keywords as input to it to get the desired output?


Example of a query that I’m looking for (this does not work):


SELECT * FROM Recipes WHERE CONTAINS_SUBSTR((Lunch), (SELECT ingredient from Keywords));

number theory – A question in calculating a constant in section square free values of quadratic polynomials

I am studying square free values of quadratic polynomials from class notes and I am struct on a deduction.

Consider this conjecture, I have no problem in understanding it:

enter image description here

Consider this theorem, I have no problem in understanding it.
enter image description here

But I have problem in calculating $c_f$

enter image description here

I don’t understand , how author wrote $rho(p^2) = 1+ (-1/p) $.

Kindly consider giving any hints.