id stringlengths 5 11 | text stringlengths 0 146k | title stringclasses 1
value |
|---|---|---|
doc_3100 | MWE:
require 'nn';
char = nn.LookupTable(100,10,0,1)
charRep = nn.Sequential():add(char):add(nn.Squeeze())
c = {}
c[1] = torch.IntTensor(5):random(1,100)
c[2] = torch.IntTensor(2):random(1,100)
c[3] = torch.IntTensor(3):random(1,100)
--This works fine
print(c)
charFeatures = {}
for i=1,3 do
charFeatures[i] = char... | |
doc_3101 | json data
"MenuRole": [
{
"id": 1,
"name": "Manage User",
"icon": "ion-person",
"path_fe": "dashboard/user",
"cmsmenuschild": [
{
"name": "Create User",
"cmsp... | |
doc_3102 | It is rather easy to get a boolean vector with True corresponding to all rows that meet the condition. In order to delete them, I thought if I could invert the boolean vector (have False where the the condition is met), I can just index my DataFrame with the inverted vector and be done.
In the process I have, I think m... | |
doc_3103 | document.getElementById("myId").children;
outputs an array of DOM elements
But if I do:
$("#myId").get().children;
outputs undefined
Why?
jQuery .get() documentation says:
.get() method grants access to the DOM nodes underlying each jQuery object
so why are the children empty if the DOM node with the id=myId has ch... | |
doc_3104 | private void changeColor( int colorId ) {
ActionBar actionBar = ((ActionBarActivity )getActivity()).getSupportActionBar();
actionBar.setBackgroundDrawable( new ColorDrawable( colorId ) );
this.getView().setBackgroundColor( getResources().getColor( colorId ) );
}
I have the actionbar themed to be blue in m... | |
doc_3105 | byte tmp = (byte)ran.Next(10);
Is there an alternative to this code?
It does not seem to have fully random behavior.
A: There are multiple reasons for why this could occur. One common problem is to create multiple instances of the Random class within a program. When using the Random class you should only create o... | |
doc_3106 | I tried to get rid of backslash-quote using the following but it ignores it and returns the original string. What am I doing wrong here?
var uNewDate = newDate.replace(/\\\"/gi, '');
here is the entire function:
function pageLoad() {
setStartDate(new Date());
}
// \"3/7/2018\"
function setStartDate(newDate) {debu... | |
doc_3107 | Following is the code.
#!/usr/bin/perl
use WWW::Scripter;
use URI;
$w = new WWW::Scripter;
$w->use_plugin('JavaScript');
$response=$w->get("sdt1.corp.xyz.com:8080/click/phoenix/339cd9314fe0136d3c30f6e9984b1ddc?clickId=sfshsksk1234go");
$data_ref = $response->content_ref( );
#this response is a html code with a js li... | |
doc_3108 | - panel data set
- 10 time periods
I need to create a dummy variable, RL that is equal to 1 (TRUE) forever if the dummy variable RS has been 1 once.
in other words:
The new variable RL (spanning 10 periods) has to be 1 in t and all subsequent periods if RS was 1 in period t-1. If no TRUE has happened in RS and RS is 0 ... | |
doc_3109 | var loader = new THREE.OBJLoader();
loader.load( 'models/refTestblend.obj', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.material = envMaterial;
}
} );
scene.add( object );
} );
Unfortunate... | |
doc_3110 | [{
"id": "1",
"title": "test 1",
"venue": "test 1",
"day": "12",
"month": "January",
"year": "2016",
"date": "2016-02-23T14:53:24.118Z",
"tasks": []
}, {
"id": "2",
"title": "test 2",
"venue": "test 2",
"day": "22",
"month": "April",
"year": "2016",
"date": "2... | |
doc_3111 | var params = "type=search" + "&content="+encodeURIComponent(document.getElementsByTagName("body")[0].innerHTML);
xmlhttp.open("POST", "/service/p.aspx", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.send(params);... | |
doc_3112 | @Component
class MySpringClass {
private static PaymentRepo paymentRepo;
@Autowired
MySpringClass(PaymentRepo repo) { MySpringClass.paymentRepo = repo; }
static void usePaymentRepoToDoStuff() { …. using paymentRepo ….. }
}
I've read that assigning static references via autowiring is not recommended. I didn't... | |
doc_3113 | Because the data is asynchronous it doesn't appear to work in time - so the console outputs the stations names at the end of the console.
But the correct station name is not injected to the correct station id (e.g. station-4).
Any help much appreciated. Please note, I am ideally looking for a solution that doesn't not... | |
doc_3114 | printf("Change in dollars: ");
change= GetFloat();
cents= round(change*100);
printf("Cents is %f",cents);
This is a logical error because the program runs fine but there is something wrong with the mathematics for example if i enter 1.50 when prompted, the return i get is 1004 which is clearly wrong. What i want to ha... | |
doc_3115 |
However, I get We encountered a problem processing your request issue.
What might be the issue? I don't get any response in my call_back url too.
I used the code from Intuit Sample app.
public static String REQUEST_TOKEN_URL = "https://oauth.intuit.com/oauth/v1/get_request_token";
public static String ACCESS_TOKEN_U... | |
doc_3116 | The idea is to rotate each array element right by a given number of places: e.g. [3, 8, 9, 7, 6] rotated 3 times gives [9, 7, 6, 3, 8].
It wasn't so difficult to figure out solution using extra array. The only required think was new position calculated:
(old_position + rotations)%array_size
However, I've started to th... | |
doc_3117 | I tried something like this but I'm sure that it's not correct:
Picasso.get()
.load(R.drawable.blue_xml_popcorn)
.into((Target) BteyoutubePlay_popcorn);
So if somebody has a solution, it will be really helpful. :)
Thanks!
| |
doc_3118 | Expected output:
./my_script.sh hello bye 2
hello
bye
2
my output:
./my_script.sh hello bye 2
Word1=1
meu_script.sh: line 2: read: `Word2=': not a valid identifier
hello
bye
2
Program:
#!/bin/bash
read -p "Word1=" $1 "Word2=" $2 "Num=" $3
Word1="${1}"
Word2="${2}"
Num="${3}"
echo ${1}
echo ${2}
echo ${3}
Can someon... | |
doc_3119 | I also need to check if email address change then it must check this email is unique or not. If not unique then user can't update the data and validation message show "Email Address already exists".
Script
$('#UserEmail').blur(function () {
var url = "/Account/CheckUserEmail";
var Email = $('#UserEmail').val();
... | |
doc_3120 | I have googled sadly I have had no luck and I was wondering if anyone knows of a script that can read (icecast ICY metadata?)
A: Please note that web browsers don't support ICY metadata, so you'd have to implement quite a few things manually and consume the whole stream just for the metadata. I do NOT recommend this.
... | |
doc_3121 | void testMessage() {
verifySomething(this.driver, "iPhone");
}
void verifySomething(WebDriver driver, String userAgent) {
String script = null;
if (driver instanceof HtmlUnitDriver) {
script = "navigator.userAgent=" + "'" + userAgent + "';";
}
else {
// something
}
((Javascr... | |
doc_3122 | Typical thumbnailLink returned: https://lh4.googleusercontent.com/p4OAiOaP0dBaE4JF…1vTCqNEUVdTH9CoCDAeAZB4D38cIvYpktGekW0IuBpRI=s220
How can I manage to display these images by using the thumbnailLink on localhost please?
import React, { useState, useEffect } from 'react'
export const App = () => {
const [ googleA... | |
doc_3123 | {
$user = auth()->user();
$lat = auth()->user()->latitude;
$lon = auth()->user()->longitude;
$radius = 3; // km => converted to meter
$angle_radius = (float)$radius / ( 111 * cos( (float)$lat ) ); // Every lat|lon degree° is ~ 111Km
$min_lat = (float)$lat - (float)$angle_radius;
$max_lat =... | |
doc_3124 |
TITLE: Connect to Server
Cannot connect to ..
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connectio... | |
doc_3125 | when i use "var_dump" it shows my function is working correctly and too many $result numbers are created. but when i use ORM INSERT Statement to save them into my database , it always SAVE : 2147483648 in database and it seems it's not depended on my $result !!!!!
here is my code :
public function Timer($Number)
... | |
doc_3126 | My user should enter information for an appointment. Once Submit is hit a document window should pop up. The submit button appears to work. The clear button is working also. I programmed a function to handle the window and set the onSubmit to return the function.
< script type = "text/javascript" >
function pop... | |
doc_3127 | Exception Type:
System.Web.HttpException
Exception: A potentially dangerous Request.Path value was detected from the client (:).
Stack Trace:
at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)
This happens when there's a c... | |
doc_3128 | When I place a dx-toolbar and set locateInMenu="always" for toolbar items, I see a dropdown button with dx-icon-overflow.
Is there any way to customize this button to have a string on it?
A: I used CSS to update that dropdown button.
.customized-toolbar .dx-toolbar-button .dx-dropdownmenu-button .dx-button-content {
... | |
doc_3129 | function previewPDF(url,canvasName){
PDFJS.workerSrc = 'js/pdfJS/pdf.worker.js';
PDFJS.getDocument(url).then(function getPdf(pdf) {
pdf.getPage(1).then(function getPage(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = document.getElemen... | |
doc_3130 | In particular we need to parse some X-prefixed response headers, for example X-Total-Results: 35.
Opening the Network tab of the browser dev tools and inspecting the resource relative to the $http request, I verified that the response header X-Total-Results: 35 is present.
in the browser, the X-Total-Results header is ... | |
doc_3131 | In "desktop" mode, I want the brand logo and other words on the left, and the menu on the right.
In "mobile" mode, I would a block with the logo and other words, and below the menu that should take the whole row.
Any suggestion to obtain this result?
Link to JsFiddle
As you can see I defined some CSS ids, just to have:... | |
doc_3132 | For this i have use model in view.My code is
@using MyProject.Models
@model Role
<h2>AddRole</h2>
@using (Html.BeginForm()){
@Html.LabelFor(m=>m.RoleName)
@Html.TextBoxFor(m=>m.RoleName)<br />
<input type="submit" value="Add Role" />
}
After submitting,it goes to AddRole action in my controller,where I am adding thi... | |
doc_3133 | Field2.Text = Text((5*Value(Self.Text))-10)
Any suggestions please?
| |
doc_3134 | <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>my-search-fronte... | |
doc_3135 | In my work, i will move in a map, but selenium will work well ,when my screen resolution is 1920*1080, and it doesn't work when my screen resolution is 1366*768.
the code is that:
ChromeDriver driver =(ChromeDriver)webDriver;
WebElement map =driver.findElementsByClassName("ol-unselectable").get(0); // a MAP
A... | |
doc_3136 | Example:
I have input dataset with 3 columns[EMPID,EMPNAME,EMP_DEPT] and I want to process these data using mapreduce. In the reduce phase is it possible to add new columns say TIMESTAMP(system timestamp when record get processed). Output of the reducer should be EMPID,EMPNAME,EMP_DEPT,TIMESTAMP
Input Data:
EMPID EMPN... | |
doc_3137 | But the problem is that it tells me that the source file doesn't exist, what did I do wrong?
Also, is That even a good approach? It will save a copy of the images in folders and retrieve this data in a recycler view; Is there a reason to preferer using a database?
Here is the code for receiving a shared image:
String a... | |
doc_3138 | I am trying to use g_object_set_property as follows:
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GValue val = G_VALUE_INIT;
g_value_init (&val, G_TYPE_ENUM);
g_value_set_enum (&val, PANGO_ELLIPSIZE_END);
g_object_set_property (G_OBJECT(renderer), "ellipsize", &val);
However, I get an error message at r... | |
doc_3139 | What I want to do is compare what the backend spits out vs what I have in my hash thats like an index so when I render my view I can have the display look a bit more appealing.
Now I could do something like this with php and an array
array("monkey" => "Monkey", "server" => "server")
and then do a str_replace("monkey",... | |
doc_3140 | Thank you!
Please keep in mind I'm very new to programming and am not familiar with lambda or other complicated ways to solve this.
A: One way to do so would be to use collections.Counter
from collections import Counter
>>> d = {'a': 5, 'b': 3, 'c': 5, 'd': 1, 'e': 5}
>>> c = Counter(d.values())
>>> c
[(5, 3), (1, ... | |
doc_3141 | In the past I've used Rubymine and I remember it automatically loading the folders for all the gems, in the "project view" on the left side, at the bottom, titled "External Libraries." For some reason I am only getting what's in the picture below. I feel as if it may be some sort of RVM issue because it's only showing ... | |
doc_3142 | E.g- suppose i want my header with value Address (*"MANDATORY) with below given color.
Address - in Black Color
*"MANDATORY - in Red Color
I came through a method for changing the fontColor provided by apache-poi but that is changing the font color of whole cell value but i want a specific text in different color.
How ... | |
doc_3143 | "{\"id\":\"c39fe0f5f9b7c89b005bf3491f2a2ce1\",\"token\":\"c39fe0f5f9b7c89b005bf3491f2a2ce1\",\"line_items\":[{\"id\":32968150843480,\"properties\":{},\"quantity\":2,\"variant_id\":32968150843480,\"key\":\"32968150843480:4a6f6b7d19c7aef119af2cd909f429f1\",\"discounted_price\":\"40.00\",\"discounts\":[],\"gift_card\":fal... | |
doc_3144 | I think I know how to get rid of the blank spaces, but my list has some data that no weighted average for that day. So I need to search my list and delete any value that does not have a space after it, then search back through the list and delete all the spaces.
For example I want this:
[754, 753.554, '', '', '', '', '... | |
doc_3145 |
Now what I want to do is the contents that are generated from UserDontrol, the values that are underlined I want to store them in database. I create a public class but in database it is stored as empty value (not NULL).
These are the codes:
.ascx.cs file
using System;
using System.Collections.Generic;
using System.Lin... | |
doc_3146 | scalaVersion := "2.12.12"
using play-json
"com.typesafe.play" %% "play-json" % "2.9.1"
If I have a Json object that looks like this:
{
"UpperCaseKey": "some value",
"AnotherUpperCaseKey": "some other value"
}
I know I can create a case class like so:
case class Yuck(UpperCaseKey: String, AnotherUpperCaseKey:... | |
doc_3147 | When myURL is set to 'http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml' as shown in the following code snippet, the map plus overlay displays as expected. The overlay file is taken from an example shared by Google.
When myURL is set to 'https://www.dropbox.com/s/hq09lfaya2cmu87/test.kml', Google returns an... | |
doc_3148 | I need the Equivalent of
lblPatient.Text = DirectCast(sender, Control).ID
'writen in vb 2010 visual web deveoper
For vb 2008
Code
Imports System.Data.SqlClient
Imports System.Data
Public Class FormRm3A
Dim Labels(40) As Label
Dim X As Integer
Dim Y As Integer
Private Sub FormArrayTest_Load(ByVal ... | |
doc_3149 | #import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\OFFICE15\MSO.DLL" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
#import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
#import "C:\Prog... | |
doc_3150 | Object reference not set to an instance of an object. in line 48 i.e. con.open();
Please help me solve it. And when i click on edit and insert values in shown txtboxes and then click update it shows another error:
Specified argument was out of the range of valid values. in the line 74 of my code i.e.
EmailID = (Tex... | |
doc_3151 | It was running a task with 0 reduce tasks.
The output of each map task was clearly being written on the HDFS as part-000**
But then the system on which the hadoop system was running crashed. Now i want to copyToLocal the output of the Map tasks that completed successfully.
I can see all the "parts" listed when i do ha... | |
doc_3152 | When an entry get's deleted / modifyed / added, there happens an api-call to store / modify / delete the data on the database. In case I get a 200 status response, I'd like to refresh the list on the Ui.
public deleteObject {
this.http.delete(...)
.subscribe( () => {
// here the getter method would get ca... | |
doc_3153 | TreeMap<Date,String> map = new TreeMap<Date,String>();
map.put(new Date(2011,1,1), "32,1");
map.put(new Date(2011,3,1), "35");
map.put(new Date(2011,4,5), "38,9");
map.put(new Date(2011,8,2), "57!!");
Then I'm lost. I've found this :
NavigableSet<Date> dates = donnees.descendingKeySet();
Then I don't know how to say ... | |
doc_3154 | <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"></link>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"></link>
<script type="script" src="https://maxcd... | |
doc_3155 | ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
When running the same command with -vvv like pip install numpy -vvv it gives the following output.
Using pip 20.2.1 from c:\program files\python38\lib\site-packages\pip (python 3.8... | |
doc_3156 | I am trying to send a gift with FBSDKGameRequestContent and I get 2 different errors with 2 different gifts while I am sending from the same code:
FBSDKGameRequestContent *gameRequestContent = [[FBSDKGameRequestContent alloc] init];
gameRequestContent.message = @"Your gift is waiting for you";
gameRequestContent.title... | |
doc_3157 | When I run my tests, the result is:
System.IO.FileNotFoundException : Could not load file or assembly
'System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
The problem is when I create an instance of a class of the references assembly.
How could create a net core or netstanda... | |
doc_3158 | showErrors: function(errorMap, errorList) {
$("#summary").html("Your form contains <a href='#' class='errorCnt'>" + this.numberOfInvalids() + " errors</a>, see details below.");
this.defaultShowErrors();
}
the code works good, but additionally, the page focus moves to first error input field. I don't want this... | |
doc_3159 | I can run mvn gwt:run and get the form modeler working with jetty.
When I take the WAR file from showcase and try to deploy it in jboss-as-7.1.1 or jboss-eap-6.2.0 it always fails deployment with following error:
11:52:37,365 ERROR [org.jboss.as.server] (HttpManagementService-threads - 10) JBAS015870: Deploy of deploym... | |
doc_3160 | res.setHeader("content-type", 'application/octet-stream');
res.setHeader("Content-Disposition", 'attachment; filename="' + 'original' + '"' + "; filename*=UTF-8''" + 'original' + "");
var readStream;
var exists = fs.existsSync(fullPath);
if (exists) {
callback(true);
... | |
doc_3161 | require(rjags)
Loading required package: rjags
Loading required package: coda
Error: package or namespace load failed for ‘rjags’: .onLoad failed
in loadNamespace() for 'rjags', details: call: fun(libname, pkgname)
error: Failed to locate any version of JAGS version 4
The rjags package is just an interface to the J... | |
doc_3162 | J_10542741@cs3060:~/assn3$ ./assn3 12
12: 2, 2, 3,
My problem is when I test it on these two other cases:
A) Multiple Arguments:
J_10542741@cs3060:~/assn3$ ./assn3 10 8 6
10: 2, 5,
8: 2, 5,
6: 2, 5,
B) Using a Range of Numbers (i.e. {1..5}):
J_10542741@cs3060:~/assn3$ ./assn3 {1..5}
1:
2:
3:
4:
5:
I've looked around... | |
doc_3163 | UITextField * myTextField = [[UITextField alloc]init];
NSString * myString = myTextField.text; //Set as reference to string here
NSLog(@"%@", myString); //Should be null
[myTextField setText:@"foobar"];
NSLog(@"%@", myString); //Should be foobar
I'm expecting that when the value of myTextField text to change, that ... | |
doc_3164 | There is a message producer (Stateless bean), that is sending messages to the Queue (configured on Wildfly 10). And a Message driven bean consuming the messages from the Queue. Also there is a servlet that calls the "SendToQueue(MailEvent mailEvent)" method of my message producer bean.
Now I have an idea to create anot... | |
doc_3165 | Those that are pinnned are important, so if I put the number on 6, open 6, pin 2 then I should be able to open 2 more.
Also, close all but pinned!?
A: Under General-> Editors
"When all editors are dirty or pinned" - choose open new editor
(I'm using Eclipse 3.7.2)
| |
doc_3166 | Already, I have used the fixedThreadPool to execute these threads.
The problem is that sometimes program control remained in the first running thread and the second one never gets the chance to go to its running state.
Here is a similar sample code to mine:
public class A implements Runnable {
@Override
pub... | |
doc_3167 | [{"scan_status":"ok","visitorData":[{"visitorCompany":"xyl","visitorStreet":"street","visitorBranche":"health","visitorEmail":"[email protected]","lastmodified":"2014-12-15 14:18:55"}]}]
Now in Swift I would like to store this data, and for this I am trying to parse the data into Swift variables, however I got ... | |
doc_3168 | np.random.seed(50)
df = pd.DataFrame(np.random.randint(0,9,size=(30, 3)), columns=list('ABC'))
print df
df
A B C
0 0 0 1
1 4 6 5
2 6 6 5
3 2 7 4
4 3 6 4
5 1 5 0
6 6 3 2
7 3 3 3
8 2 0 3
9 2 0 3
10 0 0 7
11 3 8 7
12 4 4 0
13 0 3 3
14 1 4 5
15 7 0 3
16 5 6... | |
doc_3169 | brew install [email protected]
but I keep receiving
Warning: No available formula with the name "[email protected]".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps... | |
doc_3170 | Any help or a gentle shove in the right direction is greatly appreciated :)
Here's where I am:
namespace TheAirline.GraphicsModel.PageModel.PageFinancesModel
{
/// <summary>
/// Interaction logic for PageFinances.xaml
/// </summary>
public partial class PageFinances : Page
{
private Airline ... | |
doc_3171 | I've tried using a LayerDrawable but the checkmark icon gets squished if the image I set using android:src= isn't the same height. Here's what the code for that looks like right now:
AppCompatImageView imageView = (AppCompatImageView) view;
int id = getResources().getIdentifier("drawable/" + view.getTag(), null, getPa... | |
doc_3172 |
Msg 557, Level 16, State 2, Line 2 Only functions and some extended
stored procedures can be executed from within a function.
On the other two it works fine. Is there a setting we are missing on that one specific SQL Server? Or can it be something else? The internet is ambiguous about this error.
Thank you.
A: Tha... | |
doc_3173 | I want to call a method but the method does not get called and I do not know why.
var rows = GetDataGridRows(dgTickets);
int intTickets = 0;
foreach (System.Windows.Controls.DataGridRow r in rows)
{
//some code
}
private IEnumerable<System.Windows.Controls.DataGridRow>
... | |
doc_3174 | <Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Name="c1" ></ColumnDefinit... | |
doc_3175 | ERROR: type should be string, got "https://stackoverflow.com/a/356187/1829329\nBut it only works for integers as n in nth root:\nimport gmpy2 as gmpy\n\nresult = gmpy.root((1/0.213), 31.5).real\nprint('result:', result)\n\nresults in:\n---------------------------------------------------------------------------\nTypeError Traceback (most recent call last)\n<ipython-input-14-eb4628226deb> in <module>()\n 8 \n----> 9 result = gmpy.root((1/0.213), 31.5).real\n 10 \n 11 print('result:', result)\n\nTypeError: root() requires 'mpfr','int' arguments\n\nWhat is a good and precise way to calculate such a root?\n(This is the python code representation of some formular, which I need to use to calculate in a lecture.)\nEDIT#1\nHere is my solution based on Spektre's answer and information from the people over here at http://math.stackexchange.com.\nimport numpy as np\n\ndef naive_root(nth, a, datatype=np.float128):\n \"\"\"This function can only calculate the nth root, if the operand a is positive.\"\"\"\n logarithm = np.log2(a, dtype=datatype)\n exponent = np.multiply(np.divide(1, nth, dtype=datatype), logarithm, dtype=datatype)\n result = np.exp2(exponent, dtype=datatype)\n return result\n\ndef nth_root(nth, a, datatype=np.float128):\n if a == 0:\n print('operand is zero')\n return 0\n elif a > 0:\n print('a > 0')\n return naive_root(nth, a, datatype=datatype)\n elif a < 0:\n if a % 2 == 1:\n print('a is odd')\n return -naive_root(nth, np.abs(a))\n else:\n print('a is even')\n return naive_root(nth, np.abs(a))\n\n\nA: see Power by squaring for negative exponents \nanyway as I do not code in python or gmpy here some definitions first:\n\n\n*\n\n*pow(x,y) means x powered by y\n\n*root(x,y) means x-th root of y\nAs these are inverse functions we can rewrite:\n\n\n*\n\n*pow(root(x,y),x)=y\n\nYou can use this to check for correctness. As the functions are inverse you can write also this:\n\n\n*\n\n*pow(x,1/y)=root(y,x)\n\n*root(1/x,y)=pow(y,x)\nSo if you got fractional (rational) root or power you can compute it as integer counterpart with inverse function.\nAlso if you got for example something like root(2/3,5) then you need to separate to integer operands first:\nroot(2/3,5)=pow(root(2,5),3)\n ~11.18034 = ~2.236068 ^3\n ~11.18034 = ~11.18034\n\nFor irational roots and powers you can not obtain precise result. Instead you round the root or power to nearest possible representation you can to minimize the error or use pow(x,y) = exp2(y*log2(x)) approach. If you use any floating point or fixed point decimal numbers then you can forget about precise results and go for pow(x,y) = exp2(y*log2(x)) from the start ...\n[Notes]\nI assumed only positive operand ... if you got negative number powered or rooted then you need to handle the sign for integer roots and powers (odd/even). For irational roots and powers have the sign no meaning (or at least we do not understand any yet).\n\nA: If you are willing to use Python 3.x, the native pow() will do exactly what you want by just using root(x,y) = pow(x,1/y). It will automatically return a complex result if that is appropriate.\nPython 3.4.3 (default, Sep 27 2015, 20:37:11)\n[GCC 5.2.1 20150922] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> pow(1/0.213, 1/31.5)\n1.0503191465568489\n>>> pow(1/0.213, -1/31.5)\n0.952091565004975\n>>> pow(-1/0.213, -1/31.5)\n(0.9473604081457588-0.09479770688958634j)\n>>> pow(-1/0.213, 1/31.5)\n(1.045099874779588+0.10457801566102139j)\n>>>\n\nReturning a complex result instead of raising a ValueError is one of changes in Python 3. If you want the same behavior with Python 2, you can use gmpy2 and enable complex results.\n>>> import gmpy2\n>>> gmpy2.version()\n'2.0.5'\n>>> gmpy2.get_context().allow_complex=True\n>>> pow(1/gmpy2.mpfr(\"0.213\"), 1/gmpy2.mpfr(\"31.5\"))\nmpfr('1.0503191465568489')\n>>> pow(-1/gmpy2.mpfr(\"0.213\"), 1/gmpy2.mpfr(\"31.5\"))\nmpc('1.0450998747795881+0.1045780156610214j')\n>>> pow(-1/gmpy2.mpfr(\"0.213\"), -1/gmpy2.mpfr(\"31.5\"))\nmpc('0.94736040814575884-0.094797706889586358j')\n>>> pow(1/gmpy2.mpfr(\"0.213\"), -1/gmpy2.mpfr(\"31.5\"))\nmpfr('0.95209156500497505')\n>>> \n\n\nA: Here is something I use that seems to work with any number just fine:\nroot = number**(1/nthroot)\nprint(root)\n\nIt works with any number data type.\n" | |
doc_3176 | I tried using the java.awt RGBoHSB method to get the float array with HSB. The Hue value returned from the method does not seem to be in degrees/radians to me hence I am not able to bifurcate. Moreover I want to avoid using the java.awt so could someone suggest some alternative method for the conversion of Hex colors t... | |
doc_3177 | ID DisplayName
1 Surname,User1 [Department]
2 Surname,User2 [Department]
ADSI Query:
DECLARE @sql nvarchar(MAX)
DECLARE @Mail varchar(255)
set @sql = 'SELECT TOP 1 @Mail = mail
FROM openquery(ADSI ,''
SELECT Name, displayName,givenname,distinguishedName, SAMAccountName ,mail
FROM ''''LDAP://DC=Domai... | |
doc_3178 | <span editable-select="item.myDropdown" e-multiple e-ng-options="rol as rol.roleName for rol in myCtrl.roles" onaftersave="showUsers.save($data)" ng-model="myRole.roleSelected"></span>
Because I have a function on my script where it receives the $data as parameter. Here's my sample code:
$scope.save = function (data) ... | |
doc_3179 |
A: This is documented by exception--the default applies except for where it is documented not to.
If you don't specify -1 or --single-transaction, then it runs in (the default) autocommit mode. Meaning each SQL statement commits itself upon success. Each COPY therefore is one large transaction of the while table dat... | |
doc_3180 | type I = () => () => () => "a" | "b" | "c";
Is there a way to create a generic type Unwrap such that Unwrap<I> evaluates to "a" | "b" | "c"?
type I = () => () => () => "a" | "b" | "c";
type Result = Unwrap<I>; // "a" | "b" | "c"
The following (ofc) produces a circularity error:
type Unwrap<
T extends (...args: any... | |
doc_3181 | Problem 1 - I cannot loop through the list of variables
Problem 2 - I need to insert each output from the values into Mongo DB
Here is an example of the list:
121715771201463_626656620831011
121715771201463_1149346125105084
Based on this value - I am running a code and i want this output to be inserted into MongoDB. R... | |
doc_3182 | such as VMIN*, VCVTT*, VGETEXT*, VREDUCE*, VRANGE* etc.
Intel declares SAE-awareness only with full 512bit vector length, e.g.
VMINPD xmm1 {k1}{z}, xmm2, xmm3
VMINPD ymm1 {k1}{z}, ymm2, ymm3
VMINPD zmm1 {k1}{z}, zmm2, zmm3{sae}
but I don't see a reason why SAE couldn't be applied to instructions where xmm or ymm regis... | |
doc_3183 | Whenever a value of the subscribed key changes, the properties of the subscribed QObject changes to the new value. Works in Qt/C++ fine.
Now I want to make a view in QML. Is it possible to pass from QML to C++ an object with 3 parameters:
*
*QObject pointer of the QML object
*property as string
*DB-key as string... | |
doc_3184 | i added the next lines for supported in ios8, but when these lines are added the ipa works on ios8 but not on ios7 on ios7 the application is closed immediately after i open it.
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
#ifdef __IPHONE_8_0
//Right,... | |
doc_3185 | Thor is very popular and has more followers and contributers than Boson, but Boson looks far more powerful than Thor and the architecture is very well thought out.
In Boson you:
*
*can add methods that are used both in the console and ruby environment. So you don't have to both have Thorfiles for console and gems fo... | |
doc_3186 | The idea is to use all the available HDFS disk space for testing purposes.
I have seen quite a few questions asking how to do this on other vendor’s Hadoop clusters but not on IBM Analytics Engine.
A: Using Ambari you would do something like the following:
*
*Connect to the Ambari web URL.
*Click on the HDFS tab o... | |
doc_3187 | Referencing the token smart contract in my crowdsale smart contract allows me to call the token functions.
However... I cannot use the modifier from the token smart contract.
contract Crowdsale is Token {
token private _token;
constructor (ERC20 token) public {
require(address(token) != address(0));
... | |
doc_3188 | The issue is when I'm trying to align my TouchableOpacity to something like center or flex-end it does not work inside an Image tag. The TouchableOpacity simply disappears...
Demonstration of the issue:
Here I tried with a View instead of an Image It works...
A: I realised the issue.
Must set:
width: null,
height: n... | |
doc_3189 | def callback(a,b,c):
print 'i+2'
ButtonsList=[]
VarList=[]
i=0
while i<30:
VarList.append(tk.BooleanVar())
VarList[i].trace('w',callback)
ButtonsList.append(tk.Checkbutton(root, text="This is a CB",variable=VarList[i]))
ButtonsList[i].place(x=x,y=i*20)
i+=1
A: You could wrap you... | |
doc_3190 | Here's the view code (razor):
@Using Html.BeginForm()
@<fieldset>
<legend></legend>
<br />
<fieldset>
<legend>Datos Generales</legend>
<table>
<tr>
<td style="border-width:0px; border-style:solid">
@Html.La... | |
doc_3191 | I have a print statement in some code (with many contributors). It is printing:
<soapenv:Body><QueryPerf xmlns="urn:vim25"><_this type="PerformanceManager">PerfMgr</_this><querySpec><entity type="VirtualMachine">vm-1442</entity><startTime>2019-05-21T11:32:32.362213-04:00</startTime><endTime>2019-05-22T11:32:32.362213-... | |
doc_3192 | <html>
<head>
<script>
window.onload = init;
function init() {
var button = document.getElementById("submit");
button.onclick = changeDiv;
}
function changeDiv() {
var counter=1
var name = "ul";
var textInput = document.getElementById("textInput");
var userInput = textInput.value;
alert("add... | |
doc_3193 | I created a view ("center") that returns a single center as a page (machine name page_1"). The page can be accessed from the URL /center/## where ## is the node ID of the center. I used a template to get that to display just the center content without the rest of a normal page.
I created a .js file that, in theory, wil... | |
doc_3194 | Here is my Code snippet:
@Modifying
@Query("UPDATE TBL_NAME SET DELETE_FLAG = 'YES' WHERE DELETE_FLAG = 'NO'
AND FILE_NM = :FILE_NM")
public void softDelete(@Param("FILE_NM") String fileName)
{
}
I am not getting any error, but data is not being updated in database.
Actual result must be like all the existing rows mu... | |
doc_3195 | "data":{facebook":{"message"}},
but I keep getting square brackets:
"data":{"facebook":["message"]}
Here is my code:
$output["contextOut"] = array(array("name" => "$next-context", "parameters" =>
array("param1" => $param1value, "param2" => $param2value)));
$output["speech"] = $outputtext;
$output["data"] = array("fa... | |
doc_3196 | The droid have a box collider also the door have a box collider.
But when i move the character(FPSController/FirstPersoncharacter) the player the character stop can't move through the door but the droid can.
I tried to turn off/on the Is Trigger property on the droid box collider but it didn't change.
I want the droid... | |
doc_3197 | Instead, I just want to return status code 401 with an empty response body (or at least an empty "_issues" field). Is there any way to do that? Authentication/authorization is not an option, because it's a public registration resource (public method POST allowed).
I already changed the status code to 401 (VALIDATION_ER... | |
doc_3198 | That would be useful to be able to do:
void SortByLength(List<string> t)
{
t = t.OrderBy(
s => s,
Comparer<string>.FromLambda((s1,s2) => s1.Length.CompareTo(s2.Length))
).ToList();
}
It would be much easier than having to define a Comparer class each time.
I know it is not complicate... | |
doc_3199 |
<tr>
{{#each columns}}
<th>
{{name}}
</th>
{{/each}}
</tr>
{{#each items}}
<tr>
{{each columns}}
<td>
{{! I want the items statusString field here for example }}
{{../dataField}}
</td>
{{/each}}
</tr>
{{/each}}
and the in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.