Search results for

column

2,071 results found

Post

Replies

Boosts

Views

Activity

timeseriesclassifier
After I have a dataframe of data with one column as features with type MLshapedarray and one column of annotations with type Int. How can I convert them to the correct input type for the timeseriesclassifier?
0
0
639
Jul ’24
How to animate NavigationSplitView's detailView column.
Having a traditional 'NavigationSplitView' setup, I am looking for a way to animate it the same as the sidebarView, where there is a button to toggle and it animates by sliding out from the right side of the view, however the closest I have gotten was manipulating the 'navigationSplitViewColumnWidth' but that always results in the view instantly appearing / disappearing. I am using SwiftUI for a MacOS specific app. Here is just a general idea of what I am currently doing, it is by no means a reflection of my real code but serves the purpose of this example. struct ContentView: View { @State private var columnWidth: CGFloat = 300 var body: some View { NavigationSplitView { List { NavigationLink(destination: DetailView(item: Item 1)) { Text(Item 1) } NavigationLink(destination: DetailView(item: Item 2)) { Text(Item 2) } NavigationLink(destination: DetailView(item: Item 3)) { Text(Item 3) } } .navigationTitle(Items) } detail: { VStack { DetailView(item: Select an item) Button(action: toggleColumnWidth) { Text(co
1
0
940
Jun ’24
Reply to Peculiar EXC_BAD_ACCESS, involving sparse matrices
the sparseMatrix function with comments: extension Array where Element == [Double] { // A sparse matrix is a mattrix where all zero's are ommitted. // Normal matrix: Sparse matrix: // 0 1 0 1 // 1 3 0 1 3 // 4 0 2 4 2 // Find the sparse matrix of this matrix. Returns an array of doubles containing the values of the sparse matrix (omitting all zero's) and a SparseMatrixStructure containing information about where the columns start and where the rows start. The values array of the sparse matrix above would be [1, 4, 1, 3, 2]. func sparseMatrix() -> (structure: SparseMatrixStructure, values: [Double]) { let columns = self.transpose() // Get the row indices of the matrix. The row indices of the sparse matrix above would be // [1, 2 column 0 // 0, 1, column 1 // 2] column 2 var rowIndices: [Int32] = columns.map { column in column.indices.compactMap { indexInColumn in if column[indexInColumn] != 0 { return Int32(indexInColumn) } return nil } }.reduce
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Reply to Peculiar EXC_BAD_ACCESS, involving sparse matrices
The SavitzkyGolay class with comments: class SavitzkyGolay { static func coefficients(windowLength: Int, polynomialOrder: Int, derivativeOrder: Int = 0, delta: Int = 1) -> [Double] { // windowLength is the number of coefficients returned by this function. guard windowLength > 0 else { fatalError(windowLength must be positive) } // polynomialOrder is the order of the polynomial used to smooth the noisy data (the coefficients are calculated independently from the noisy data) guard polynomialOrder < windowLength else { fatalError(polynomialOrder must be less than windowLength) } // The derivativeOrder is the order of the derivative to compute. If it is set to zero, the noisy data is smoothed without differentiating. guard derivativeOrder <= polynomialOrder else { return [Double](repeating: 0, count: windowLength) } let (halfWindow, remainder) = windowLength.quotientAndRemainder(dividingBy: 2) var pos = Double(halfWindow) // pos should not be a round number (because otherwise this function won't work
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Peculiar EXC_BAD_ACCESS, involving sparse matrices
Helo all, Currently, I'm working on an iOS app that performs measurement and shows the results to the user in a graph. I use a Savitzky-Golay filter to filter out noise, so that the graph is nice and smooth. However, the code that calculates the Savitzky-Golay coefficients using sparse matrices crashes sometimes, throwing an EXC_BAD_ACCESS. I tried to find out what the problem is by turning on Address Sanitizer and Thread Sanitizer, but, for some reason, the bad access exception isn't thrown when either of these is on. What else could I try to trace back the problem? Thanks in advance, CaS To reproduce the error, run the following: import SwiftUI import Accelerate struct ContentView: View { var body: some View { VStack { Button(Try, action: test) } .padding() } func test() { for windowLength in 3...100 { let coeffs = SavitzkyGolay.coefficients(windowLength: windowLength, polynomialOrder: 2) print(coeffs) } } } class SavitzkyGolay { static func coefficients(windowLength: Int, polynomialOrder: Int, derivativeOr
11
0
1.4k
Jun ’24
Reply to Data storage for a Matrix struct when working with Accelerate
I would also like to mention that running the code below gives me almost identical elapsed times for the matrix array and matrix buffer solutions. So, at least for this case, I'm not seeing any performance differences between the two approaches. func runBenchmark1() { print(Benchmark matrix multiplication) for _ in 1...3 { let tic = Date.now let n = 8_000 let a = Matrix(rows: n, columns: n, fill: 1.5) let b = Matrix(rows: n, columns: n, fill: 2.8) let c = a * b let toc = tic.timeIntervalSinceNow.magnitude let elapsed = String(format: %.4f, toc) print(Elapsed time is (elapsed) sec, first element is (c[0, 0])) } }
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Data storage for a Matrix struct when working with Accelerate
I have a Matrix structure as defined below for working with 2D numerical data in Accelerate. The underlying numerical data in this Matrix struct is stored as an Array. struct Matrix { let rows: Int let columns: Int var data: [T] init(rows: Int, columns: Int, fill: T) { self.rows = rows self.columns = columns self.data = Array(repeating: fill, count: rows * columns) } init(rows: Int, columns: Int, source: (inout UnsafeMutableBufferPointer) -> Void) { self.rows = rows self.columns = columns self.data = Array(unsafeUninitializedCapacity: rows * columns) { buffer, initializedCount in source(&buffer) initializedCount = rows * columns } } subscript(row: Int, column: Int) -> T { get { return self.data[(row * self.columns) + column] } set { self.data[(row * self.columns) + column] = newValue } } } Multiplication is implemented by the functions shown below. import Accelerate infix operator .* func .* (lhs: Matr
3
0
964
Jun ’24
Reply to About NavigationLink Inside NavigationSplitView's Sidebar
Hi @kittens , You're seeing this behavior because the NavigationSplitView is collapsing down to a stack and showing content based on the content of the split view's columns. Here, it's showing the sidebar, and then navigating to the detail view, so the back button is taking you back to the sidebar no matter what. To change this to the behavior you are looking for, you can put a NavigationStack in the detail view. For example: NavigationSplitView { Text(Here is the FirstView) NavigationLink(Go to SecondView) { SecondView() } } detail: { NavigationStack { Text(nothing selected yet) } } Hope this helps, Sydney
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
SwiftUI DropDelegate + Scrollview auto scroll while reshuffle the item outside of scrollview bounds
We have a feature requirement where we need to use LazyVGrid and DropDelegate. Our view hierarchy is as follows: Color.white.ignoresSafeArea() VStack(spacing: 0) { customNavigationView ScrollView(showsIndicators: true) { LazyVGrid(columns: columns, alignment: .center, spacing: 16) { ForEach(viewModel.selectedReferences, id: .self) { item in ZStack { Rectangle() .fill(Color.yellow.opacity(0.5)) Text(item.title) } .frame (height: 120) .background(Color.white) .padding([.leading, .trailing], 4) .overlay((draggedItem?.uuid == item.uuid && changedView) ? Color.white.opacity(0.8) : Color.clear) .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .onDrag { initialIndex = viewModel.selectedReferences.firstIndex { $0 == item } draggedItem = item changedView = false return NSItemProvider(object: String(item.uuid) as NSString) } .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .onDrop(of: [UTType.text], delegate: DragRelocateDelegate(item: item, listData: $viewM
0
0
577
Jun ’24
Trouble navigation from detail view to grid view (root view) in app using SwiftData
I am writing an Library app that shows a grid. Each grid location shows the book cover and some info about the book. If the user clicks on a cover, the detail view opens. One option that the user has is a delete the book button. This button deletes the book from SwiftData, but the detail page remains populated. The simple way I want to handle this is to have the delete button also return to the grid view (eg root). Here is the relative code from the CurrentView @State private var path = [Book]() var body: some View { NavigationStack(path: $path) { BookListView(sort: sortOrder, searchString: searchText) .navigationTitle(Library) .navigationDestination(for: Book.self, destination: EditBookView.init) .searchable(text: $searchText) Here is the code from the Grid View var body: some View { LazyVGrid (columns: gridLayout) { ForEach(books) { book in NavigationLink(value: book) { GridRow { VStack { Here is the code from the Detail View var body: some View { Form { VStack (spacing: 0){ BookImageView(book: boo
Topic: UI Frameworks SubTopic: SwiftUI
0
0
289
Jun ’24
NSTableView cells disappear on macOS Sonoma
Hi, i have an old popover status bar mac app that i didn't check in the past few macOS releases, so don't know when the problem appeared. On Sonoma i have the following problem: All NSTableViews cells when they are reused the second time, they are blank. The cells are of type view and only one column. If i investigate in the Xcode's view hierarchy I indeed see no subviews in the cell, but if i print the subviews and their frames and their visibility, they are there alright, they exist. All the cells are instantiated from nib and I tried few strategies to use them: register the cell in the tableview and load it with tableView.makeView(withIdentifier: ) no registration, just load them from xib and keep a reference to their instance and feed that to the table when asked no registration, load them from xib when the table asks. This solution actually works but i really need a reference to them that doesn't change, it's a settings screen and someone else is feeding some info to this cells. I'm stuck, I hav
Topic: UI Frameworks SubTopic: AppKit
0
0
601
Jun ’24
UISplitViewController column-style, bug in setViewController?
&TLDR; I see no documentation stating that during the life of UISplitViewController, that I cannot call setViewController(xxxxx, column) more than once on the same column. Yet in my experience calling it a second time does not work, unless I set the value to nil before calling it again to set it to the new value... I'm using a UISplitViewController in newer column-style layout and when bootstrapping the app, I create the UISplitViewController and use setViewController(primaryViewController, .primary) and setViewController(detailViewController, .secondary). In order to use the primaryViewController for the compact scenario, I return the .primary column in the UISplitViewControllerDelegate method: splitViewController(_ svc: UISplitViewController, topColumnForCollapsingToProposedTopColumn proposedTopColumn: UISplitViewController.Column) -> UISplitViewController.Column Tapping a cell in the primaryViewController, results in a call to splitViewController.show(.secondary)
Topic: UI Frameworks SubTopic: UIKit
0
0
426
Jun ’24
SwiftData Document-based app produces strange write errors
I have a document app built using SwiftData because frankly I'm too lazy to learn how to use FileDocument. The app's title is Artsheets, and I'm using a document type that my app owns: com.wannafedor4.ArtsheetsDoc. The exported type identifier has these values: Description: Artsheets Document Identifier: com.wannafedor4.ArtsheetsDoc Conforms to: com.apple.package Reference URL: (none) Extensions: artsheets MIME Types: (none) And the code: ArtsheetsApp.swift import SwiftUI import SwiftData @main struct ArtsheetsApp: App { var body: some Scene { DocumentGroup(editing: Sheet.self, contentType: .package) { EditorView() } } } Document.swift import SwiftUI import SwiftData import UniformTypeIdentifiers @Model final class Sheet { var titleKey: String @Relationship(deleteRule: .cascade) var columns: [Column] init(titleKey: String, columns: [Column]) { self.titleKey = titleKey self.columns = columns } } @Model final class Column: Identifiable { var titlekey: String
9
0
1.7k
Jun ’24
tvOS Context Menu on LazyVGrid is selecting item below.
Context menu on tvOS LazyVGrid selecting wrong item. It works fine if selecting items on last row. Testing on code from https://developer.apple.com/videos/play/wwdc2024/10207/ I just added contextMenu LazyVGrid(columns: columns, spacing: 40) { ForEach(sortedMatchingAssets) { asset in Button {} label: { asset.landscapeImage .resizable() .aspectRatio(16 / 9, contentMode: .fit) .contextMenu { Button(Test) {} } Text(asset.title) } .buttonStyle(.borderless) } } Attached video with the bug - https://www.icloud.com/iclouddrive/020zq2PxZ_E_1Pr0vE86-8aww#Screen_Recording_2024-06-13_at_9.26.15%E2%80%AFPM
2
0
618
Jun ’24
iOS18 beta enterprise certificate trust issue
When I trusted my certificate in 'Setting'->'VPN & Device Management', my device reboot automatically. After reboot, it showed that developer of My Team is not trusted in this iPhone, but the app is verified in the second column. The UI looks like: iOS18 beta: First Col: Trust My Team Second Col: MyApp Verified Other versions: First Col: Delete App Second Col: MyApp Verified What's more, my app has plugins(extensions), my app can run normally while the extension is not able to be pulled up on iOS18 beta.
2
0
1.7k
Jun ’24