Asked  7 Months ago    Answers:  5   Viewed   21 times

float('nan') results in Nan (not a number). But how do I check for it? Should be very easy, but I cannot find it.

 Answers

47

math.isnan(x)

Return True if x is a NaN (not a number), and False otherwise.

>>> import math
>>> x = float('nan')
>>> math.isnan(x)
True
Tuesday, June 1, 2021
 
davidb
answered 7 Months ago
32
>>> import math
>>> print math.sin.__doc__
sin(x)

Return the sine of x (measured in radians).

math.sin expects its argument to be in radians, not degrees, so:

>>> import math
>>> print math.sin(math.radians(68))
0.927183854567
Thursday, July 29, 2021
 
Crashthatch
answered 5 Months ago
48

here is a complete example where the DataGridViewColumns are created in the IDE so there is no code showing them being created.

''' <summary>
''' DataGridView columns were created in the IDE
''' </summary>
''' <remarks></remarks>
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DataGridView1.Rows.Add(New Object() {"John", "USA", True})
        DataGridView1.Rows.Add(New Object() {"Mike", "AU", False})
        DataGridView1.Rows.Add(New Object() {"Jack", "EU", True})
        DataGridView1.Rows.Add(New Object() {"Mike", "AU", False})
    End Sub
    Private Sub DataGridView1SelectAll_CurrentCellDirtyStateChanged(
        ByVal sender As Object,
        ByVal e As EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged

        RemoveHandler DataGridView1.CurrentCellDirtyStateChanged,
            AddressOf DataGridView1SelectAll_CurrentCellDirtyStateChanged

        If TypeOf DataGridView1.CurrentCell Is DataGridViewCheckBoxCell Then
            DataGridView1.EndEdit()
            Dim Checked As Boolean = CType(DataGridView1.CurrentCell.Value, Boolean)
            If Checked Then
                MessageBox.Show("You have checked")
            Else
                MessageBox.Show("You have un-checked")
            End If
        End If

        AddHandler DataGridView1.CurrentCellDirtyStateChanged,
            AddressOf DataGridView1SelectAll_CurrentCellDirtyStateChanged
    End Sub
End Class

enter image description here

Here is a language extension method that also be helpful in that by say pressing a button you can get all rows that are checked. It would be easy to adjust so that you could ask for either checked or unchecked rows.

Module Module1
    <System.Diagnostics.DebuggerStepThrough()> _
    <Runtime.CompilerServices.Extension()> _
    Public Function GetCheckedRows1(
        ByVal GridView As DataGridView,
        ByVal ColumnName As String) As List(Of DataGridViewRow)
        Return _
            (
                From SubRows In
                    (
                        From Rows In GridView.Rows.Cast(Of DataGridViewRow)()
                        Where Not Rows.IsNewRow
                    ).ToList
                Where CBool(SubRows.Cells(ColumnName).Value) = True
            ).ToList
    End Function
End Module

Usage

Dim rowsCheckedList As List(Of DataGridViewRow) =
    DataGridView1.GetCheckedRows1("ProcessColumn")

See also my MSDN code samples on this topic. They are done in VS2013 and if using a lesser version you can still view the code online.

Monday, August 30, 2021
 
Asher
answered 3 Months ago
23

Try this using attribute selector

$.each(arrayValues, function(i, val){

   $("input[value='" + val + "']").prop('checked', true);

});
Saturday, September 18, 2021
 
Sasha
answered 3 Months ago
68

This is because the pyparsing code allows functions. (And by the way, it does a lot more than what you need, i.e. create a stack and evaluate that.)

For starters, you could remove pi and ident (and possibly something else I'm missing right now) from the code to disallow characters.

The reason is different: PyParsing parsers won't try to consume the whole input by default. You have to add + StringEnd() (and import it, of course) to the end of expr to make it fail if it can't parse the whole input. In that case, pyparsing.ParseException will be raised. (Source: http://pyparsing-public.wikispaces.com/FAQs)

If you care to learn a bit of parsing, what you need can propably be built in less than thirty lines with any decent parsing library (I like LEPL).

Tuesday, September 28, 2021
 
StevenR
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share