any

Can I use any() and next() to get rid of empty data frames in R?

一世执手 提交于 2020-01-05 05:30:09
问题 The following link if else statement gone bad suggests not to use the formulation > any( c(5,6,7) )==0 [1] FALSE I have been using any() to get rid of empty data frames in for() loops like this: id <- c(1,2,3,4,5,6) len <- c(11.25,11.75,12,12,12.5,13.25) df <- data.frame(id,len) bin.brks <- c(10,11,12,13,14) options(warn = -1) # to turn warnings off for (m in 1: (length(bin.brks)-1)){ #subset weights into each bin; empty when m=1 temp <- df[(df$len > bin.brks[m] & df$len <= bin.brks[m+1]),] #

Python: Expanding the scope of the iterator variable in the any() function

陌路散爱 提交于 2020-01-03 19:43:27
问题 I wrote some structurally equivalent real world code, where I anticipated the result for firstAdjective would be quick . But the result shows that word is out of scope. What is a neat solution that will overcome this but still retain the 'linguistic' style of what I want to do? >>> text = 'the quick brown fox jumps over the lazy dog' >>> adjectives = ['slow', 'quick', 'brown', 'lazy'] >>> if any(word in text for word in adjectives): ... firstAdjective = word ... Traceback (most recent call

Are SQL ANY and SOME keywords synonyms in all SQL dialects?

妖精的绣舞 提交于 2020-01-03 07:18:34
问题 In Postgres, ANY and SOME are synonyms when used on the right hand side of a predicate expression. For example, these are the same: column = ANY (SELECT ...) column = SOME (SELECT ...) This is documented here: http://www.postgresql.org/docs/9.1/static/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME I have observed ANY and SOME to be supported by at least these SQL DBMSs: DB2 Derby H2 HSQLDB Ingres MySQL Oracle Postgres SQL Server Sybase ASE Sybase SQL Anywhere Can I safely assume that all

How can I do bi-directional mapping over @Any annotated property?

China☆狼群 提交于 2020-01-01 10:13:15
问题 In this article http://www.jroller.com/eyallupu/entry/hibernate_the_any_annotation and also in this question How to use Hibernate @Any-related annotations?, how @Any annotation can be used was explained. But how can I get borrows for each DVD/VHS/BOOK? How can I do mapping definition on DVD/VHS/BOOK? 回答1: I don't think this is supported and, as mentioned in the documentation: 2.4.5.2. @Any The @Any annotation defines a polymorphic association to classes from multiple tables. This type of

Haskell/GHC performance of `any`/`all`

妖精的绣舞 提交于 2019-12-31 00:56:45
问题 I wrote quantification functions exists , forall , and none for Haskell's build-in [] list data type. On multiple occasions, these seemed to prove much more efficient than Prelude / Data.List s any and all . I naively suspect that this performance is due to any and all being implemented using Θ(n) folds. Since I am relatively new to Haskell, I think I must be mistaken, or that there would be a good reason for this phenomenon. From Data.Foldable : -- | Determines whether any element of the

Type intersections using any

与世无争的帅哥 提交于 2019-12-29 08:15:10
问题 From https://github.com/Microsoft/TypeScript/pull/3622: Supertype collapsing: A & B is equivalent to A if B is a supertype of A. However: type a = string & any; // Resolves to any, not string!? This intersection resolves to any. Isn't 'any' a supertype of string? So shouldn't this intersection be just string, due to supertype collapsing? What am I missing? The use case here is something like: type PropertyMap = { prop1: { name: "somename"; required: any; }; prop2: { name: "someothername";

Why does Python's `any` function not return True or False? [closed]

帅比萌擦擦* 提交于 2019-12-25 18:53:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . If I try >>> from pylab import * >>> b = [2, 3, 4, 5, 6, 7] >>> a = any(x < 0 for x in b) >>> print(a) it doesn't return True or False . It returns <generator object <genexpr> at 0x7fbd62129ab0> 回答1: You are using a numpy.any() instead of the built-in any() . Most probably you have from numpy import any or from

Java Regex looking a combination of words in any order

≡放荡痞女 提交于 2019-12-24 11:50:17
问题 I'm looking for a way to find two or more words in a sentence that might come in any order. For example I might look for the words "NCAA" and "Basketball" in a sentence that says NCAA Indiana Vs. Purdue Basketball" or it might say "Indiana Vs. Purdue Basketball NCAA". How would I write the regex for the words showing in any order and any location in the string? 回答1: You can use lookahead: (?=.*?NCAA)(?=.*?Basketball) Or else use alternation: NCAA.*?Basketball|Basketball.*?NCAA 来源: https:/

Subquery with “ANY” and local array generate nested too deep SQL Statement

假如想象 提交于 2019-12-23 15:33:38
问题 public IEnumerable<Table1> GetMatchingTable1(string param, double[] Thicknesses) { return DBContext.Table1.Where(c => c.Field1 == param && Thicknesses.Any(Thickness => Thickness >= c.MinThickness && Thickness <= c.MaxThickness)) .ToList(); } Above query return the following exception. "Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries." So far, all my research on the web for this error pointed toward replacing "ANY" with "CONTAINS".

Python NameError: global name 'any' is not defined

心不动则不痛 提交于 2019-12-23 13:15:11
问题 I am getting the following error on my production server: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 89, in get_response response = middleware_method(request) File "myproject/middleware.py", line 31, in process_request if not any(m.match(path) for m in EXEMPT_URLS): NameError: global name 'any' is not defined The server is running python 2.6 and in development this error was not raised. The offending code is in middleware.py :