问:
Javascript - Month Year range automatically on selectlist
I'm try to automacially create a select list that has the following:

```<code><select name="Range" id="ranges">
  <option value="July 2017">July 2017</option>
   <option value="June 2017">June 2017</option>
     <option value="May 2017">May 2017</option>
</code>```

all the way down to August 2015

```<code>     <option value="August 2015">August 2015</option>

</select>
</code>```

The first option must be the current Month and Year

is this possible to be automatically populated via javascript?

答:
you can get an array of months between now and Aug 1, 2015 and then use that array to make options in select, something like this:

function dateRange(startDate, endDate) {
  var monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
  ];
  var startMonth = parseInt(startDate.getMonth());
  var endMonth   = parseInt(endDate.getMonth());
  var startYear  = parseInt(startDate.getFullYear());
  var endYear    = parseInt(endDate.getFullYear());
  var dates      = [];
  for (var i = startMonth; i >= 0; i--)
     dates.push(monthNames[i] + " " + startYear);
  startYear--;
 for(var i = startYear; i > endYear; i--) {
   for (var j = monthNames.length-1; j >= 0; j--)
  dates.push(monthNames[j] + " " + i);
 }

  for (var i = monthNames.length-1; i >= endMonth; i--)
 dates.push(monthNames[i] + " " + endYear);
  return dates;
}
dates = dateRange(new Date(), new Date('August 1, 2015'));
var select = document.getElementById('datepicker');
dates.forEach(function(d){
 select.options.add(new Option(d, d));
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <select id="datepicker"></select></code>```

Body:
I'm try to automacially create a select list that has the following:

<select name="Range" id="ranges">
  <option value="July 2017">July 2017</option>
   <option value="June 2017">June 2017</option>
     <option value="May 2017">May 2017</option>

all the way down to August 2015

     <option value="August 2015">August 2015</option>

</select>

The first option must be the current Month and Year

is this possible to be automatically populated via javascript?

Body:
you can get an array of months between now and Aug 1, 2015 and then use that array to make options in select, something like this:

function dateRange(startDate, endDate) {
  var monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
  ];
  var startMonth = parseInt(startDate.getMonth());
  var endMonth   = parseInt(endDate.getMonth());
  var startYear  = parseInt(startDate.getFullYear());
  var endYear    = parseInt(endDate.getFullYear());
  var dates      = [];
  for (var i = startMonth; i >= 0; i--)
     dates.push(monthNames[i] + " " + startYear);
  startYear--;
 for(var i = startYear; i > endYear; i--) {
   for (var j = monthNames.length-1; j >= 0; j--)
  dates.push(monthNames[j] + " " + i);
 }

  for (var i = monthNames.length-1; i >= endMonth; i--)
 dates.push(monthNames[i] + " " + endYear);
  return dates;
}
dates = dateRange(new Date(), new Date('August 1, 2015'));
var select = document.getElementById('datepicker');
dates.forEach(function(d){
 select.options.add(new Option(d, d));
});

    <select id="datepicker"></select>


来源: stackexchange

问:
Rails ajax submit fails to send params
View File

```<code><%= form_for(@task, url: task_path, method: :post, remote: true) do |f| %>
  <li><button class="bton" name="status" value="Pending">Complete</button></li>
<% end %>
</code>```

On clicking the Complete button the name and value is not received at the controller but things works fine if I remove remote:true

Am I missing anything?

答:
You can pass hidden field for sending those values, If you need to send many values you can do this approach, without showing displaying the elements in Page

```<code><%= form_for(@task, url: task_path, method: :post, remote: true) do |f| %>
      <input type="hidden" class="bton" name="status" value="Pending">
          <li><button class="bton" name="status" value="Pending">Complete</button></li>

<% end %>
</code>```

ContentLicense: CC BY-SA 3.0

Title: Rails ajax submit fails to send params

Body:
View File

<%= form_for(@task, url: task_path, method: :post, remote: true) do |f| %>

<button class="bton" name="status" value="Pending">Complete</button>

<% end %>

On clicking the Complete button the name and value is not received at the controller but things works fine if I remove remote:true

Am I missing anything?

Body:
You can pass hidden field for sending those values, If you need to send many values you can do this approach, without showing displaying the elements in Page

<%= form_for(@task, url: task_path, method: :post, remote: true) do |f| %>
      <input type="hidden" class="bton" name="status" value="Pending">
          <li><button class="bton" name="status" value="Pending">Complete</button></li>

<% end %>


问:
NSRegularExpression:stringByReplacingMatchesInString Does not reconstruct string with multiple lines
Following section of code beautifully results:
 - (void)setRepresentedObject:(id)representedObject { DLOG()

```<code>- (void) putLogInFunctionCalls{

NSString *string = @"- (void)setRepresentedObject:(id)representedObject {";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^-[^{]+\{" options:NSRegularExpressionCaseInsensitive error:&error];

NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:[NSString stringWithFormat:@"%@ DLOG()", string]];

NSLog(@"%@", modifiedString);
</code>```

}

But instead of putting just one line of input in the variable string if I try to read a code file say ViewController.m file that contains following code and put it in that variable: it does not work.

```<code>//
//  ViewController.m
//  ForCommonCoding
//
//  Created by A Programmer on 7/6/17.
//  Copyright ? 2017 A Programmer. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
}
- (void)setRepresentedObject:(id)representedObject {
         [super setRepresentedObject:representedObject];

     // Update the view, if already loaded.
}

- (void)sampleFunction {
    NSLog(@"This is sampleFunction");
}
@end
</code>```

NSLog shows same as input. DLog() not appeneded Can anyone help solve it?

答:
This should work as you expects:

```<code>NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(-[^{]+\{)" options:NSRegularExpressionAnchorsMatchLines error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@"$1 DLOG()"];
NSLog(@"%@", modifiedString);
</code>```

The are three problems with your code:

NSRegularExpressionAnchorsMatchLines was missing but you're matching line start with ^

Matching group is missing in regex which allows you to use the matching result in replacement: ()

Replacement template string uses the whole string instead of the first match $1

Working Playground code:

```<code>let line = "- (void)setRepresentedObject:(id)representedObject {"
let file = "#import \"ViewController.h\"\n\n\n@implementation ViewController\n\n- (void)viewDidLoad {\n    [super viewDidLoad];\n\n    // Do any additional setup after loading the view.\n}\n- (void)setRepresentedObject:(id)representedObject {\n         [super setRepresentedObject:representedObject];\n\n     // Update the view, if already loaded.\n}\n\n- (void)sampleFunction {\n    NSLog(@\"This is sampleFunction\");\n}\n@end"
let regex = try! NSRegularExpression(pattern: "^(-[^{]+\\{)", options: [.anchorsMatchLines])
regex.stringByReplacingMatches(in: line, options: [], range: NSMakeRange(0, line.characters.count), withTemplate: "$1 DLOG()")
regex.stringByReplacingMatches(in: file, options: [], range: NSMakeRange(0, file.characters.count), withTemplate: "$1 DLOG()")
</code>```

Body:
Following section of code beautifully results:
 - (void)setRepresentedObject:(id)representedObject { DLOG()

- (void) putLogInFunctionCalls{

NSString *string = @"- (void)setRepresentedObject:(id)representedObject {";
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^-[^{]+\{" options:NSRegularExpressionCaseInsensitive error:&error];

NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:[NSString stringWithFormat:@"%@ DLOG()", string]];

NSLog(@"%@", modifiedString);

}

But instead of putting just one line of input in the variable string if I try to read a code file say ViewController.m file that contains following code and put it in that variable: it does not work.

//
//  ViewController.m
//  ForCommonCoding
//
//  Created by A Programmer on 7/6/17.
//  Copyright ? 2017 A Programmer. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
}
- (void)setRepresentedObject:(id)representedObject {
         [super setRepresentedObject:representedObject];

     // Update the view, if already loaded.
}

- (void)sampleFunction {
    NSLog(@"This is sampleFunction");
}
@end

NSLog shows same as input. DLog() not appeneded Can anyone help solve it?

Body:
This should work as you expects:

NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(-[^{]+\{)" options:NSRegularExpressionAnchorsMatchLines error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@"$1 DLOG()"];
NSLog(@"%@", modifiedString);

The are three problems with your code:

NSRegularExpressionAnchorsMatchLines was missing but you're matching line start with ^

Matching group is missing in regex which allows you to use the matching result in replacement: ()

Replacement template string uses the whole string instead of the first match $1

Working Playground code:

let line = "- (void)setRepresentedObject:(id)representedObject {"
let file = "#import \"ViewController.h\"\n\n\n@implementation ViewController\n\n- (void)viewDidLoad {\n    [super viewDidLoad];\n\n    // Do any additional setup after loading the view.\n}\n- (void)setRepresentedObject:(id)representedObject {\n         [super setRepresentedObject:representedObject];\n\n     // Update the view, if already loaded.\n}\n\n- (void)sampleFunction {\n    NSLog(@\"This is sampleFunction\");\n}\n@end"
let regex = try! NSRegularExpression(pattern: "^(-[^{]+\\{)", options: [.anchorsMatchLines])
regex.stringByReplacingMatches(in: line, options: [], range: NSMakeRange(0, line.characters.count), withTemplate: "$1 DLOG()")
regex.stringByReplacingMatches(in: file, options: [], range: NSMakeRange(0, file.characters.count), withTemplate: "$1 DLOG()")


问:
Header is not allowing  to align in the same line
I have a css header that is not allowing me to align a text in the same line using . I imagine there is a weird default to the header that doesnt allow me to do this how do i prevent the default or what else can i use instead?

HTML

```<code>h3>Size:</h3>
<?php echo "<span class='sP'>".$pSize ."</span><br>"?>
</code>```

CSS

```<code>h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;

}
</code>```

答:
Try to put  in
 tags as header takes the full width.

```<code><h3>Size:
   <?php echo "<span class='sP'>".$pSize ."</span><br>"?>
</h3>
</code>```

Title: Header is not allowing <span> to align in the same line

Body:
I have a css header that is not allowing me to align a text in the same line using . I imagine there is a weird default to the header that doesnt allow me to do this how do i prevent the default or what else can i use instead?

HTML

h3>Size:

<?php echo "".$pSize ."
"?>

CSS

h3{
margin-top: 0;
margin-bottom: 0;
color: #7C7C7C;
font-size: 20px;
font-weight: bold;
text-align: left;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;
}

.sP{
color: #7C7C7C;
font-family: "Lucida Sans Typewriter", "Lucida Console", monaco, "Bitstream Vera Sans Mono", monospace;

}

Body:
Try to put <span> in <h3> tags as header takes the full width.

<h3>Size:
   <?php echo "<span class='sP'>".$pSize ."</span><br>"?>
</h3>


问:
Is it possible exclude test directories from coverage.py reports?
I'm kind of a rookie with python unit testing, and particularly coverage.py.  Is it desirable to have coverage reports include the coverage of your actual test files?

Here's a screenshot of my HTML report as an example.

You can see that the report includes tests/test_credit_card.  At first I was trying to omit the tests/ directory from the reports, like so:

```<code>coverage html --omit=tests/ -d tests/coverage
</code>```

I tried several variations of that command but I could not for the life of me get the tests/ excluded.  After accepting defeat, I began to wonder if maybe the test files are supposed to be included in the report.

Can anyone shed some light on this?

答:
Create <code>.coveragerc</code> file in your project root folder, and include the following:  </p>

```<code>[run]
omit = *tests*
</code>```

Body:
I'm kind of a rookie with python unit testing, and particularly coverage.py.  Is it desirable to have coverage reports include the coverage of your actual test files?

Here's a screenshot of my HTML report as an example.

You can see that the report includes tests/test_credit_card.  At first I was trying to omit the tests/ directory from the reports, like so:

coverage html --omit=tests/ -d tests/coverage

I tried several variations of that command but I could not for the life of me get the tests/ excluded.  After accepting defeat, I began to wonder if maybe the test files are supposed to be included in the report.

Can anyone shed some light on this?

Body:
Create .coveragerc file in your project root folder, and include the following:

[run]
omit = *tests*


问:
Define externalized groovy file in test step definition
I'd like to externalize my groovy scripts to a file. Instead of

```<code><con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
    <con:settings/>
    <con:config>
        <script>log.info "[ isr::CallbackController::Init ] "</script>
    </con:config>
</con:testStep>
</code>```

I'd prefer something like this:

```<code><con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
    <con:settings/>
    <con:config>
        <script file="path/to/my.groovy"/>
    </con:config>
</con:testStep>
</code>```

答:
I think that this is not currently supported in SOAPUI, maybe you can add a feature request to it :).

However in the meantime maybe the following tricky workaround could be useful for you.

I purpose you to create a groovy script testStep which reads your script from a file, dynamically create a groovy testStep, sets the script with the file content, execute this new dynamic created testStep and finally remove it in order that it can be run it multiple times. See the follow script:

```<code>import com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory

// read the file with your script
File f = new File('path/to/my.groovy')

def tc = testRunner.testCase
// create a empty groovy testStep in the current testCase
def groovyTS = tc.addTestStep( GroovyScriptStepFactory.GROOVY_TYPE, "Groovy testStep dinamic" )

// set the file script as a content
groovyTS.properties["script"].value = f.text

// run the the created testStep with your script
groovyTS.run(testRunner,context)

// once runned delete it
tc.removeTestStep(groovyTS)
</code>```

As @Rao note in the comments, maybe an easy way to do so it's simply use evaluate in the groovy script testStep as:

```<code>evaluate(new File('path/to/my.groovy'))
</code>```

At first I avoid this option thinking on possible problems with context variables like testRunner, context, log... and I use the option to create groovy testStep to keep it as similar as possible to the SOAPUI way. However using evaluate seems a really nice and easier workaround.

Body:
I'd like to externalize my groovy scripts to a file. Instead of

<con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
    <con:settings/>
    <con:config>

    </con:config>
</con:testStep>

I'd prefer something like this:

<con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
    <con:settings/>
    <con:config>

Body:
I think that this is not currently supported in SOAPUI, maybe you can add a feature request to it :).

However in the meantime maybe the following tricky workaround could be useful for you.

I purpose you to create a groovy script testStep which reads your script from a file, dynamically create a groovy testStep, sets the script with the file content, execute this new dynamic created testStep and finally remove it in order that it can be run it multiple times. See the follow script:

import com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory

// read the file with your script
File f = new File('path/to/my.groovy')

def tc = testRunner.testCase
// create a empty groovy testStep in the current testCase
def groovyTS = tc.addTestStep( GroovyScriptStepFactory.GROOVY_TYPE, "Groovy testStep dinamic" )

// set the file script as a content
groovyTS.properties["script"].value = f.text

// run the the created testStep with your script
groovyTS.run(testRunner,context)

// once runned delete it
tc.removeTestStep(groovyTS)

As @Rao note in the comments, maybe an easy way to do so it's simply use evaluate in the groovy script testStep as:

evaluate(new File('path/to/my.groovy'))

At first I avoid this option thinking on possible problems with context variables like testRunner, context, log... and I use the option to create groovy testStep to keep it as similar as possible to the SOAPUI way. However using evaluate seems a really nice and easier workaround.


问:
SQL data returned in a comma-delimited list
Here are my tables:

```<code>-----------------------------------------
Hotels
-----------------------------------------
HotelID | HotelName
-----------------------------------------

-----------------------------------------
HotelImages
-----------------------------------------
HotelImageID | HotelID | Filename
-----------------------------------------
</code>```

I'd like to create a SELECT statement that will return the data like so:

```<code>HotelID | HotelName | Images
-----------------------------------------
1 | Hotel1 | Image1,Image2,Image3
2 | Hotel2 | Image4,Image5,Image6
</code>```

How can I modify my query to do this? I have:

```<code>SELECT H.HotelID, H.HotelName, '' AS Images
FROM Hotels H
</code>```

I know I can use COALESCE to create a comma-delimited list:

```<code>DECLARE @Images varchar(500)
SELECT @Images = COALESCE(@Images + ',', '') + CAST(Filename AS varchar(100)) FROM HotelImages WHERE HotelID = 1
SELECT @Images
</code>```

But I don't know how to integrate that into my current query so that the list can be returned with the rest of the hotel data.

I should mention I'm using SQL Server 2000.

答:
Since this is SQL 2000 you options are somewhat limited. You can't use FOR XML PATH or recursive CTEs

Also the COALESCE trick only works for stuffing a comma delimited list for single hotel. Not all of them.

Honestly you're better off doing this in the client. But if that can't be done (certain Report Apps that-which-must-not-be-named come to mind) you can do the following.

Note the number of times the loop process is equal to maximum number of files associated with a hotel. This is much better than setting up a loop for each hotel (e.g. calling a UDF from the select clause).

```<code>DECLARE @foo table ( HotelID int , lastID int , FileNameList varchar(8000))

INSERT INTO @Foo

SELECT
    start.HotelID,
    start.firstID ,
    id.FileName

FROM
    (SELECT
        HotelID,
        min(HotelImageID ) firstID
    from
        HotelImages

    group by HotelID) start
    INNER JOIN HotelImages hi
    ON start.firstID = hi.HotelImageID

WHILE @@RowCount <> 0
BEGIN

    UPDATE @foo
    SET
        FileNameList = FileNameList + ',' + FileName
        lastID  = Xnext.nextID
    FROM
        @foo f
        INNER JOIN HotelImages hi
        ON f.HotelID = id.HotelID
        INNER JOIN
        (SELECT

            id.HotelID,
            min(HotelImageID ) nextID
        from HotelImages hi
              inner join @foo f
              on f.HotelID = id.HotelID
        where id.HotelImageID  > f.lastid

        group by id.HotelID) Xnext

        ON Xnext.nextID = id.HotelImageID

END

SELECT
    h.HotelID
    h.HotelName,
    f.FileNameList
FROM
    Hotels h
    INNER JOIN @foo f
    ON h.hotelId = f.HotelId
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Here are my tables:

-----------------------------------------
Hotels
-----------------------------------------
HotelID | HotelName
-----------------------------------------

-----------------------------------------
HotelImages
-----------------------------------------
HotelImageID | HotelID | Filename
-----------------------------------------

I'd like to create a SELECT statement that will return the data like so:

HotelID | HotelName | Images
-----------------------------------------
1 | Hotel1 | Image1,Image2,Image3
2 | Hotel2 | Image4,Image5,Image6

How can I modify my query to do this? I have:

SELECT H.HotelID, H.HotelName, '' AS Images
FROM Hotels H

I know I can use COALESCE to create a comma-delimited list:

DECLARE @Images varchar(500)
SELECT @Images = COALESCE(@Images + ',', '') + CAST(Filename AS varchar(100)) FROM HotelImages WHERE HotelID = 1
SELECT @Images

But I don't know how to integrate that into my current query so that the list can be returned with the rest of the hotel data.

I should mention I'm using SQL Server 2000.

Body:
Since this is SQL 2000 you options are somewhat limited. You can't use FOR XML PATH or recursive CTEs

Also the COALESCE trick only works for stuffing a comma delimited list for single hotel. Not all of them.

Honestly you're better off doing this in the client. But if that can't be done (certain Report Apps that-which-must-not-be-named come to mind) you can do the following.

Note the number of times the loop process is equal to maximum number of files associated with a hotel. This is much better than setting up a loop for each hotel (e.g. calling a UDF from the select clause).

DECLARE @foo table ( HotelID int , lastID int , FileNameList varchar(8000))

INSERT INTO @Foo

SELECT
    start.HotelID,
    start.firstID ,
    id.FileName

FROM
    (SELECT
        HotelID,
        min(HotelImageID ) firstID
    from
        HotelImages

    group by HotelID) start
    INNER JOIN HotelImages hi
    ON start.firstID = hi.HotelImageID

WHILE @@RowCount <> 0
BEGIN

    UPDATE @foo
    SET
        FileNameList = FileNameList + ',' + FileName
        lastID  = Xnext.nextID
    FROM
        @foo f
        INNER JOIN HotelImages hi
        ON f.HotelID = id.HotelID
        INNER JOIN
        (SELECT

            id.HotelID,
            min(HotelImageID ) nextID
        from HotelImages hi
              inner join @foo f
              on f.HotelID = id.HotelID
        where id.HotelImageID  > f.lastid

        group by id.HotelID) Xnext

        ON Xnext.nextID = id.HotelImageID

END

SELECT
    h.HotelID
    h.HotelName,
    f.FileNameList
FROM
    Hotels h
    INNER JOIN @foo f
    ON h.hotelId = f.HotelId


问:
Match any word of a List/Array in a Sentence java
I have an List of word like below

```<code>List<String> forbiddenWordList = Arrays.asList("LATE", "S/O", "SO", "W/O", "WO");
</code>```

How can I understand a String Contains any one of the word of the List. like....

```<code>String name1 = "Adam Smith";      // false (not found)
String name2 = "Late H Milton";   // true  (found Late)
String name3 = "S/O Furi Kerman"; // true  (found S/O)
String name4 = "Conl Faruk";      // false (not found)
String name5 = "Furi Kerman WO";  // true  (found WO)
</code>```

Regular Expression highly appreciated.

答:
You can use like this :

Iteration over words (stream) and returns true if any words (named w) match with the condition (contains)

```<code>public static boolean isForbidden(String word, List<String> words) {
     return words.stream().anyMatch(w -> (word.toLowerCase().contains(w.toLowerCase())));
}
</code>```

Using regex, it will build the pattern itself from the List

```<code>public static boolean isForbidden1(String word, List<String> words) {
     String forbiddenWordPattern = String.join("|", words);

     return Pattern.compile(forbiddenWordPattern, Pattern.CASE_INSENSITIVE)
                   .matcher(word)
                   .find();
 }
</code>```

Body:
I have an List of word like below

List<String> forbiddenWordList = Arrays.asList("LATE", "S/O", "SO", "W/O", "WO");

How can I understand a String Contains any one of the word of the List. like....

String name1 = "Adam Smith";      // false (not found)
String name2 = "Late H Milton";   // true  (found Late)
String name3 = "S/O Furi Kerman"; // true  (found S/O)
String name4 = "Conl Faruk";      // false (not found)
String name5 = "Furi Kerman WO";  // true  (found WO)

Regular Expression highly appreciated.

Body:
You can use like this :

Iteration over words (stream) and returns true if any words (named w) match with the condition (contains)

public static boolean isForbidden(String word, List<String> words) {
     return words.stream().anyMatch(w -> (word.toLowerCase().contains(w.toLowerCase())));
}

Using regex, it will build the pattern itself from the List

public static boolean isForbidden1(String word, List<String> words) {
     String forbiddenWordPattern = String.join("|", words);

     return Pattern.compile(forbiddenWordPattern, Pattern.CASE_INSENSITIVE)
                   .matcher(word)
                   .find();
 }


问:
Issue Installing WISDEM using openmdao-0.7.0
Below is the log which I received when trying to install WISDEM using OpenMDAO-0.7.0. I know it's been a while but can anyone figure what went wrong in my installation process. I probably missed something that is important.

I think the issue lie in installing some libraries probably:

libzmq

or something related but am not sure.

But looking at the log -that's where the installation has started to converge. Do have a look.

Cheers!

```<code>(openmdao-0.7.0) C:\Python27\openmdao-0.7.0\WISDEM>python setup_all.py Searching for pandas
Best match: pandas 0.14.1
pandas 0.14.1 is already the active version in easy-install.pth

Using c:\python27\lib\site-packages
Processing dependencies for pandas
Finished processing dependencies for pandas
Searching for algopy
Best match: algopy 0.5.5
Processing algopy-0.5.5-py2.7.egg
algopy 0.5.5 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\algopy-0.5.5-py2.7.egg
Processing dependencies for algopy
Finished processing dependencies for algopy
Searching for zope.interface
Best match: zope.interface 3.6.1
Processing zope.interface-3.6.1-py2.7-win32.egg
zope.interface 3.6.1 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\zope.interface-3.6.1-py2.7-wi
n32.egg
Processing dependencies for zope.interface
Finished processing dependencies for zope.interface
Searching for sphinx
Best match: sphinx 1.6.3
Processing sphinx-1.6.3-py2.7.egg
sphinx 1.6.3 is already the active version in easy-install.pth
Installing sphinx-apidoc-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-apidoc.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-apidoc.exe.manifest script to C:\Python27\openmdao-0.7.0\Scrip
ts
Installing sphinx-build-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-build.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-build.exe.manifest script to C:\Python27\openmdao-0.7.0\Script
s
Installing sphinx-quickstart-script.py script to C:\Python27\openmdao-0.7.0\Scri
pts
Installing sphinx-quickstart.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-quickstart.exe.manifest script to C:\Python27\openmdao-0.7.0\S
cripts
Installing sphinx-autogen-script.py script to C:\Python27\openmdao-0.7.0\Scripts

Installing sphinx-autogen.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-autogen.exe.manifest script to C:\Python27\openmdao-0.7.0\Scri
pts

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinx-1.6.3-py2.7.egg
Processing dependencies for sphinx
Finished processing dependencies for sphinx
Searching for xlrd
Best match: xlrd 1.0.0
Processing xlrd-1.0.0-py2.7.egg
xlrd 1.0.0 is already the active version in easy-install.pth
Installing runxlrd.py script to C:\Python27\openmdao-0.7.0\Scripts

Using c:\python27\openmdao-0.7.0\lib\site-packages\xlrd-1.0.0-py2.7.egg
Processing dependencies for xlrd
Finished processing dependencies for xlrd
Searching for pyopt
Best match: pyopt 0.84
Processing pyopt-0.84-py2.7.egg
pyopt 0.84 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\pyopt-0.84-py2.7.egg
Processing dependencies for pyopt
Finished processing dependencies for pyopt
Searching for py2exe
Best match: py2exe 0.9.2.2
Processing py2exe-0.9.2.2-py2.7-win32.egg
py2exe 0.9.2.2 is already the active version in easy-install.pth
Installing build_exe-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe-script.pyc script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe.manifest script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe.manifest script to C:\Python27\openmdao-0.7.0\Scripts

Using c:\python27\openmdao-0.7.0\lib\site-packages\py2exe-0.9.2.2-py2.7-win32.eg
g
Processing dependencies for py2exe
Finished processing dependencies for py2exe
Searching for pyzmq
Reading https://pypi.python.org/simple/pyzmq/
Downloading https://pypi.python.org/packages/af/37/8e0bf3800823bc247c36715a52e92
4e8f8fd5d1432f04b44b8cd7a5d7e55/pyzmq-16.0.2.tar.gz#md5=9a8768b00a566a400d70318f
8c359cfe
Best match: pyzmq 16.0.2
Processing pyzmq-16.0.2.tar.gz
Writing c:\users\anur\appdata\local\temp\easy_install-6x9i5o\pyzmq-16.0.2\setup.
cfg
Running pyzmq-16.0.2\setup.py -q bdist_egg --dist-dir c:\users\anur\appdata\loca
l\temp\easy_install-6x9i5o\pyzmq-16.0.2\egg-dist-tmp-fszbbf
warning: no files found matching 'tox.ini'
no previously-included directories found matching 'docs\build'
no previously-included directories found matching 'docs\gh-pages'
warning: no previously-included files found matching 'bundled\zeromq\src\Makefil
e*'
warning: no previously-included files found matching 'bundled\zeromq\src\platfor
m.hpp'
warning: no previously-included files found matching 'zmq\libzmq*'
warning: no previously-included files matching '__pycache__\*' found anywhere in
 distribution
warning: no previously-included files matching '.deps\*' found anywhere in distr
ibution
warning: no previously-included files matching '*.so' found anywhere in distribu
tion
warning: no previously-included files matching '*.pyd' found anywhere in distrib
ution
warning: no previously-included files matching '.git*' found anywhere in distrib
ution
warning: no previously-included files matching '.DS_Store' found anywhere in dis
tribution
warning: no previously-included files matching '.mailmap' found anywhere in dist
ribution
warning: no previously-included files matching 'Makefile.am' found anywhere in d
istribution
warning: no previously-included files matching 'Makefile.in' found anywhere in d
istribution
************************************************
Warning: Couldn't find an acceptable libzmq on the system.

If you expected pyzmq to link against an installed libzmq, please check to make
sure:

    * You have a C compiler installed
    * A development version of Python is installed (including headers)
    * A development version of ZMQ >= 3.2 is installed (including headers)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location,
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`

You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:

    `--zmq=bundled`

I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...

 1...
************************************************
Using bundled libzmq
already have bundled\zeromq
staging platform.hpp from: bundled\zeromq\builds\msvc
************************************************
In file included from zmq\utils/zmq_compat.h:16:0,
                 from zmq\devices\monitoredqueue.c:403:
bundled\zeromq\include/zmq.h:439:52: error: unknown type name 'uint8_t'
 ZMQ_EXPORT char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);

                                                    ^
bundled\zeromq\include/zmq.h:442:12: error: unknown type name 'uint8_t'
 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
            ^
bundled\zeromq\include/zmq.h:442:37: error: unknown type name 'uint8_t'
 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
                                     ^
In file included from zmq\devices\monitoredqueue.c:403:0:
zmq\devices\monitoredqueue.c: In function '__pyx_f_3zmq_7devices_14monitoredqueu
e__relay':
zmq\utils/zmq_compat.h:12:23: error: unknown type name 'int64_t'
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1761:3: note: in expansion of macro 'pyzmq_int64_t'

   pyzmq_int64_t __pyx_v_flag_2;
   ^
zmq\utils/zmq_compat.h:12:23: error: 'int64_t' undeclared (first use in this fun
ction)
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1786:30: note: in expansion of macro 'pyzmq_int64_t
'
     __pyx_v_flagsz = (sizeof(pyzmq_int64_t));
                              ^
zmq\utils/zmq_compat.h:12:23: note: each undeclared identifier is reported only
once for each function it appears in
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1786:30: note: in expansion of macro 'pyzmq_int64_t
'
     __pyx_v_flagsz = (sizeof(pyzmq_int64_t));
                              ^
zmq\devices\monitoredqueue.c: In function '__Pyx_RaiseArgtupleInvalid':
zmq\devices\monitoredqueue.c:5271:18: warning: unknown conversion type character
 'z' in format [-Wformat=]
                  (num_expected == 1) ? "" : "s", num_found);
                  ^
zmq\devices\monitoredqueue.c:5271:18: warning: format '%s' expects argument of t
ype 'char *', but argument 5 has type 'Py_ssize_t' [-Wformat=]
zmq\devices\monitoredqueue.c:5271:18: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:5271:18: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c: In function '__Pyx_CyFunction_CallMethod':
zmq\devices\monitoredqueue.c:6537:17: warning: unknown conversion type character
 'z' in format [-Wformat=]
                 f->m_ml->ml_name, size);
                 ^
zmq\devices\monitoredqueue.c:6537:17: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c:6553:17: warning: unknown conversion type character
 'z' in format [-Wformat=]
                 f->m_ml->ml_name, size);
                 ^
