Skip to content

Commit a65db79

Browse files
Mohamed ShahawyMohamed Shahawy
authored andcommitted
Added PyPi build files
1 parent f4bbe5e commit a65db79

File tree

3 files changed

+215
-0
lines changed

3 files changed

+215
-0
lines changed

README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
![HiveNAS Logo](https://i.imgur.com/ueKRYpM.png =x100)
2+
3+
A feature-rich, Neural Architecture Search framework based on Artificial Bee Colony optimization
4+
5+
------------------------
6+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ThunderStruct/HiveNAS/blob/main/colab/HiveNas.ipynb) [![Platform](https://img.shields.io/badge/python-v3.7-green)](https://github.com/ThunderStruct/HiveNAS) [![License](https://img.shields.io/cocoapods/l/AFNetworking.svg)](https://github.com/ThunderStruct/HiveNAS/blob/master/LICENSE)
7+
8+
9+
10+
11+
## Getting Started
12+
MSCircularSlider provides a fluid and straightforward interface to a multipurpose slider UIControl. The entire library is written in Swift 5 along with the accompanying example project
13+
14+
### Installation
15+
#### PyPi (recommended)
16+
For the latest [CocoaPods](https://cocoapods.org/) release
17+
```ruby
18+
pod 'MSCircularSlider'
19+
```
20+
#### Manual Installation
21+
Simply clone the entire repo and extract the files in the `MSCircularSlider` folder, then import them into your XCode project.
22+
23+
Or use one of the shorthand methods below
24+
##### GIT
25+
- `cd` into your project directory
26+
- Use `sparse-checkout` to pull the library files only into your project directory
27+
```sh
28+
git init MSCircularSlider
29+
cd MSCircularSlider
30+
git remote add -f origin https://github.com/ThunderStruct/MSCircularSlider.git
31+
git config core.sparseCheckout true
32+
echo "MSCircularSlider/*" >> .git/info/sparse-checkout
33+
git pull --depth=1 origin master
34+
```
35+
- Import the newly pulled files into your XCode project
36+
##### SVN
37+
- `cd` into your project directory
38+
- `checkout` the library files
39+
```sh
40+
svn checkout https://github.com/ThunderStruct/MSCircularSlider/trunk/MSCircularSlider
41+
```
42+
- Import the newly checked out files into your XCode project
43+
44+
45+
### Usage
46+
#### Initialization
47+
Most members are `IBInspectable`, providing multiple ways of complete initialization; through the `Interface Builder` or programmatically
48+
##### Interface Builder Initialization
49+
50+
<p>
51+
<img src="https://i.imgur.com/iLp7ifC.png">
52+
</p>
53+
54+
##### Programmatic Initialization
55+
The following code instantiates and initializes the slider to make it identical to the one in the IB sample above
56+
```swift
57+
let frame = CGRect(x: view.center.x - 200, y: view.center.y - 200, width: 400, height 400) // center in superview
58+
let slider = MSCircularSlider(frame: frame)
59+
slider.currentValue = 60.0
60+
slider.maximumAngle = 300.0
61+
slider.filledColor = UIColor(red: 127 / 255.0, green: 168 / 255.0, blue: 198 / 255.0, alpha: 1.0)
62+
slider.unfilledColor = UIColor(red: 80 / 255.0, green: 148 / 255.0, blue: 95 / 255.0, alpha: 1.0)
63+
slider.handleType = .doubleCircle
64+
slider.handleColor = UIColor(red: 35 / 255.0, green: 69 / 255.0, blue: 96 / 255.0, alpha: 1.0)
65+
slider.handleEnlargementPoints = 12
66+
slider.labels = ["1", "2", "3", "4", "5"]
67+
view.addSubview(slider!)
68+
```
69+
70+
### Members and Methods
71+
#### MSCircularSlider
72+
- `delegate`: takes a class conforming to MSCircularSliderDelegate and handles delegation - default nil
73+
- note: please check the _Protocols_ segment below for more info about the abstract delegation model used
74+
- `minimumValue`: the value the slider takes at angle 0° - default 0.0
75+
- `maximumValue`: the value the slider takes at maximumAngle - default 100.0
76+
- `currentValue`: the value the slider has at the current angle - default 0.0
77+
- `maximumAngle`: the arc's maximum angle (360° = full circle) - default 360.0
78+
- `sliderPadding`: the padding between the frame and the drawn slider (can be used to prevent labels' clipping by enlarging the frame and increasing the padding) - default 0.0
79+
- `lineWidth`: the arc's line width - default 5
80+
- `filledColor`: the color shown for the part "filled" by the handle - default .darkGrey
81+
- `unfilledColor`: the color shown for the "unfilled" part of the circle - default .lightGrey
82+
- `rotationAngle`: the rotation transformation angle of the entire slider view - default calculated so that the _gap_ is facing downwards
83+
- note: the slider adds an inverted rotational transformation to all of its subviews to cancel any applied rotation
84+
- `handleType`: indicates the type of the handle - default .largeCircle
85+
- `handleColor`: the handle's color - default .darkGrey
86+
- `hanldeImage`: the handle's image - default nil
87+
- `handleEnlargementPoints`: the number of points the handle is larger than lineWidth - default 10
88+
- note: this property only applies to handles of types .largeCircle or .doubleCircle
89+
- `handleHighlightable`: indicates whether the handle should _highlight_ (becomes semitransparent) while being pressed - default true
90+
- `handleRotatable`: specifies whether or not the handle should rotate to always point outwards - default false
91+
- `labels`: the string array that contains all labels to be displayed in an evenly-distributed manner - default [ ]
92+
- note: all changes to this array will not be applied instantly unless they go through the assignment operator (=). To perform changes, use the provided methods below
93+
- `labelColor`: the color applied to the displayed labels - default .black
94+
- `snapToLabels`: indicates whether the handle should _snap_ to the nearest label upon handle-release - default false
95+
- `labelFont`: the font applied to the displayed labels - default .systemFont(ofSize: 12)
96+
- `labelOffset`: the number of point labels are pushed off away from the slider's center - default 0.0
97+
- note: a negative number can be used to draw the labels inwards towards the center
98+
- `markerCount`: indicates the number of markers to be displayed in an evenly-distributed manner - default 0
99+
- `markerColor`: the color applied to the displayed markers - default .darkGrey
100+
- `markerPath`: an optional UIBezierPath to draw custom-shaped markers instead of the standard ellipse markers - default nil
101+
- `markerImage`: an optional UIImage to be drawn instead of the standard ellipse markers - default nil
102+
- note: markerPath takes precedence over markerImage, so if both members are set, the images will not be drawn
103+
- `snapToMarkers`: indicates whether the handle should _snap_ to the nearest marker upon handle-release - default false
104+
- ~note: if both snapToMarkers and snapToLabels are true, the handle will be snapped to the nearest marker~ _removed mutual-exclusion in 1.1.0_
105+
- `slidingDirection`: indicates the current handle sliding direction - default .none
106+
- `revolutionsCount`: indicates the number of times the handle has revolved (requires `maximumAngle` = 360) - default 0
107+
- `maximumRevolutions`: specifies the maximum number of revolutions before the slider is bounded at 100% (`angle` = 360.0) - default -1
108+
- note: this property is valid only when `maximumAngle = 360.0`, it also prevents -ve revolutions by bounding the counter-clockwise sliding at 0% (`angle` = 0.0) and `revolutionsCount` = 0. Setting this property to any -ve value will allow the slider to revolve endlessly
109+
- `addLabel(_ string: String)`: adds a string to the labels array and triggers required drawing methods
110+
- `changeLabel(at index: Int, string: String)`: replaces the label's string at the given index with the provided string
111+
- `removeLabel(at index: Int)`: removes the string from the labels array at the given index
112+
113+
#### MSDoubleHandleCircularSlider
114+
Inherits from MSCircularSlider with the following differences
115+
116+
- `delegate`: takes a class conforming to MSDoubleHandleCircularSliderDelegate and handles delegation - default nil
117+
- note: please check the _Protocols_ segment below for more info about the abstract delegation model used
118+
- `minimumHandlesDistance`: indicates the minimum arc length between the two handles - default 10.0
119+
- `secondCurrentValue`: the current value of the second handle - default calculated from 60° angle
120+
- `secondHandleType`: indicates the type of the second handle - default .largeCircle
121+
- `secondHandleColor`: the second handle's color - default .darkGrey
122+
- `secondHandleImage`: the second handle's image - default nil
123+
- `secondHandleEnlargementPoints`: the number of points the second handle is larger than lineWidth - default 10
124+
- note: this property only applies to handles of types .largeCircle or .doubleCircle
125+
- `secondHandleHighlightable`: indicates whether the second handle should _highlight_ (becomes semitransparent) while being pressed - default true
126+
- `secondHandleRotatable`: specifies whether or not the second handle should rotate to always point outwards - default false
127+
- `snapToLabels`: indicates whether both handles should _snap_ to the nearest marker upon handle-release - default false - ~overridden and made unavailable~ _available in 1.3.0_
128+
- `snapToMarkers`: findicates whether both handles should _snap_ to the nearest label upon handle-release - default false - ~overriden and made unavailable~ _available in 1.3.0_
129+
130+
#### MSGradientCircularSlider
131+
Inherits from MSCircularSlider with the following differences
132+
133+
- `gradientColors`: the colors array upon which the gradient is calculated (as ordered in the array) - default [.lightGray, .blue, .darkGray]
134+
- note: all changes to this array will not be applied instantly unless they go through the assignment operator (=). To perform changes, use the provided methods below
135+
- `addColor(_ color: UIColor)`: adds a color to the gradientColors array and triggers required drawing methods
136+
- `changeColor(at index: Int, newColor: UIColor)`: replaces the color at the given index with the provided newColor
137+
- `removeColor(at index: Int)`: removes the color from the gradientColors array at the given index
138+
139+
### Protocols and Enums
140+
There are three protocols used in the MSCircularSlider library
141+
142+
#### MSCircularSliderProtocol
143+
An internal protocol that acts only as an abstract super class with no defined methods. The main and only `delegate` member exposed in all classes is of type MSCircularSliderProtocol and gets cast to one of the other two protocols appropriately
144+
145+
#### MSCircularSliderDelegate
146+
Inherits from MSCircularSliderProtocol and contains all methods (documented below) used by MSCircularSlider and MSGradientCircularSlider
147+
148+
- `circularSlider(_ slider: MSCircularSlider, valueChangedTo value: Double, fromUser: Bool)`: called upon currentValue change and provides a _fromUser_ Bool that indicates whether the value was changed by the user (by scrolling the handle) or through other means (programmatically or so - `currentValue = 20`)
149+
150+
- `circularSlider(_ slider: MSCircularSlider, startedTrackingWith value: Double)`: indicates that the handle started scrolling
151+
152+
- `circularSlider(_ slider: MSCircularSlider, endedTrackingWith value: Double)`: indicates that the slider's handle was released
153+
- `circularSlider(_ slider: MSCircularSlider, directionChangedTo value: MSCircularSliderDirection)`: indicates which direction the user is currently sliding
154+
- `circularSlider(_ slider: MSCircularSlider, revolutionsChangedTo value: Int)`: indicates how many times the handle has revolved around the entire slider (only valid for `maximumAngle` = 360.0 / full circle)
155+
156+
#### MSDoubleHandleCircularSliderDelegate
157+
Inherits from MSCircularSliderProtocol and is used only by MSDoubleHandleCircularSlider
158+
159+
- `circularSlider(_ slider: MSCircularSlider, valueChangedTo firstValue: Double, secondValue: Double, isFirstHandle: Bool?, fromUser: Bool) `: called upon any of the two current values changes and provides an isFirstHandle Bool indicating whether the change came from the first or second handle
160+
161+
- `circularSlider(_ slider: MSCircularSlider, startedTrackingWith firstValue: Double, secondValue: Double, isFirstHandle: Bool)`: indicates that the handle started scrolling
162+
163+
- `circularSlider(_ slider: MSCircularSlider, endedTrackingWith firstValue: Double, secondValue: Double, isFirstHandle: Bool)`: indicates that the active slider's handle was released
164+
165+
#### MSCircularSliderDirection
166+
Used to indicate which direction the user is currently sliding
167+
168+
- `.none`
169+
- `.clockwise`
170+
- `.counterclockwise`
171+
172+
173+
## License
174+
175+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/ThunderStruct/HiveNAS/blob/master/LICENSE) file for details
176+
177+

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ['setuptools>=61']
3+
build-backend = 'setuptools.build_meta'

setup.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import setuptools
2+
3+
with open('README.md', 'r') as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name='HiveNAS',
8+
version='0.1.0',
9+
author='Mohamed Shahawy',
10+
author_email='[email protected]',
11+
description='A Neural Architecture Search framework based on Artificial Bee Colony optimization',
12+
long_description=long_description,
13+
long_description_content_type='text/markdown',
14+
url='https://github.com/ThunderStruct/HiveNAS',
15+
classifiers=[
16+
'Intended Audience :: Developers',
17+
'Intended Audience :: Science/Research',
18+
'Topic :: Education',
19+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
20+
'Topic :: Utilities',
21+
'Framework :: Jupyter',
22+
'Framework :: IPython',
23+
'License :: OSI Approved :: MIT License',
24+
'Programming Language :: Python :: 3.7',
25+
'Programming Language :: Python :: 3.9',
26+
'Programming Language :: Python :: 3.10',
27+
'Operating System :: MacOS',
28+
'Operating System :: Microsoft :: Windows',
29+
'Operating System :: POSIX :: Linux'
30+
],
31+
keywords='nas neural architecture search optimization automl',
32+
package_dir = {'': 'src'},
33+
packages = setuptools.find_packages(where='src'),
34+
python_requires = '>=3.7'
35+
)

0 commit comments

Comments
 (0)