zmq\devices\monitoredqueue.c:6553:17: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c: In function '__Pyx_ImportType':
zmq\devices\monitoredqueue.c:7390:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
             module_name, class_name, basicsize, size);
             ^
zmq\devices\monitoredqueue.c:7390:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:7390:13: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c:7396:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
             module_name, class_name, basicsize, size);
             ^
zmq\devices\monitoredqueue.c:7396:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:7396:13: warning: too many arguments for format [-W
format-extra-args]
error: Setup script exited with error: command 'c:\\Rtools\\mingw_32\\bin\\gcc.e
xe' failed with exit status 1
Searching for sphinxcontrib-bibtex
Best match: sphinxcontrib-bibtex 0.3.5
Processing sphinxcontrib_bibtex-0.3.5-py2.7.egg
sphinxcontrib-bibtex 0.3.5 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinxcontrib_bibtex-0.3.5-py
2.7.egg
Processing dependencies for sphinxcontrib-bibtex
Finished processing dependencies for sphinxcontrib-bibtex
Searching for sphinxcontrib-napoleon
Best match: sphinxcontrib-napoleon 0.6.1
Processing sphinxcontrib_napoleon-0.6.1-py2.7.egg
sphinxcontrib-napoleon 0.6.1 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinxcontrib_napoleon-0.6.1-
py2.7.egg
Processing dependencies for sphinxcontrib-napoleon
Finished processing dependencies for sphinxcontrib-napoleon
Searching for numpydoc
Best match: numpydoc 0.7.0
Processing numpydoc-0.7.0-py2.7.egg
numpydoc 0.7.0 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\numpydoc-0.7.0-py2.7.egg
Processing dependencies for numpydoc
Finished processing dependencies for numpydoc
Searching for ipython
Reading https://pypi.python.org/simple/ipython/
Downloading https://pypi.python.org/packages/79/63/b671fc2bf0051739e87a7478a207b
beb45cfae3c328d38ccdd063d9e0074/ipython-6.1.0.tar.gz#md5=1e15e1ce3f3f722da6935d7
ac0e51346
Best match: ipython 6.1.0
Processing ipython-6.1.0.tar.gz
Writing c:\users\anur\appdata\local\temp\easy_install-k7ruj5\ipython-6.1.0\setup
.cfg
Running ipython-6.1.0\setup.py -q bdist_egg --dist-dir c:\users\anur\appdata\loc
al\temp\easy_install-k7ruj5\ipython-6.1.0\egg-dist-tmp-tkov77

IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.

Beginning with IPython 6.0, Python 3.3 and above is required.

See IPython `README.rst` file for more information:

    https://github.com/ipython/ipython/blob/master/README.rst

Python sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial
=0) detected.

error: Setup script exited with 1
Searching for python-dateutil
Best match: python-dateutil 2.6.0
Processing python_dateutil-2.6.0-py2.7.egg
python-dateutil 2.6.0 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\python_dateutil-2.6.0-py2.7.e
gg
Processing dependencies for python-dateutil
Finished processing dependencies for python-dateutil
install url: package= fusedwind url=  http://github.com/FUSED-Wind/fusedwind/tar
ball/develop
installing distribution from current directory as a 'develop' egg
running develop
running egg_info
creating src\fusedwind.egg-info
writing requirements to src\fusedwind.egg-info\requires.txt
writing src\fusedwind.egg-info\PKG-INFO
writing top-level names to src\fusedwind.egg-info\top_level.txt
writing dependency_links to src\fusedwind.egg-info\dependency_links.txt
writing manifest file 'src\fusedwind.egg-info\SOURCES.txt'
reading manifest file 'src\fusedwind.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no directories found matching 'src\fusedwind\sphinx_build\html'
writing manifest file 'src\fusedwind.egg-info\SOURCES.txt'
running build_ext
Creating c:\python27\openmdao-0.7.0\lib\site-packages\fusedwind.egg-link (link t
o src)
Adding fusedwind 0.1.0 to easy-install.pth file

Installed c:\python27\openmdao-0.7.0\wisdem\plugins\fusedwind\src
subprocess returned  0
install url: package= Turbine_CostsSE url=  http://github.com/WISDEM/Turbine_Cos
tsSE/tarball/0.1
installing distribution from current directory as a 'develop' egg
running develop
running egg_info
creating src\Turbine_CostsSE.egg-info
writing requirements to src\Turbine_CostsSE.egg-info\requires.txt
writing src\Turbine_CostsSE.egg-info\PKG-INFO
writing top-level names to src\Turbine_CostsSE.egg-info\top_level.txt
writing dependency_links to src\Turbine_CostsSE.egg-info\dependency_links.txt
writing manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
reading manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching 'openmdao_log.txt' found anywhere
 in distribution
writing manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
running build_ext
Creating c:\python27\openmdao-0.7.0\lib\site-packages\Turbine-CostsSE.egg-link (
link to src)
Adding Turbine-CostsSE 0.1.0 to easy-install.pth file

Installed c:\python27\openmdao-0.7.0\wisdem\plugins\turbine_costsse\src
subprocess returned  0
install url: package= CommonSE url=  http://github.com/WISDEM/CommonSE/tarball/0
.1
Traceback (most recent call last):
  File "setup_all.py", line 105, in <module>
    install_url(f, url,force=options.force)
  File "setup_all.py", line 28, in install_url
    thetarfile = tarfile.open(fileobj=response, mode="r|gz")
  File "C:\Python27\Lib\tarfile.py", line 1703, in open
    stream = _Stream(name, filemode, comptype, fileobj, bufsize)
  File "C:\Python27\Lib\tarfile.py", line 430, in __init__
    self._init_read_gz()
  File "C:\Python27\Lib\tarfile.py", line 524, in _init_read_gz
    raise ReadError("not a gzip file")
tarfile.ReadError: not a gzip file

(openmdao-0.7.0) C:\Python27\openmdao-0.7.0\WISDEM>'
</code>```

答: openmdao 0.7.0 is very heavily outdated. You should be using at the very least 0.13.0, or  much preferably 1.7.X</p>

Body:
Below is the log which I received when trying to install WISDEM using OpenMDAO-0.7.0. I know it's been a while but can anyone figure what went wrong in my installation process. I probably missed something that is important.

I think the issue lie in installing some libraries probably:

libzmq

or something related but am not sure.

But looking at the log -that's where the installation has started to converge. Do have a look.

Cheers!

(openmdao-0.7.0) C:\Python27\openmdao-0.7.0\WISDEM>python setup_all.py Searching for pandas
Best match: pandas 0.14.1
pandas 0.14.1 is already the active version in easy-install.pth

Using c:\python27\lib\site-packages
Processing dependencies for pandas
Finished processing dependencies for pandas
Searching for algopy
Best match: algopy 0.5.5
Processing algopy-0.5.5-py2.7.egg
algopy 0.5.5 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\algopy-0.5.5-py2.7.egg
Processing dependencies for algopy
Finished processing dependencies for algopy
Searching for zope.interface
Best match: zope.interface 3.6.1
Processing zope.interface-3.6.1-py2.7-win32.egg
zope.interface 3.6.1 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\zope.interface-3.6.1-py2.7-wi
n32.egg
Processing dependencies for zope.interface
Finished processing dependencies for zope.interface
Searching for sphinx
Best match: sphinx 1.6.3
Processing sphinx-1.6.3-py2.7.egg
sphinx 1.6.3 is already the active version in easy-install.pth
Installing sphinx-apidoc-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-apidoc.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-apidoc.exe.manifest script to C:\Python27\openmdao-0.7.0\Scrip
ts
Installing sphinx-build-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-build.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-build.exe.manifest script to C:\Python27\openmdao-0.7.0\Script
s
Installing sphinx-quickstart-script.py script to C:\Python27\openmdao-0.7.0\Scri
pts
Installing sphinx-quickstart.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-quickstart.exe.manifest script to C:\Python27\openmdao-0.7.0\S
cripts
Installing sphinx-autogen-script.py script to C:\Python27\openmdao-0.7.0\Scripts

Installing sphinx-autogen.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing sphinx-autogen.exe.manifest script to C:\Python27\openmdao-0.7.0\Scri
pts

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinx-1.6.3-py2.7.egg
Processing dependencies for sphinx
Finished processing dependencies for sphinx
Searching for xlrd
Best match: xlrd 1.0.0
Processing xlrd-1.0.0-py2.7.egg
xlrd 1.0.0 is already the active version in easy-install.pth
Installing runxlrd.py script to C:\Python27\openmdao-0.7.0\Scripts

Using c:\python27\openmdao-0.7.0\lib\site-packages\xlrd-1.0.0-py2.7.egg
Processing dependencies for xlrd
Finished processing dependencies for xlrd
Searching for pyopt
Best match: pyopt 0.84
Processing pyopt-0.84-py2.7.egg
pyopt 0.84 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\pyopt-0.84-py2.7.egg
Processing dependencies for pyopt
Finished processing dependencies for pyopt
Searching for py2exe
Best match: py2exe 0.9.2.2
Processing py2exe-0.9.2.2-py2.7-win32.egg
py2exe 0.9.2.2 is already the active version in easy-install.pth
Installing build_exe-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe-script.pyc script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe.manifest script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe-script.py script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe script to C:\Python27\openmdao-0.7.0\Scripts
Installing build_exe.exe.manifest script to C:\Python27\openmdao-0.7.0\Scripts

Using c:\python27\openmdao-0.7.0\lib\site-packages\py2exe-0.9.2.2-py2.7-win32.eg
g
Processing dependencies for py2exe
Finished processing dependencies for py2exe
Searching for pyzmq
Reading https://pypi.python.org/simple/pyzmq/
Downloading https://pypi.python.org/packages/af/37/8e0bf3800823bc247c36715a52e92
4e8f8fd5d1432f04b44b8cd7a5d7e55/pyzmq-16.0.2.tar.gz#md5=9a8768b00a566a400d70318f
8c359cfe
Best match: pyzmq 16.0.2
Processing pyzmq-16.0.2.tar.gz
Writing c:\users\anur\appdata\local\temp\easy_install-6x9i5o\pyzmq-16.0.2\setup.
cfg
Running pyzmq-16.0.2\setup.py -q bdist_egg --dist-dir c:\users\anur\appdata\loca
l\temp\easy_install-6x9i5o\pyzmq-16.0.2\egg-dist-tmp-fszbbf
warning: no files found matching 'tox.ini'
no previously-included directories found matching 'docs\build'
no previously-included directories found matching 'docs\gh-pages'
warning: no previously-included files found matching 'bundled\zeromq\src\Makefil
e*'
warning: no previously-included files found matching 'bundled\zeromq\src\platfor
m.hpp'
warning: no previously-included files found matching 'zmq\libzmq*'
warning: no previously-included files matching '__pycache__\*' found anywhere in
 distribution
warning: no previously-included files matching '.deps\*' found anywhere in distr
ibution
warning: no previously-included files matching '*.so' found anywhere in distribu
tion
warning: no previously-included files matching '*.pyd' found anywhere in distrib
ution
warning: no previously-included files matching '.git*' found anywhere in distrib
ution
warning: no previously-included files matching '.DS_Store' found anywhere in dis
tribution
warning: no previously-included files matching '.mailmap' found anywhere in dist
ribution
warning: no previously-included files matching 'Makefile.am' found anywhere in d
istribution
warning: no previously-included files matching 'Makefile.in' found anywhere in d
istribution
************************************************
Warning: Couldn't find an acceptable libzmq on the system.

If you expected pyzmq to link against an installed libzmq, please check to make
sure:

    * You have a C compiler installed
    * A development version of Python is installed (including headers)
    * A development version of ZMQ >= 3.2 is installed (including headers)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location,
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`

You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:

    `--zmq=bundled`

I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...

 1...
************************************************
Using bundled libzmq
already have bundled\zeromq
staging platform.hpp from: bundled\zeromq\builds\msvc
************************************************
In file included from zmq\utils/zmq_compat.h:16:0,
                 from zmq\devices\monitoredqueue.c:403:
bundled\zeromq\include/zmq.h:439:52: error: unknown type name 'uint8_t'
 ZMQ_EXPORT char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);

                                                    ^
bundled\zeromq\include/zmq.h:442:12: error: unknown type name 'uint8_t'
 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
            ^
bundled\zeromq\include/zmq.h:442:37: error: unknown type name 'uint8_t'
 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
                                     ^
In file included from zmq\devices\monitoredqueue.c:403:0:
zmq\devices\monitoredqueue.c: In function '__pyx_f_3zmq_7devices_14monitoredqueu
e__relay':
zmq\utils/zmq_compat.h:12:23: error: unknown type name 'int64_t'
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1761:3: note: in expansion of macro 'pyzmq_int64_t'

   pyzmq_int64_t __pyx_v_flag_2;
   ^
zmq\utils/zmq_compat.h:12:23: error: 'int64_t' undeclared (first use in this fun
ction)
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1786:30: note: in expansion of macro 'pyzmq_int64_t
'
     __pyx_v_flagsz = (sizeof(pyzmq_int64_t));
                              ^
zmq\utils/zmq_compat.h:12:23: note: each undeclared identifier is reported only
once for each function it appears in
 #define pyzmq_int64_t int64_t
                       ^
zmq\devices\monitoredqueue.c:1786:30: note: in expansion of macro 'pyzmq_int64_t
'
     __pyx_v_flagsz = (sizeof(pyzmq_int64_t));
                              ^
zmq\devices\monitoredqueue.c: In function '__Pyx_RaiseArgtupleInvalid':
zmq\devices\monitoredqueue.c:5271:18: warning: unknown conversion type character
 'z' in format [-Wformat=]
                  (num_expected == 1) ? "" : "s", num_found);
                  ^
zmq\devices\monitoredqueue.c:5271:18: warning: format '%s' expects argument of t
ype 'char *', but argument 5 has type 'Py_ssize_t' [-Wformat=]
zmq\devices\monitoredqueue.c:5271:18: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:5271:18: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c: In function '__Pyx_CyFunction_CallMethod':
zmq\devices\monitoredqueue.c:6537:17: warning: unknown conversion type character
 'z' in format [-Wformat=]
                 f->m_ml->ml_name, size);
                 ^
zmq\devices\monitoredqueue.c:6537:17: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c:6553:17: warning: unknown conversion type character
 'z' in format [-Wformat=]
                 f->m_ml->ml_name, size);
                 ^
zmq\devices\monitoredqueue.c:6553:17: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c: In function '__Pyx_ImportType':
zmq\devices\monitoredqueue.c:7390:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
             module_name, class_name, basicsize, size);
             ^
zmq\devices\monitoredqueue.c:7390:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:7390:13: warning: too many arguments for format [-W
format-extra-args]
zmq\devices\monitoredqueue.c:7396:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
             module_name, class_name, basicsize, size);
             ^
zmq\devices\monitoredqueue.c:7396:13: warning: unknown conversion type character
 'z' in format [-Wformat=]
zmq\devices\monitoredqueue.c:7396:13: warning: too many arguments for format [-W
format-extra-args]
error: Setup script exited with error: command 'c:\\Rtools\\mingw_32\\bin\\gcc.e
xe' failed with exit status 1
Searching for sphinxcontrib-bibtex
Best match: sphinxcontrib-bibtex 0.3.5
Processing sphinxcontrib_bibtex-0.3.5-py2.7.egg
sphinxcontrib-bibtex 0.3.5 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinxcontrib_bibtex-0.3.5-py
2.7.egg
Processing dependencies for sphinxcontrib-bibtex
Finished processing dependencies for sphinxcontrib-bibtex
Searching for sphinxcontrib-napoleon
Best match: sphinxcontrib-napoleon 0.6.1
Processing sphinxcontrib_napoleon-0.6.1-py2.7.egg
sphinxcontrib-napoleon 0.6.1 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\sphinxcontrib_napoleon-0.6.1-
py2.7.egg
Processing dependencies for sphinxcontrib-napoleon
Finished processing dependencies for sphinxcontrib-napoleon
Searching for numpydoc
Best match: numpydoc 0.7.0
Processing numpydoc-0.7.0-py2.7.egg
numpydoc 0.7.0 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\numpydoc-0.7.0-py2.7.egg
Processing dependencies for numpydoc
Finished processing dependencies for numpydoc
Searching for ipython
Reading https://pypi.python.org/simple/ipython/
Downloading https://pypi.python.org/packages/79/63/b671fc2bf0051739e87a7478a207b
beb45cfae3c328d38ccdd063d9e0074/ipython-6.1.0.tar.gz#md5=1e15e1ce3f3f722da6935d7
ac0e51346
Best match: ipython 6.1.0
Processing ipython-6.1.0.tar.gz
Writing c:\users\anur\appdata\local\temp\easy_install-k7ruj5\ipython-6.1.0\setup
.cfg
Running ipython-6.1.0\setup.py -q bdist_egg --dist-dir c:\users\anur\appdata\loc
al\temp\easy_install-k7ruj5\ipython-6.1.0\egg-dist-tmp-tkov77

IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.

Beginning with IPython 6.0, Python 3.3 and above is required.

See IPython `README.rst` file for more information:

    https://github.com/ipython/ipython/blob/master/README.rst

Python sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial
=0) detected.

error: Setup script exited with 1
Searching for python-dateutil
Best match: python-dateutil 2.6.0
Processing python_dateutil-2.6.0-py2.7.egg
python-dateutil 2.6.0 is already the active version in easy-install.pth

Using c:\python27\openmdao-0.7.0\lib\site-packages\python_dateutil-2.6.0-py2.7.e
gg
Processing dependencies for python-dateutil
Finished processing dependencies for python-dateutil
install url: package= fusedwind url=  http://github.com/FUSED-Wind/fusedwind/tar
ball/develop
installing distribution from current directory as a 'develop' egg
running develop
running egg_info
creating src\fusedwind.egg-info
writing requirements to src\fusedwind.egg-info\requires.txt
writing src\fusedwind.egg-info\PKG-INFO
writing top-level names to src\fusedwind.egg-info\top_level.txt
writing dependency_links to src\fusedwind.egg-info\dependency_links.txt
writing manifest file 'src\fusedwind.egg-info\SOURCES.txt'
reading manifest file 'src\fusedwind.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no directories found matching 'src\fusedwind\sphinx_build\html'
writing manifest file 'src\fusedwind.egg-info\SOURCES.txt'
running build_ext
Creating c:\python27\openmdao-0.7.0\lib\site-packages\fusedwind.egg-link (link t
o src)
Adding fusedwind 0.1.0 to easy-install.pth file

Installed c:\python27\openmdao-0.7.0\wisdem\plugins\fusedwind\src
subprocess returned  0
install url: package= Turbine_CostsSE url=  http://github.com/WISDEM/Turbine_Cos
tsSE/tarball/0.1
installing distribution from current directory as a 'develop' egg
running develop
running egg_info
creating src\Turbine_CostsSE.egg-info
writing requirements to src\Turbine_CostsSE.egg-info\requires.txt
writing src\Turbine_CostsSE.egg-info\PKG-INFO
writing top-level names to src\Turbine_CostsSE.egg-info\top_level.txt
writing dependency_links to src\Turbine_CostsSE.egg-info\dependency_links.txt
writing manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
reading manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching 'openmdao_log.txt' found anywhere
 in distribution
writing manifest file 'src\Turbine_CostsSE.egg-info\SOURCES.txt'
running build_ext
Creating c:\python27\openmdao-0.7.0\lib\site-packages\Turbine-CostsSE.egg-link (
link to src)
Adding Turbine-CostsSE 0.1.0 to easy-install.pth file

Installed c:\python27\openmdao-0.7.0\wisdem\plugins\turbine_costsse\src
subprocess returned  0
install url: package= CommonSE url=  http://github.com/WISDEM/CommonSE/tarball/0
.1
Traceback (most recent call last):
  File "setup_all.py", line 105, in <module>
    install_url(f, url,force=options.force)
  File "setup_all.py", line 28, in install_url
    thetarfile = tarfile.open(fileobj=response, mode="r|gz")
  File "C:\Python27\Lib\tarfile.py", line 1703, in open
    stream = _Stream(name, filemode, comptype, fileobj, bufsize)
  File "C:\Python27\Lib\tarfile.py", line 430, in __init__
    self._init_read_gz()
  File "C:\Python27\Lib\tarfile.py", line 524, in _init_read_gz
    raise ReadError("not a gzip file")
tarfile.ReadError: not a gzip file

(openmdao-0.7.0) C:\Python27\openmdao-0.7.0\WISDEM>'


问:
Divide the population Fortran - receiving zeros
I have a program to read and stratify an R file of multivariate normal population with (x, y) values. I want to divide the population into two groups, where the division is based on if x and y is higher or below a specific number.

When I do the stratification in Fortran, I get no results but zeros for x and y, something like this

```<code>total number of individuals        1551
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000

.
.
.
</code>```

The original data looks like this

```<code>755,885
656,841
742,844
747,829
776,861
696,809
782,891
771,867
760,826
812,830
711,792
736,840
738,873
793,833
751,836
747,871
796,830
711,868
747,843
758,835
760,824
759,839
696,868
</code>```

I have attached the file to the original data from R as well

```<code>program test

implicit none

    real, dimension(:), allocatable :: x,y
    real, dimension(:,:), allocatable :: s1, s2, s3, s4
    integer::  io, l1, l2, l3,l4,n,i

    open(33, file = '', status = 'old', action = 'read')
    n = 0
    DO
        READ(33,*,iostat=io)
        IF (io/=0) EXIT
        n = n + 1
    END DO

    allocate(x(n) ,y(n))
    rewind(33)

    DO i =1,n
        READ(33,*) x(i), y(i)
    END DO

    allocate(s1(n,2))
    allocate(s2(n,2))
    allocate(s3(n,2))
    allocate(s4(n,2))

    s1=0
    s2=0
    s3=0
    s4=0

    l1=1
    l2=1
    l3=1
    l4=1

    do i = 1 , n
        if (x(i) >=0 .AND. x(i)<=500) then
            if( y(i) >= 0 .AND. y(i) <=500) then
                s1(l1, :)=(/x(i), y(i) /)
                l1=l1+1
            end if

        else if (x(i)  > 500  .AND.  x(i)  <= 1000 ) then
            if ( y(i) > 0  .AND. y(i) < 500 ) then
                s2(l2, :)=(/x(i), y(i) /)
                l2=l2+1
            end if
        end if

        write(*,*)  s1(l1, :)
    end do !iloop

end program test
</code>```

I have no idea what I am doing here wrong.

答:
This is known as the "dangling ELSE problem". FORTRAN thinks that the "else if (x(i) > 500 ..." part belongs to the "if( y(i) >= 0 .AND. y(i) <=500)" statement. Add an "END IF" before the "else".</p>

```<code> do i = 1 , n
    if (x(i) >=0 .AND. x(i)<=500) THEN
        if( y(i) >= 0 .AND. y(i) <=500) THEN
            s1(l1, :)=(/x(i), y(i) /)
                l1=l1+1
        end if
    else if (x(i)  > 500  .AND.  x(i)  <= 1000 )THEN
        if ( y(i) > 0  .AND. y(i) < 500 ) THEN
            s2(l2, :)=(/x(i), y(i) /)
                l2=l2+1
        END IF
    END IF
END do !iloop
</code>```

Body:
I have a program to read and stratify an R file of multivariate normal population with (x, y) values. I want to divide the population into two groups, where the division is based on if x and y is higher or below a specific number.

When I do the stratification in Fortran, I get no results but zeros for x and y, something like this

total number of individuals        1551
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000
   0.00000000       0.00000000

.
.
.

The original data looks like this

755,885
656,841
742,844
747,829
776,861
696,809
782,891
771,867
760,826
812,830
711,792
736,840
738,873
793,833
751,836
747,871
796,830
711,868
747,843
758,835
760,824
759,839
696,868

I have attached the file to the original data from R as well

program test

implicit none

    real, dimension(:), allocatable :: x,y
    real, dimension(:,:), allocatable :: s1, s2, s3, s4
    integer::  io, l1, l2, l3,l4,n,i

    open(33, file = '', status = 'old', action = 'read')
    n = 0
    DO
        READ(33,*,iostat=io)
        IF (io/=0) EXIT
        n = n + 1
    END DO

    allocate(x(n) ,y(n))
    rewind(33)

    DO i =1,n
        READ(33,*) x(i), y(i)
    END DO

    allocate(s1(n,2))
    allocate(s2(n,2))
    allocate(s3(n,2))
    allocate(s4(n,2))

    s1=0
    s2=0
    s3=0
    s4=0

    l1=1
    l2=1
    l3=1
    l4=1

    do i = 1 , n
        if (x(i) >=0 .AND. x(i)<=500) then
            if( y(i) >= 0 .AND. y(i) <=500) then
                s1(l1, :)=(/x(i), y(i) /)
                l1=l1+1
            end if

        else if (x(i)  > 500  .AND.  x(i)  <= 1000 ) then
            if ( y(i) > 0  .AND. y(i) < 500 ) then
                s2(l2, :)=(/x(i), y(i) /)
                l2=l2+1
            end if
        end if

        write(*,*)  s1(l1, :)
    end do !iloop

end program test

I have no idea what I am doing here wrong.

Body:
This is known as the "dangling ELSE problem". FORTRAN thinks that the "else if (x(i) > 500 ..." part belongs to the "if( y(i) >= 0 .AND. y(i) <=500)" statement. Add an "END IF" before the "else".

 do i = 1 , n
    if (x(i) >=0 .AND. x(i)<=500) THEN
        if( y(i) >= 0 .AND. y(i) <=500) THEN
            s1(l1, :)=(/x(i), y(i) /)
                l1=l1+1
        end if
    else if (x(i)  > 500  .AND.  x(i)  <= 1000 )THEN
        if ( y(i) > 0  .AND. y(i) < 500 ) THEN
            s2(l2, :)=(/x(i), y(i) /)
                l2=l2+1
        END IF
    END IF
END do !iloop


问:
Could not load main class when compiled and executed with Runtime.exec()
I have the following code to run three executions :

```<code>            public static void main(String[] args) throws InterruptedException, IOException
            {
                String filepath1 = "cmd /c gradlew jmhJar";
                String filepath2 = "cmd /c java -jar path/to/the/file/filename.jar -rf csv -rff path/to/save/file1.csv -wi 3 -i 5 -f 2";
                String filepath4 = "cmd /c javac path/to/the/file/ParserHash.java";/*Code to compile is parserHash.java*/

    String filepath3 = "cmd /c java path/to/the/compiled/class/ParserHash "C:/Users/msek/Desktop/trial/result/file1.csv C:/Users/msek/Desktop/trial/result/file2.csv C:/Users/msek/Desktop/trial/result/file3.csv";
                try
                    {
                    runProcess(filepath1);
                    runProcess(filepath2);
                    System.out.println("Sucessfully written into file1.csv");
                    runProcess(filepath4);
                    System.out.println("Compilation Over");
                    runProcess(filepath3);
                    System.out.println("Program Sucessfully Executed");
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                }

public static void  runProcess(String processString)
{
    try
    {

     final Process p = Runtime.getRuntime().exec(processString);

        new Thread(new Runnable() {
            public void run() {
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line = null;

                try {
                    while ((line = input.readLine()) != null)
                        System.out.println(line);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        p.waitFor();
    }

    catch (Exception x)
    {
        x.printStackTrace();
    }
}
</code>```

If I compile the java file going to that particular directory and compile its compiling successfully and on running it, it executes successfully. But if I pass it like "cmd /c path/to/java/file/file.java" its getting compiled but when I execute it, I get an error stating that could not find or load mainclass eventhough class file is present.

I have looked various links on this which suggested buid process, but that didn't work.

I just want to know where I'm going wrong and how to compile, execute a java file by passing multiple arguments using Runtime.exec()..

答:
```<code>java path/to/the/compiled/class/ParserHash
</code>```

If you're having trouble with an exec() you should:

Try the command from a command line yourself. It will fail the same way in this case.

Look up the syntax of the command. In this case you will learn that the argument to the java command is not a path but a class name, fully qualified, i.e. including the package name. With dots.

Body:
I have the following code to run three executions :

            public static void main(String[] args) throws InterruptedException, IOException
            {
                String filepath1 = "cmd /c gradlew jmhJar";
                String filepath2 = "cmd /c java -jar path/to/the/file/filename.jar -rf csv -rff path/to/save/file1.csv -wi 3 -i 5 -f 2";
                String filepath4 = "cmd /c javac path/to/the/file/ParserHash.java";/*Code to compile is parserHash.java*/

    String filepath3 = "cmd /c java path/to/the/compiled/class/ParserHash "C:/Users/msek/Desktop/trial/result/file1.csv C:/Users/msek/Desktop/trial/result/file2.csv C:/Users/msek/Desktop/trial/result/file3.csv";
                try
                    {
                    runProcess(filepath1);
                    runProcess(filepath2);
                    System.out.println("Sucessfully written into file1.csv");
                    runProcess(filepath4);
                    System.out.println("Compilation Over");
                    runProcess(filepath3);
                    System.out.println("Program Sucessfully Executed");
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                }

public static void  runProcess(String processString)
{
    try
    {

     final Process p = Runtime.getRuntime().exec(processString);

        new Thread(new Runnable() {
            public void run() {
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line = null;

                try {
                    while ((line = input.readLine()) != null)
                        System.out.println(line);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        p.waitFor();
    }

    catch (Exception x)
    {
        x.printStackTrace();
    }
}

If I compile the java file going to that particular directory and compile its compiling successfully and on running it, it executes successfully. But if I pass it like "cmd /c path/to/java/file/file.java" its getting compiled but when I execute it, I get an error stating that could not find or load mainclass eventhough class file is present.

I have looked various links on this which suggested buid process, but that didn't work.

I just want to know where I'm going wrong and how to compile, execute a java file by passing multiple arguments using Runtime.exec()..

Body:
java path/to/the/compiled/class/ParserHash

If you're having trouble with an exec() you should:

Try the command from a command line yourself. It will fail the same way in this case.

Look up the syntax of the command. In this case you will learn that the argument to the java command is not a path but a class name, fully qualified, i.e. including the package name. With dots.


问:
UITabbar Application with different Orientations
i've got a iPad TabBarApplication. i subclassed the TabbarController to make the Application react to a orientation change:

@implementation frankenlandTabBarController

```<code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (
            interfaceOrientation == UIInterfaceOrientationPortrait ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
            interfaceOrientation == UIInterfaceOrientationLandscapeRight
            );
}

@end
</code>```

the problem now is, that i dont want ALL viewcontrollers of my tabbarapp in this orientations.

overwriting the shouldAutorotateToInterfaceOrientation method in a single controller does not have any effect.

any ideas?

thanks!

答: It's not possible to change the orientation for one view in a tabBar and not for another. If a TabBar is specified then all the subviews (tabs) must have the same orientation appearance. You must set the orientation in each ViewController and in the TabBarController.</p>

Body:
i've got a iPad TabBarApplication. i subclassed the TabbarController to make the Application react to a orientation change:

@implementation frankenlandTabBarController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (
            interfaceOrientation == UIInterfaceOrientationPortrait ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
            interfaceOrientation == UIInterfaceOrientationLandscapeRight
            );
}

@end

the problem now is, that i dont want ALL viewcontrollers of my tabbarapp in this orientations.

overwriting the shouldAutorotateToInterfaceOrientation method in a single controller does not have any effect.

any ideas?

thanks!


问:
initialize pandas SparseArray
Is it possible to initialize a pandas SparseArray by providing only the dense entries? I could not figure this out from the documentation: http://pandas.pydata.org/pandas-docs/stable/sparse.html .

For example, say I want a length 1000 SparseArray with a one at index 9 and zeros everywhere else, how would I go about creating it? This is one way:

```<code>a = [0] * 1000
a[9] = 1
sparse_a = pd.SparseArray(data=a, fill_value=0)
</code>```

But, in the above, we have to create the dense array before the sparse one. Is there a way to specify only the indices and the dense entries to create the SparseArray directly?

答:
A length 10 SparseArray with a one at index 9 and zeros everywhere else:

```<code>pd.SparseArray(1, index= range(1), kind='block',
               sparse_index= BlockIndex(10, [8], [1]),
               fill_value=0)
</code>```

Notes:

index could be any list as long as its length is equal to all non-sparsed part of the array (the smaller part of the data), in this case, number of 1 in the sparse array

BlockIndex(10, [8], [1]) is the object pointing to the positions of the non-parsed part of the data where the first argument is the TOTAL length of the array (sparse + non-sparse), the second argument is a list of starting positions of the non-sparse data and the third argument is a list of how long each block of non-sparse lasts. Notice: that the length of the array mentioned in point 1 is the sum of all elements of the list in the third argument of this BlockIndex

So a more general example is: to make a length 20 SparseArray where the 2nd, 3rd, 6th,7th,8th elements are 1 and the rest is 0 is:

```<code>pd.SparseArray(1, index= range(5), kind='block',
               sparse_index= BlockIndex(20, [1,5], [2,3]),
               fill_value=0)
</code>```

or

```<code>pd.SparseArray(1, index= [None, 3, 2, 7, np.inf], kind='block',
               sparse_index= BlockIndex(20, [1,5], [2,3]),
               fill_value=0)
</code>```

Sadly, I don't know any good way to specify an array of non-sparsed data as the first argument for SparseArray-- it does not mean that it can't be done, this is only a disclaimer. I think as long as you specify index=... pandas will require a scalar for the first argument (the data).

Tested on Windows 7, pandas version 0.20.2 installed by Aconda.

Title: initialize pandas SparseArray

Body:
Is it possible to initialize a pandas SparseArray by providing only the dense entries? I could not figure this out from the documentation: http://pandas.pydata.org/pandas-docs/stable/sparse.html .

For example, say I want a length 1000 SparseArray with a one at index 9 and zeros everywhere else, how would I go about creating it? This is one way:

a = [0] * 1000
a[9] = 1
sparse_a = pd.SparseArray(data=a, fill_value=0)

But, in the above, we have to create the dense array before the sparse one. Is there a way to specify only the indices and the dense entries to create the SparseArray directly?

Body:
A length 10 SparseArray with a one at index 9 and zeros everywhere else:

pd.SparseArray(1, index= range(1), kind='block',
               sparse_index= BlockIndex(10, [8], [1]),
               fill_value=0)

Notes:

index could be any list as long as its length is equal to all non-sparsed part of the array (the smaller part of the data), in this case, number of 1 in the sparse array

BlockIndex(10, [8], [1]) is the object pointing to the positions of the non-parsed part of the data where the first argument is the TOTAL length of the array (sparse + non-sparse), the second argument is a list of starting positions of the non-sparse data and the third argument is a list of how long each block of non-sparse lasts. Notice: that the length of the array mentioned in point 1 is the sum of all elements of the list in the third argument of this BlockIndex

So a more general example is: to make a length 20 SparseArray where the 2nd, 3rd, 6th,7th,8th elements are 1 and the rest is 0 is:

pd.SparseArray(1, index= range(5), kind='block',
               sparse_index= BlockIndex(20, [1,5], [2,3]),
               fill_value=0)

or

pd.SparseArray(1, index= [None, 3, 2, 7, np.inf], kind='block',
               sparse_index= BlockIndex(20, [1,5], [2,3]),
               fill_value=0)

Sadly, I don't know any good way to specify an array of non-sparsed data as the first argument for SparseArray-- it does not mean that it can't be done, this is only a disclaimer. I think as long as you specify index=... pandas will require a scalar for the first argument (the data).

Tested on Windows 7, pandas version 0.20.2 installed by Aconda.


问:
Why related field not showing value on view in odoo 10?
I am working on point of sale where i need to display 'Payment Journal'(Cash / Cheque) and statement id (statement) from 'Accounting' module which containing these fields only not POS. S o need to display in tree view of Point of sale(orders) list.
here is my code i tried :</p>

```<code>journal_ids = fields.Many2one('account.journal', string='Journal', readonly=True, domain=[('type', 'in', ('bank', 'cash'))])
journal_id = fields.Char(related='journal_ids.type', store=True)
</code>```

答: This is working in base "Point of Sale".. You can take reference from "account_journal_view.xml" In this you get to know that they are just using tree view of account model in POS "Payment Method" menu.  Just inherit this in your custom module add fields what you want to add using  tag in tree view and you get result what you want.

Body:
I am working on point of sale where i need to display 'Payment Journal'(Cash / Cheque) and statement id (statement) from 'Accounting' module which containing these fields only not POS. S o need to display in tree view of Point of sale(orders) list.
here is my code i tried :

journal_ids = fields.Many2one('account.journal', string='Journal', readonly=True, domain=[('type', 'in', ('bank', 'cash'))])
journal_id = fields.Char(related='journal_ids.type', store=True)


问:
how to display middle name as middle initial if middle name have two words
so i created a form which have middle name field and display the middle name as initial.

preg_split("/[\s,_-]+/",$data["s_mname"])

this code works IF the middle name is only one word.. like Snow it will display as S but my problem is if the middle name is 2 words like De Leon, Delos Santos the initial that will be displayed is DL,DS.. but it should display as D... any idea how to do this..

SUBSTR($data["s_mname"],strrchr($data["s_mname"], ' '), 1)

i tried this code but nothing works i just got this from other site..

答:
```<code>preg_match_all('/\s\w/', $data["s_mname"], $matches, PREG_SET_ORDER);
/*echo end($matches)[0];*/
echo $matches[0][0];
</code>```

Try this code, and you can use it as per your need

Body:
preg_match_all('/\s\w/', $data["s_mname"], $matches, PREG_SET_ORDER);
/*echo end($matches)[0];*/
echo $matches[0][0];

Try this code, and you can use it as per your need


问:
In Google Maps iOS how to turn Marker as per turns on road like in Uber's Trip screen
I am working on an iOS application that works like Uber. When the device moves I am moving the car marker as well. But am not able to turn it as per turns on road like Uber does. How can I make it possible?
Also how can I keep this car marker only on road?</p>

答:
You can calculate bearing then rotate marker based on the calculated bearing.
Use this function to calculate bearing:

```<code>+(float)getBearing:(CLLocationCoordinate2D)locations1 andSecond:(CLLocationCoordinate2D)locattion2
{
    float fLat = degreesToRadians(locations1.latitude);
    float fLng = degreesToRadians(locations1.longitude);
    float tLat = degreesToRadians(locattion2.latitude);
    float tLng = degreesToRadians(locattion2.longitude);

    float degree = radiansToDegrees(atan2(sin(tLng-fLng)*cos(tLat), cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng)));

    if (degree >= 0) {
        return degree;
    } else {
        return 360+degree;
    }
}
</code>```

Then rotate the marker itself using rotation property

```<code>marker.rotation = CALCULATED_BEARING - 180;
</code>```

Body:
You can calculate bearing then rotate marker based on the calculated bearing.
Use this function to calculate bearing:

+(float)getBearing:(CLLocationCoordinate2D)locations1 andSecond:(CLLocationCoordinate2D)locattion2
{
    float fLat = degreesToRadians(locations1.latitude);
    float fLng = degreesToRadians(locations1.longitude);
    float tLat = degreesToRadians(locattion2.latitude);
    float tLng = degreesToRadians(locattion2.longitude);

    float degree = radiansToDegrees(atan2(sin(tLng-fLng)*cos(tLat), cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng)));

    if (degree >= 0) {
        return degree;
    } else {
        return 360+degree;
    }
}

Then rotate the marker itself using rotation property

marker.rotation = CALCULATED_BEARING - 180;


问:
How can I launch another app in full screen using LaunchUriForResultAsync?
I would like to use the LaunchUriForResultAsync to launch my other app and get some results from it. But I want to launch the other app in full screen and if that's not possible maybe just launch it in a bigger size.

When I launch another app using LaunchUriForResultAsync, the modal app launches in 500x500 size. I would need something bigger than that because I need to create a data entry app that requires more space which multiple applications can launch. I tried to set the DesiredRemainingView and PreferredLaunchWindowingMode to FullScreen. It didn't make my other app launch in full screen.

Is there a way I can use LaunchUriForResultAsync to launch my other app in full screen?

答:
It is not possible to control the size of the window launched for results. In current versions of Windows this size is hard coded to 500x500. Providing a way to allow an app to control this is being investigated for future a future update.

Since you control both apps you could write a custom system to manage the communication rather than use LaunchUriForResultAsync. AppA and AppB can each define their own protocols (appa: and appb:). AppA can LaunchUriAsync appb: to do whatever it needs, then AppB can LaunchUriAsync appa: to deliver the results. Pass AppA's return URL as an argument to appb: and this can be called from multiple apps.

The trickiest part may be to manage the modality. It's easy to disable AppA's page while it's waiting, but harder to link AppB's window to AppA's after the initial launch. Off the top of my head I'd just relaunch appb: and make sure appb: can track and handle multiple launches sanely.

This is more or less what LaunchUriForResultAsync does for you.